diff --git a/source/bindings/c/CMakeLists.txt b/source/bindings/c/CMakeLists.txt index d7e1bf71..96e2d72c 100644 --- a/source/bindings/c/CMakeLists.txt +++ b/source/bindings/c/CMakeLists.txt @@ -1,3 +1,5 @@ +include(CheckLinkerFlag) + find_program(PATCHELF_EXECUTABLE NAMES patchelf) if (NOT PATCHELF_EXECUTABLE AND LINUX) @@ -10,19 +12,15 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) set(gosling_c_bindings_sources ${CARGO_TARGET_DIR}/include/cgosling.h ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_STATIC} + ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_IMPL_STATIC} ) set(gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/include/cgosling.h ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} + ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_IMPL_STATIC} ) -# add Shared library import library -if (WINDOWS) - list(APPEND gosling_c_bindings_sources ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_IMPORT}) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_IMPORT}) -endif() - # # Just copy header and libs from the cgosling crate build outputs # @@ -33,46 +31,6 @@ foreach(src dest IN ZIP_LISTS gosling_c_bindings_sources gosling_c_bindings_outp COMMAND cp -P ${src} ${dest}) endforeach() -# Shared Library + Symlinks -if (LINUX) - add_custom_command( - DEPENDS ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_VERSION} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_MAJOR_VERSION} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - # copy shared library and set soname - COMMAND ${CMAKE_COMMAND} -E copy ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_VERSION} - COMMAND patchelf --set-soname libcgosling.so.${CGOSLING_MAJOR_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_VERSION} - # create symlinks - COMMAND ${CMAKE_COMMAND} -E create_symlink ${CGOSLING_SHARED}.${CGOSLING_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_MAJOR_VERSION} - COMMAND ${CMAKE_COMMAND} -E create_symlink ${CGOSLING_SHARED}.${CGOSLING_MAJOR_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_VERSION}) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_MAJOR_VERSION}) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}) -elseif(MACOS) - add_custom_command( - DEPENDS ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_VERSION}.dylib - ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_MAJOR_VERSION}.dylib - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - # copy shared library - COMMAND ${CMAKE_COMMAND} -E copy ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_VERSION}.dylib - # create symlinks - COMMAND ${CMAKE_COMMAND} -E create_symlink libcgosling.${CGOSLING_VERSION}.dylib ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_MAJOR_VERSION}.dylib - COMMAND ${CMAKE_COMMAND} -E create_symlink libcgosling.${CGOSLING_MAJOR_VERSION}.dylib ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_VERSION}.dylib) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_MAJOR_VERSION}.dylib) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}) -else() - add_custom_command( - DEPENDS ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - COMMAND ${CMAKE_COMMAND} -E copy ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}) - list(APPEND gosling_c_bindings_outputs ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}) -endif() - add_custom_target(gosling_c_bindings_target DEPENDS ${gosling_c_bindings_outputs}) add_dependencies(gosling_c_bindings_target cgosling_target) @@ -92,12 +50,6 @@ set_target_properties(gosling_c_static_bindings PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} ) -# Linux targets needed by rust runtime -if(LINUX) - target_link_libraries(gosling_c_static_bindings INTERFACE pthread) - target_link_libraries(gosling_c_static_bindings INTERFACE dl) -endif() - if(WINDOWS) target_link_libraries(gosling_c_static_bindings INTERFACE ws2_32) target_link_libraries(gosling_c_static_bindings INTERFACE userenv) @@ -112,19 +64,41 @@ add_dependencies(gosling_c_static_bindings_target gosling_c_static_bindings) # Shared Library # -add_library(gosling_c_shared_bindings SHARED IMPORTED GLOBAL) -add_dependencies(gosling_c_shared_bindings gosling_c_bindings_target) - -target_include_directories(gosling_c_shared_bindings INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/include) -set_target_properties(gosling_c_shared_bindings PROPERTIES - IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} +# generate cgosling.c +set(gosling_c_shared_bindings_sources + build_c_shared_bindings.rs + Cargo.toml + cgosling.c.handlebars) + +# cgosling.c basically forwards the various gosling calls in the public header +# to the _impl methods +add_custom_command( + DEPENDS ${gosling_c_shared_bindings_sources} gosling_c_bindings_target + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cgosling.c + # generate c source + COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo run ${CARGO_FLAGS} --bin build_c_shared_bindings ${CARGO_TARGET_DIR}/cgosling.json cgosling.c.handlebars ${CMAKE_CURRENT_BINARY_DIR}/cgosling.c + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) -if (WINDOWS) - set_target_properties(gosling_c_shared_bindings PROPERTIES - IMPORTED_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_IMPORT} - ) + +# build our shared library +add_library(gosling_c_shared_bindings SHARED ${CMAKE_CURRENT_BINARY_DIR}/cgosling.c) +set_target_properties(gosling_c_shared_bindings + PROPERTIES + OUTPUT_NAME cgosling + VERSION ${CGOSLING_VERSION} + SOVERSION ${CGOSLING_MAJOR_VERSION}) +target_include_directories(gosling_c_shared_bindings PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include) +target_link_libraries(gosling_c_shared_bindings PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_IMPL_STATIC}) +# check if the --exclude-libs flag is supported by the linker +check_linker_flag(C "-Wl,--exclude-libs,ALL" LINKER_SUPPORTS_EXCLUDE_LIBS) + +if(LINKER_SUPPORTS_EXCLUDE_LIBS) + # prevents the result so from re-exporting all of the static libs symbols out of the shared library + target_link_options(gosling_c_shared_bindings PRIVATE "-Wl,--exclude-libs,ALL") endif() +target_include_directories(gosling_c_shared_bindings PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include) + add_custom_target(gosling_c_shared_bindings_target ALL) add_dependencies(gosling_c_shared_bindings_target gosling_c_shared_bindings) @@ -136,44 +110,5 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cgosling.h TYPE INCLUDE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} TYPE LIB) -if (WINDOWS) - # .a + .dll.a goes to lib - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_IMPORT} - TYPE LIB) - # .dll goes to bin - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - TYPE BIN) -elseif (LINUX) - # .so and .a go to lib - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - TYPE LIB) - # versioned symlinks go to lib - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_MAJOR_VERSION} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED}.${CGOSLING_VERSION} - TYPE LIB) -elseif (MACOS) - # .dylib and .a go to lib - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - TYPE LIB) - # versioned symlinks go to lib - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_MAJOR_VERSION}.dylib - ${CMAKE_CURRENT_BINARY_DIR}/lib/libcgosling.${CGOSLING_VERSION}.dylib - TYPE LIB) -else() - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_STATIC} - ${CMAKE_CURRENT_BINARY_DIR}/lib/${CGOSLING_SHARED} - TYPE LIB) -endif() - +install(TARGETS gosling_c_shared_bindings) diff --git a/source/bindings/c/Cargo.lock b/source/bindings/c/Cargo.lock new file mode 100644 index 00000000..b67ea60d --- /dev/null +++ b/source/bindings/c/Cargo.lock @@ -0,0 +1,275 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "build_c_shared_bindings" +version = "0.1.0" +dependencies = [ + "handlebars", + "serde_json", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "handlebars" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "pest" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f8023d0fb78c8e03784ea1c7f3fa36e68a723138990b8d5a47d916b651e7a8" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0d24f72393fd16ab6ac5738bc33cdb6a9aa73f8b902e8fe29cf4e67d7dd1026" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc17e2a6c7d0a492f0158d7a4bd66cc17280308bbaff78d5bef566dca35ab80" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934cd7631c050f4674352a6e835d5f6711ffbfb9345c2fc0107155ac495ae293" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" diff --git a/source/bindings/c/Cargo.toml b/source/bindings/c/Cargo.toml new file mode 100644 index 00000000..f3391941 --- /dev/null +++ b/source/bindings/c/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "build_c_shared_bindings" +version = "0.1.0" +rust-version = "1.63" +edition = "2021" + +[[bin]] +name = "build_c_shared_bindings" +path = "./build_c_shared_bindings.rs" + +[dependencies] +handlebars = "^4.3.0" +serde_json = "^1.0" diff --git a/source/bindings/c/build_c_shared_bindings.rs b/source/bindings/c/build_c_shared_bindings.rs new file mode 100644 index 00000000..7357a074 --- /dev/null +++ b/source/bindings/c/build_c_shared_bindings.rs @@ -0,0 +1,23 @@ +use handlebars::Handlebars; +use serde_json::Value; + +fn main() { + + let args: Vec = std::env::args().collect(); + assert_eq!(args.len(), 4); + + let source = &args[1]; + let template = &args[2]; + let dest = &args[3]; + + let source = std::fs::read_to_string(source).unwrap(); + let source: Value = serde_json::from_str(source.as_str()).unwrap(); + + let mut handlebars = Handlebars::new(); + + handlebars.register_template_file("source", template).unwrap(); + handlebars.register_escape_fn(|val| val.to_string()); + + let dest = std::fs::File::create(dest).unwrap(); + handlebars.render_to_write("source", &source, dest).unwrap(); +} diff --git a/source/bindings/c/cgosling.c.handlebars b/source/bindings/c/cgosling.c.handlebars new file mode 100644 index 00000000..267a2edd --- /dev/null +++ b/source/bindings/c/cgosling.c.handlebars @@ -0,0 +1,8 @@ +#include +{{#each functions}} + +{{return_param}} {{name}}_impl({{#each input_params}}{{#unless (eq @index 0)}}, {{/unless}}{{typename}} {{name}}{{/each}}); +{{return_param}} {{name}}({{#each input_params}}{{#unless (eq @index 0)}}, {{/unless}}{{typename}} {{name}}{{/each}}) { + return {{name}}_impl({{#each input_params}}{{#unless (eq @index 0)}}, {{/unless}}{{name}}{{/each}}); +} +{{/each}} diff --git a/source/gosling/crates/cgosling/CMakeLists.txt b/source/gosling/crates/cgosling/CMakeLists.txt index 15621bc2..d5a8fa6e 100644 --- a/source/gosling/crates/cgosling/CMakeLists.txt +++ b/source/gosling/crates/cgosling/CMakeLists.txt @@ -17,33 +17,23 @@ set(cgosling_sources src/object_registry.rs) set(CGOSLING_STATIC "${CMAKE_STATIC_LIBRARY_PREFIX}cgosling${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "cgosling static library filename" FORCE) -if (WINDOWS) - set(CGOSLING_SHARED "cgosling${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE STRING "cgosling shared library filename" FORCE) - set(CGOSLING_IMPORT "libcgosling${CMAKE_IMPORT_LIBRARY_SUFFIX}" CACHE STRING "cgosling import library filename" FORCE) -else() - set(CGOSLING_SHARED "${CMAKE_SHARED_LIBRARY_PREFIX}cgosling${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE STRING "cgosling shared library filename" FORCE) -endif() +set(CGOSLING_IMPL_STATIC "${CMAKE_STATIC_LIBRARY_PREFIX}cgosling_impl${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "cgosling static impl library filename" FORCE) set(cgosling_outputs ${CARGO_TARGET_DIR}/include/cgosling.h ${CARGO_TARGET_DIR}/cgosling.json - ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/libcgosling.d - ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/libcgosling.rlib ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_STATIC} - ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_SHARED} + ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_IMPL_STATIC} ) -# add shared library import library if platform supports it -if ((DEFINED CGOSLING_IMPORT)) - list(APPEND cgosling_outputs ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_IMPORT}) -endif() - # # build target # add_custom_command( DEPENDS ${cgosling_sources} OUTPUT ${cgosling_outputs} + COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo build ${CARGO_FLAGS} --features impl-lib + COMMAND ${CMAKE_COMMAND} -E rename ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_STATIC} ${CARGO_TARGET_DIR}/${CARGO_PROFILE}/${CGOSLING_IMPL_STATIC} COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo build ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/source/gosling/crates/cgosling/Cargo.toml.in b/source/gosling/crates/cgosling/Cargo.toml.in index 6927cc60..2279fa74 100644 --- a/source/gosling/crates/cgosling/Cargo.toml.in +++ b/source/gosling/crates/cgosling/Cargo.toml.in @@ -17,6 +17,7 @@ serde_json = "1.0" anyhow = "^1" backtrace = ">= 0.3, <= 0.3.67" bson = ">= 2.0, <= 2.4.0" +cgosling-proc-macros = { version = "0.1.0", path = "../cgosling-proc-macros" } gosling = { version = "^0.1.0", path = "../gosling" } home = ">= 0.5, <= 0.5.5" paste = "^1.0" @@ -26,7 +27,8 @@ which = ">= 4.4.2, <= 5.0.0" [lib] name = "cgosling" -crate-type = ["staticlib", "cdylib", "rlib"] +crate-type = ["staticlib" ,"rlib"] [features] offline-test = ["gosling/offline-test"] +impl-lib = [] diff --git a/source/gosling/crates/cgosling/build.rs b/source/gosling/crates/cgosling/build.rs index baf6c534..4c7daa51 100644 --- a/source/gosling/crates/cgosling/build.rs +++ b/source/gosling/crates/cgosling/build.rs @@ -177,32 +177,35 @@ fn parse_header(mut file: File, source: &str) { } fn main() { - // set by cargo - let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); - // Set by the user or by cmake. - let target_dir = match std::env::var("CARGO_TARGET_DIR") { - Ok(target) => PathBuf::from(target), - Err(_) => Path::new(&crate_dir).join("target"), - }; - let header_file_path = target_dir.join("include").join("cgosling.h"); - println!("cargo:rerun-if-changed={}",header_file_path.display()); + if cfg! (not(feature = "impl-lib")) { + // set by cargo + let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + // Set by the user or by cmake. + let target_dir = match std::env::var("CARGO_TARGET_DIR") { + Ok(target) => PathBuf::from(target), + Err(_) => Path::new(&crate_dir).join("target"), + }; - // generate libgosling.h C header - match cbindgen::generate(&crate_dir) { - Ok(bindings) => bindings.write_to_file(header_file_path.clone().into_os_string()), - Err(cbindgen::Error::ParseSyntaxError { .. }) => return, // ignore in favor of cargo's syntax check - Err(err) => panic!("{:?}", err), - }; + let header_file_path = target_dir.join("include").join("cgosling.h"); + println!("cargo:rerun-if-changed={}",header_file_path.display()); - // convert generated header to json IDL - let json_file_path = target_dir.join("cgosling.json"); - println!("cargo:rerun-if-changed={}",json_file_path.display()); - let json_file = match File::create(json_file_path) { - Ok(file) => file, - Err(err) => panic!("{:?}", err), - }; - let source = std::fs::read_to_string(header_file_path).unwrap(); + // generate libgosling.h C header + match cbindgen::generate(&crate_dir) { + Ok(bindings) => bindings.write_to_file(header_file_path.clone().into_os_string()), + Err(cbindgen::Error::ParseSyntaxError { .. }) => return, // ignore in favor of cargo's syntax check + Err(err) => panic!("{:?}", err), + }; + + // convert generated header to json IDL + let json_file_path = target_dir.join("cgosling.json"); + println!("cargo:rerun-if-changed={}",json_file_path.display()); + let json_file = match File::create(json_file_path) { + Ok(file) => file, + Err(err) => panic!("{:?}", err), + }; + let source = std::fs::read_to_string(header_file_path).unwrap(); - parse_header(json_file, source.as_str()); + parse_header(json_file, source.as_str()); + } } diff --git a/source/gosling/crates/cgosling/src/ffi.rs b/source/gosling/crates/cgosling/src/ffi.rs index cfa65461..2b1cabac 100644 --- a/source/gosling/crates/cgosling/src/ffi.rs +++ b/source/gosling/crates/cgosling/src/ffi.rs @@ -19,6 +19,8 @@ use std::time::Duration; // extern crates use anyhow::anyhow; use anyhow::bail; +#[cfg(feature = "impl-lib")] +use cgosling_proc_macros::*; use gosling::context::*; use tor_interface::legacy_tor_client::*; use tor_interface::mock_tor_client::*; @@ -92,12 +94,14 @@ define_registry! {Error} /// A wrapper object containing an error message pub struct GoslingFFIError; -#[no_mangle] + /// Get error message from gosling_error /// /// @param error: the error object to get the message from /// @return null-terminated string with error message whose /// lifetime is tied to the source +#[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_error_get_message(error: *const GoslingFFIError) -> *const c_char { if !error.is_null() { let key = error as usize; @@ -119,6 +123,7 @@ pub extern "C" fn gosling_error_get_message(error: *const GoslingFFIError) -> *c /// @param orig_error: original to copy /// @param error: fliled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_error_clone( out_error: *mut *mut GoslingFFIError, orig_error: *const GoslingFFIError, @@ -164,6 +169,7 @@ macro_rules! impl_registry_free { /// /// @param error: the error object to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_error_free(error: *mut GoslingFFIError) { impl_registry_free!(error, Error); } @@ -200,6 +206,7 @@ define_registry! {ContextTuple} /// /// @param in_private_key: the private key to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_ed25519_private_key_free(in_private_key: *mut GoslingEd25519PrivateKey) { impl_registry_free!(in_private_key, Ed25519PrivateKey); } @@ -208,6 +215,7 @@ pub extern "C" fn gosling_ed25519_private_key_free(in_private_key: *mut GoslingE /// /// @param in_private_key: the private key to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_x25519_private_key_free(in_private_key: *mut GoslingX25519PrivateKey) { impl_registry_free!(in_private_key, X25519PrivateKey); } @@ -215,6 +223,7 @@ pub extern "C" fn gosling_x25519_private_key_free(in_private_key: *mut GoslingX2 /// /// @param public_key: the public key to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_x25519_public_key_free(in_public_key: *mut GoslingX25519PublicKey) { impl_registry_free!(in_public_key, X25519PublicKey); } @@ -222,6 +231,7 @@ pub extern "C" fn gosling_x25519_public_key_free(in_public_key: *mut GoslingX255 /// /// @param in_service_id: the service id object to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_v3_onion_service_id_free(in_service_id: *mut GoslingV3OnionServiceId) { impl_registry_free!(in_service_id, V3OnionServiceId); } @@ -229,6 +239,7 @@ pub extern "C" fn gosling_v3_onion_service_id_free(in_service_id: *mut GoslingV3 /// /// @param in_tor_provider: the tor provider object to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_tor_provider_free(in_tor_provider: *mut GoslingTorProvider) { impl_registry_free!(in_tor_provider, ContextTuple); } @@ -236,6 +247,7 @@ pub extern "C" fn gosling_tor_provider_free(in_tor_provider: *mut GoslingTorProv /// /// @param in_context: the context object to free #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_free(in_context: *mut GoslingContext) { impl_registry_free!(in_context, ContextTuple); } @@ -291,6 +303,7 @@ const GOSLING_LIBRARY_HANDLE: usize = { /// /// @return: returns 0 on success #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_library_init( out_library: *mut *mut GoslingLibrary, error: *mut *mut GoslingFFIError, @@ -315,6 +328,7 @@ pub unsafe extern "C" fn gosling_library_init( /// is not initialized or if it has already been freed #[no_mangle] #[allow(unused_variables)] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_library_free(in_library: *mut GoslingLibrary) { if GOSLING_LIBRARY_INITED.load(Ordering::Relaxed) { clear_error_registry(); @@ -335,6 +349,7 @@ pub extern "C" fn gosling_library_free(in_library: *mut GoslingLibrary) { /// @param out_private_key: returned generated ed25519 private key /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_ed25519_private_key_generate( out_private_key: *mut *mut GoslingEd25519PrivateKey, error: *mut *mut GoslingFFIError, @@ -358,6 +373,7 @@ pub unsafe extern "C" fn gosling_ed25519_private_key_generate( /// @param private_key: original to copy /// @param error: fliled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_ed25519_private_key_clone( out_private_key: *mut *mut GoslingEd25519PrivateKey, private_key: *const GoslingEd25519PrivateKey, @@ -391,6 +407,7 @@ pub unsafe extern "C" fn gosling_ed25519_private_key_clone( /// @param key_blob_length: number of chars in key_blob not including any null-terminator /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_ed25519_private_key_from_keyblob( out_private_key: *mut *mut GoslingEd25519PrivateKey, key_blob: *const c_char, @@ -430,6 +447,7 @@ pub unsafe extern "C" fn gosling_ed25519_private_key_from_keyblob( /// least 100 characters (99 for string + 1 for null-terminator) /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_ed25519_private_key_to_keyblob( private_key: *const GoslingEd25519PrivateKey, out_key_blob: *mut c_char, @@ -484,6 +502,7 @@ pub extern "C" fn gosling_ed25519_private_key_to_keyblob( /// @param private_key: original to copy /// @param error: fliled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_x25519_private_key_clone( out_private_key: *mut *mut GoslingX25519PrivateKey, private_key: *const GoslingX25519PrivateKey, @@ -516,6 +535,7 @@ pub unsafe extern "C" fn gosling_x25519_private_key_clone( /// @param base64_length: the number of chars in base64 not including any null-terminator /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_x25519_private_key_from_base64( out_private_key: *mut *mut GoslingX25519PrivateKey, base64: *const c_char, @@ -554,6 +574,7 @@ pub unsafe extern "C" fn gosling_x25519_private_key_from_base64( /// least 45 characters (44 for string + 1 for null-terminator) /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_x25519_private_key_to_base64( private_key: *const GoslingX25519PrivateKey, out_base64: *mut c_char, @@ -608,6 +629,7 @@ pub extern "C" fn gosling_x25519_private_key_to_base64( /// @param public_key: original to copy /// @param error: fliled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_x25519_public_key_clone( out_public_key: *mut *mut GoslingX25519PublicKey, public_key: *const GoslingX25519PublicKey, @@ -640,6 +662,7 @@ pub unsafe extern "C" fn gosling_x25519_public_key_clone( /// @param base32_length: the number of chars in base32 not including any null-terminator /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_x25519_public_key_from_base32( out_public_key: *mut *mut GoslingX25519PublicKey, base32: *const c_char, @@ -678,6 +701,7 @@ pub unsafe extern "C" fn gosling_x25519_public_key_from_base32( /// least 53 characters (52 for string + 1 for null-terminator) /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_x25519_public_key_to_base32( public_key: *const GoslingX25519PublicKey, out_base32: *mut c_char, @@ -732,6 +756,7 @@ pub extern "C" fn gosling_x25519_public_key_to_base32( /// @param service_id: original to copy /// @param error: fliled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_v3_onion_service_id_clone( out_service_id: *mut *mut GoslingV3OnionServiceId, service_id: *const GoslingV3OnionServiceId, @@ -765,6 +790,7 @@ pub unsafe extern "C" fn gosling_v3_onion_service_id_clone( /// null-terminator /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_v3_onion_service_id_from_string( out_service_id: *mut *mut GoslingV3OnionServiceId, service_id_string: *const c_char, @@ -802,6 +828,7 @@ pub unsafe extern "C" fn gosling_v3_onion_service_id_from_string( /// @param ed25519_private_key: an e25519 private key /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_v3_onion_service_id_from_ed25519_private_key( out_service_id: *mut *mut GoslingV3OnionServiceId, ed25519_private_key: *const GoslingEd25519PrivateKey, @@ -841,6 +868,7 @@ pub unsafe extern "C" fn gosling_v3_onion_service_id_from_ed25519_private_key( /// must be at least 57 characters (56 for string + 1 for null-terminator) /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_v3_onion_service_id_to_string( service_id: *const GoslingV3OnionServiceId, out_service_id_string: *mut c_char, @@ -899,6 +927,7 @@ pub extern "C" fn gosling_v3_onion_service_id_to_string( /// null-terminator; must be V3_ONION_SERVICE_ID_STRING_LENGTH (56) /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_string_is_valid_v3_onion_service_id( service_id_string: *const c_char, service_id_string_length: usize, @@ -936,6 +965,7 @@ pub extern "C" fn gosling_string_is_valid_v3_onion_service_id( /// null-terminator /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_tor_provider_new_legacy_client( out_tor_provider: *mut *mut GoslingTorProvider, tor_bin_path: *const c_char, @@ -994,6 +1024,7 @@ pub unsafe extern "C" fn gosling_tor_provider_new_legacy_client( /// @param out_tor_provider: returned tor provider /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_tor_provider_new_mock_client( out_tor_provider: *mut *mut GoslingTorProvider, error: *mut *mut GoslingFFIError, @@ -1023,6 +1054,7 @@ pub unsafe extern "C" fn gosling_tor_provider_new_mock_client( /// @param identity_private_key: the e25519 private key used to start th identity server's onion service /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub unsafe extern "C" fn gosling_context_init( // out context out_context: *mut *mut GoslingContext, @@ -1086,6 +1118,7 @@ pub unsafe extern "C" fn gosling_context_init( /// @param context: the gosling context object to connect to the tor network /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_bootstrap_tor( context: *mut GoslingContext, error: *mut *mut GoslingFFIError, @@ -1109,6 +1142,7 @@ pub extern "C" fn gosling_context_bootstrap_tor( /// @param context: the gosling context whose identity server to start /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_start_identity_server( context: *mut GoslingContext, error: *mut *mut GoslingFFIError, @@ -1132,6 +1166,7 @@ pub extern "C" fn gosling_context_start_identity_server( /// @param context: the gosling context whose identity server to stop /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_stop_identity_server( context: *mut GoslingContext, error: *mut *mut GoslingFFIError, @@ -1161,6 +1196,7 @@ pub extern "C" fn gosling_context_stop_identity_server( /// @param client_auth_public_key: the x25519 public key used to encrypt the onion service descriptor /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_start_endpoint_server( context: *mut GoslingContext, endpoint_private_key: *const GoslingEd25519PrivateKey, @@ -1238,6 +1274,7 @@ pub extern "C" fn gosling_context_start_endpoint_server( /// @param endpoint_private_key: the ed25519 private key associated with the endpoint server to stop /// @param error: filled on erro #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_stop_endpoint_server( context: *mut GoslingContext, endpoint_private_key: *const GoslingEd25519PrivateKey, @@ -1278,6 +1315,7 @@ pub extern "C" fn gosling_context_stop_endpoint_server( /// @param endpoint_name_length: the number of chars in endpoin_name not including any null-terminator /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_begin_identity_handshake( context: *mut GoslingContext, identity_service_id: *const GoslingV3OnionServiceId, @@ -1336,6 +1374,7 @@ pub extern "C" fn gosling_context_begin_identity_handshake( /// @param handshake_handle: the handle associated with the identity client handshake /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_abort_identity_client_handshake( context: *mut GoslingContext, handshake_handle: GoslingHandshakeHandle, @@ -1367,6 +1406,7 @@ pub extern "C" fn gosling_context_abort_identity_client_handshake( /// @param channel_name: the ascii-encoded name of the channel to open /// @param channel_name_length: the number of chars in channel name not including any null-terminator #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_begin_endpoint_handshake( context: *mut GoslingContext, endpoint_service_id: *const GoslingV3OnionServiceId, @@ -1438,6 +1478,7 @@ pub extern "C" fn gosling_context_begin_endpoint_handshake( /// @param handshake_handle: the handle associated with the identity client handshake /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_abort_endpoint_client_handshake( context: *mut GoslingContext, handshake_handle: GoslingHandshakeHandle, @@ -1993,6 +2034,7 @@ fn handle_context_event( /// @param context: the context object we are updating /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_poll_events( context: *mut GoslingContext, error: *mut *mut GoslingFFIError, @@ -2622,6 +2664,7 @@ macro_rules! impl_callback_setter { /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_tor_bootstrap_status_received_callback( context: *mut GoslingContext, callback: GoslingTorBootstrapStatusReceivedCallback, @@ -2641,6 +2684,7 @@ pub extern "C" fn gosling_context_set_tor_bootstrap_status_received_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_tor_bootstrap_completed_callback( context: *mut GoslingContext, callback: GoslingTorBootstrapCompletedCallback, @@ -2655,6 +2699,7 @@ pub extern "C" fn gosling_context_set_tor_bootstrap_completed_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_tor_log_received_callback( context: *mut GoslingContext, callback: GoslingTorLogReceivedCallback, @@ -2670,6 +2715,7 @@ pub extern "C" fn gosling_context_set_tor_log_received_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_client_challenge_response_size_callback( context: *mut GoslingContext, callback: GoslingIdentityClientHandshakeChallengeResponseSizeCallback, @@ -2689,6 +2735,7 @@ pub extern "C" fn gosling_context_set_identity_client_challenge_response_size_ca /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_client_build_challenge_response_callback( context: *mut GoslingContext, callback: GoslingIdentityClientHandshakeBuildChallengeResponseCallback, @@ -2708,6 +2755,7 @@ pub extern "C" fn gosling_context_set_identity_client_build_challenge_response_c /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_client_handshake_completed_callback( context: *mut GoslingContext, callback: GoslingIdentityClientHandshakeCompletedCallback, @@ -2727,6 +2775,7 @@ pub extern "C" fn gosling_context_set_identity_client_handshake_completed_callba /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_client_handshake_failed_callback( context: *mut GoslingContext, callback: GoslingIdentityClientHandshakeFailedCallback, @@ -2746,6 +2795,7 @@ pub extern "C" fn gosling_context_set_identity_client_handshake_failed_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_published_callback( context: *mut GoslingContext, callback: GoslingIdentityServerPublishedCallback, @@ -2760,6 +2810,7 @@ pub extern "C" fn gosling_context_set_identity_server_published_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_handshake_started_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeStartedCallback, @@ -2779,6 +2830,7 @@ pub extern "C" fn gosling_context_set_identity_server_handshake_started_callback /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_client_allowed_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeClientAllowedCallback, @@ -2798,6 +2850,7 @@ pub extern "C" fn gosling_context_set_identity_server_client_allowed_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_endpoint_supported_callback( context: *mut GoslingContext, callback: GoslingIdentityServerEndpointSupportedCallback, @@ -2817,6 +2870,7 @@ pub extern "C" fn gosling_context_set_identity_server_endpoint_supported_callbac /// @param callback: the callback to register /// @param error: filled on erro #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_challenge_size_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeChallengeSizeCallback, @@ -2836,6 +2890,7 @@ pub extern "C" fn gosling_context_set_identity_server_challenge_size_callback( /// @param callback: the callback to register /// @param error: filled on erro #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_build_challenge_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeBuildChallengeCallback, @@ -2855,6 +2910,7 @@ pub extern "C" fn gosling_context_set_identity_server_build_challenge_callback( /// @param callback: the callback to register /// @param error: filled on erro #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_verify_challenge_response_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeVerifyChallengeResponseCallback, @@ -2874,6 +2930,7 @@ pub extern "C" fn gosling_context_set_identity_server_verify_challenge_response_ /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_handshake_completed_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeCompletedCallback, @@ -2893,6 +2950,7 @@ pub extern "C" fn gosling_context_set_identity_server_handshake_completed_callba /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_handshake_rejected_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeRejectedCallback, @@ -2912,6 +2970,7 @@ pub extern "C" fn gosling_context_set_identity_server_handshake_rejected_callbac /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_identity_server_handshake_failed_callback( context: *mut GoslingContext, callback: GoslingIdentityServerHandshakeFailedCallback, @@ -2931,6 +2990,7 @@ pub extern "C" fn gosling_context_set_identity_server_handshake_failed_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_client_handshake_completed_callback( context: *mut GoslingContext, callback: GoslingEndpointClientHandshakeCompletedCallback, @@ -2950,6 +3010,7 @@ pub extern "C" fn gosling_context_set_endpoint_client_handshake_completed_callba /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_client_handshake_failed_callback( context: *mut GoslingContext, callback: GoslingEndpointClientHandshakeFailedCallback, @@ -2969,6 +3030,7 @@ pub extern "C" fn gosling_context_set_endpoint_client_handshake_failed_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_server_published_callback( context: *mut GoslingContext, callback: GoslingEndpointServerPublishedCallback, @@ -2983,6 +3045,7 @@ pub extern "C" fn gosling_context_set_endpoint_server_published_callback( /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_server_handshake_started_callback( context: *mut GoslingContext, callback: GoslingEndpointServerHandshakeStartedCallback, @@ -3002,6 +3065,7 @@ pub extern "C" fn gosling_context_set_endpoint_server_handshake_started_callback /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_server_channel_supported_callback( context: *mut GoslingContext, callback: GoslingEndpointServerChannelSupportedCallback, @@ -3021,6 +3085,7 @@ pub extern "C" fn gosling_context_set_endpoint_server_channel_supported_callback /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_server_handshake_completed_callback( context: *mut GoslingContext, callback: GoslingEndpointServerHandshakeCompletedCallback, @@ -3040,6 +3105,7 @@ pub extern "C" fn gosling_context_set_endpoint_server_handshake_completed_callba /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_server_handshake_rejected_callback( context: *mut GoslingContext, callback: GoslingEndpointServerHandshakeRejectedCallback, @@ -3059,6 +3125,7 @@ pub extern "C" fn gosling_context_set_endpoint_server_handshake_rejected_callbac /// @param callback: the callback to register /// @param error: filled on error #[no_mangle] +#[cfg_attr(feature = "impl-lib", rename_impl)] pub extern "C" fn gosling_context_set_endpoint_server_handshake_failed_callback( context: *mut GoslingContext, callback: GoslingEndpointServerHandshakeFailedCallback,