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. |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 6 | set(WRAPPER_TARGET ${CMAKE_BINARY_DIR}/rust/src/wrapper_${RUST_BINDINGS}.rs) |
| 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" |
| 15 | # These are not BoringSSL symbols, they are from glibc |
| 16 | # and are not relevant to the build besides throwing warnings |
| 17 | # about their 'long double' (aka u128) not being FFI safe. |
| 18 | # We block those functions so that the build doesn't |
| 19 | # spam warnings. |
| 20 | # |
| 21 | # https://github.com/rust-lang/rust-bindgen/issues/1549 describes the current problem |
| 22 | # and other folks' solutions. |
| 23 | # |
| 24 | # We will explore migrating to https://github.com/rust-lang/rust-bindgen/pull/2122 |
| 25 | # when it lands |
| 26 | --blocklist-function="strtold" |
| 27 | --blocklist-function="qecvt" |
| 28 | --blocklist-function="qecvt_r" |
| 29 | --blocklist-function="qgcvt" |
| 30 | --blocklist-function="qfcvt" |
| 31 | --blocklist-function="qfcvt_r" |
| 32 | -- # these are LLVM arg passthroughs |
| 33 | -I../include |
| 34 | # https://doc.rust-lang.org/nightly/rustc/platform-support.html |
| 35 | --target=${RUST_BINDINGS}) |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 36 | |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 37 | set(INCLUDES "include!(\"wrapper_${RUST_BINDINGS}.rs\");\n") |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 38 | |
Benjamin Brittain | ea46caf | 2022-01-20 15:50:12 -0500 | [diff] [blame] | 39 | add_custom_target( |
| 40 | bindgen_rust_${RUST_BINDINGS} |
| 41 | ALL |
| 42 | ${COMMAND} |
| 43 | BYPRODUCTS ${WRAPPER_TARGET} |
| 44 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 45 | ) |
Benjamin Brittain | 8d8d8f3 | 2021-09-28 10:00:50 -0400 | [diff] [blame] | 46 | |
| 47 | # move files into build directory |
| 48 | configure_file("src/lib.rs" "src/lib.rs") |
| 49 | |
| 50 | if(NOT BUILD_SHARED_LIBS) |
| 51 | configure_file("build.rs" "build.rs" COPYONLY) |
| 52 | endif() |
| 53 | |
| 54 | configure_file("Cargo.toml" "Cargo.toml" COPYONLY) |