Browse Source

build: copy c header file

master
Dnomd343 2 years ago
parent
commit
e25f35b256
  1. 6
      CMakeLists.txt
  2. 2
      src/demo.py
  3. 7
      src/klotski_core/klotski.h
  4. 2
      src/rust_ffi/wrapper.h

6
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)

2
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()

7
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[]);

2
src/rust_ffi/wrapper.h

@ -1,3 +1,3 @@
#pragma once
#include "../klotski_core/klotski.h"
#include "../../bin/klotski.h"

Loading…
Cancel
Save