blob: 344d80f5f84ef7c41eee5556a6d97daaf8bd5124 [file] [log] [blame]
David Benjamin0e685202023-02-04 20:06:30 -05001# Additional interop for things like macros and inlined functions.
2add_library(rust_wrapper STATIC rust_wrapper.c)
3target_link_libraries(rust_wrapper crypto)
Benjamin Brittain8d8d8f32021-09-28 10:00:50 -04004
David Benjamin0e685202023-02-04 20:06:30 -05005# Generate architecture-specific wrappers.
Benjamin Brittainea46caf2022-01-20 15:50:12 -05006set(WRAPPER_TARGET ${CMAKE_BINARY_DIR}/rust/src/wrapper_${RUST_BINDINGS}.rs)
7set(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 Brittain8d8d8f32021-09-28 10:00:50 -040036
Benjamin Brittainea46caf2022-01-20 15:50:12 -050037set(INCLUDES "include!(\"wrapper_${RUST_BINDINGS}.rs\");\n")
Benjamin Brittain8d8d8f32021-09-28 10:00:50 -040038
Benjamin Brittainea46caf2022-01-20 15:50:12 -050039add_custom_target(
40 bindgen_rust_${RUST_BINDINGS}
41 ALL
42 ${COMMAND}
43 BYPRODUCTS ${WRAPPER_TARGET}
44 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
45)
Benjamin Brittain8d8d8f32021-09-28 10:00:50 -040046
47# move files into build directory
48configure_file("src/lib.rs" "src/lib.rs")
49
50if(NOT BUILD_SHARED_LIBS)
51 configure_file("build.rs" "build.rs" COPYONLY)
52endif()
53
54configure_file("Cargo.toml" "Cargo.toml" COPYONLY)