From e25f35b2561485812abd8563f4d75a98dc93bb3e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 29 Jan 2023 00:26:11 +0800 Subject: [PATCH] build: copy c header file --- CMakeLists.txt | 6 ++++++ src/demo.py | 2 +- src/klotski_core/klotski.h | 7 +++---- src/rust_ffi/wrapper.h | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 890f9db..ae8ac65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) +file( + COPY ${PROJECT_SOURCE_DIR}/src/klotski_core/klotski.h + DESTINATION ${PROJECT_SOURCE_DIR}/bin + FOLLOW_SYMLINK_CHAIN +) + # TODO: only in libklotski.so add_compile_options(-fPIC) diff --git a/src/demo.py b/src/demo.py index bb877df..4fd69c8 100755 --- a/src/demo.py +++ b/src/demo.py @@ -2,6 +2,6 @@ import ctypes -lib = ctypes.CDLL('../cmake-build-release/src/klotski_core/libklotski.so') +lib = ctypes.CDLL('../bin/libklotski.so') lib.tmain() diff --git a/src/klotski_core/klotski.h b/src/klotski_core/klotski.h index 72bec22..9d72867 100644 --- a/src/klotski_core/klotski.h +++ b/src/klotski_core/klotski.h @@ -22,7 +22,7 @@ extern "C" { #ifdef __cplusplus extern "C" { #endif - /// version -> major.minor.patch + // version -> major.minor.patch extern int get_version_major(); extern int get_version_minor(); extern int get_version_patch(); @@ -62,7 +62,7 @@ extern "C" { #ifdef __cplusplus extern "C" { #endif - /// short code warm up api + // short code index warm up extern void short_code_enable(); extern void short_code_enable_fast(); extern bool is_short_code_available(); @@ -72,6 +72,7 @@ extern "C" { extern bool short_code_check(uint32_t short_code); extern bool common_code_check(uint64_t common_code); + // TODO: allow unsafe convert extern bool raw_code_to_short_code(uint64_t raw_code, uint32_t *short_code); extern bool short_code_to_raw_code(uint32_t short_code, uint64_t *raw_code); extern bool raw_code_to_common_code(uint64_t raw_code, uint64_t *common_code); @@ -79,12 +80,10 @@ extern "C" { extern bool short_code_to_common_code(uint32_t short_code, uint64_t *common_code); extern bool common_code_to_short_code(uint64_t common_code, uint32_t *short_code); - /// output char[] buffer at least 6-bytes extern const uint32_t SHORT_CODE_STR_SIZE; extern bool short_code_to_string(uint32_t short_code, char short_code_str[]); extern bool short_code_from_string(const char short_code_str[], uint32_t *short_code); - /// output char[] buffer at least 10-bytes extern const uint32_t COMMON_CODE_STR_SIZE; extern bool common_code_to_string(uint64_t common_code, char common_code_str[]); extern bool common_code_to_string_shorten(uint64_t common_code, char common_code_str[]); diff --git a/src/rust_ffi/wrapper.h b/src/rust_ffi/wrapper.h index 5b97c58..2fcfc5e 100644 --- a/src/rust_ffi/wrapper.h +++ b/src/rust_ffi/wrapper.h @@ -1,3 +1,3 @@ #pragma once -#include "../klotski_core/klotski.h" +#include "../../bin/klotski.h"