David Benjamin | 0e68520 | 2023-02-04 20:06:30 -0500 | [diff] [blame] | 1 | # Additional interop for things like macros and inlined functions. |
| 2 | add_library(rust_wrapper STATIC rust_wrapper.c) |
| 3 | target_link_libraries(rust_wrapper crypto) |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 4 | |
David Benjamin | 0e68520 | 2023-02-04 20:06:30 -0500 | [diff] [blame] | 5 | # Generate architecture-specific wrappers. |
David Benjamin | 8c4ec3b | 2023-02-27 12:46:12 -0500 | [diff] [blame^] | 6 | set(WRAPPER_TARGET ${CMAKE_CURRENT_BINARY_DIR}/src/wrapper_${RUST_BINDINGS}.rs) |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 7 | set(COMMAND ${BINDGEN_EXECUTABLE} "wrapper.h" |
| 8 | -o ${WRAPPER_TARGET} |
| 9 | --no-derive-default |
| 10 | --enable-function-attribute-detection |
| 11 | --use-core |
| 12 | --size_t-is-usize |
| 13 | --default-macro-constant-type="signed" |
| 14 | --rustified-enum="point_conversion_form_t" |
David Benjamin | b8b924c | 2023-02-14 16:43:50 -0500 | [diff] [blame] | 15 | --allowlist-file=".*/include/openssl/.*\\.h" |
| 16 | --allowlist-file=".*/rust_wrapper\\.h" |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 17 | -- # these are LLVM arg passthroughs |
| 18 | -I../include |
| 19 | # https://doc.rust-lang.org/nightly/rustc/platform-support.html |
| 20 | --target=${RUST_BINDINGS}) |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 21 | |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 22 | set(INCLUDES "include!(\"wrapper_${RUST_BINDINGS}.rs\");\n") |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 23 | |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 24 | add_custom_target( |
| 25 | bindgen_rust_${RUST_BINDINGS} |
| 26 | ALL |
| 27 | ${COMMAND} |
| 28 | BYPRODUCTS ${WRAPPER_TARGET} |
| 29 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 30 | ) |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 31 | |
| 32 | # move files into build directory |
| 33 | configure_file("src/lib.rs" "src/lib.rs") |
| 34 | |
| 35 | if(NOT BUILD_SHARED_LIBS) |
| 36 | configure_file("build.rs" "build.rs" COPYONLY) |
| 37 | endif() |
| 38 | |
| 39 | configure_file("Cargo.toml" "Cargo.toml" COPYONLY) |