From 563fc969bfaa3c9c1e8d19f49984d25fce345eb9 Mon Sep 17 00:00:00 2001 From: John Elliott Date: Tue, 28 Nov 2023 21:33:29 -0800 Subject: [PATCH] Move sapling_backingstore_get_tree_batch to cxx_bridge Summary: X-link: https://github.com/facebookincubator/velox/pull/7781 cxx.rs provides a more ergonomic and opinionated interop layer between Rust and C++ that we would like to leverage for future API chages. This moves sapling_backingstore_get_tree_batch from the existing cbindgen implemenation to the new cxxbridge. Reviewed By: MichaelCuevas Differential Revision: D51645547 fbshipit-source-id: 0b11ea745efe02f282200fe5a325422978a1b466 --- .../CMake/RustStaticLibrary.cmake | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/build/fbcode_builder/CMake/RustStaticLibrary.cmake b/build/fbcode_builder/CMake/RustStaticLibrary.cmake index 9e4be959fb9..e6f839bdfac 100644 --- a/build/fbcode_builder/CMake/RustStaticLibrary.cmake +++ b/build/fbcode_builder/CMake/RustStaticLibrary.cmake @@ -363,7 +363,7 @@ endfunction() # `${TARGET}` CMake library target. # # ```cmake -# rust_cxx_bridge( [CRATE ]) +# rust_cxx_bridge( [CRATE ] [LIBS ]) # ``` # # Parameters: @@ -374,9 +374,11 @@ endfunction() # - CRATE_NAME: # Name of the crate. This parameter is optional. If unspecified, it will # fallback to `${TARGET}`. +# - LIBS [ ...]: +# A list of libraries that this library depends on. # function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) - fb_cmake_parse_args(ARG "" "CRATE" "" "${ARGN}") + fb_cmake_parse_args(ARG "" "CRATE" "LIBS" "${ARGN}") if(DEFINED ARG_CRATE) set(crate_name "${ARG_CRATE}") @@ -476,6 +478,11 @@ function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) $ $ ) + target_link_libraries( + ${crate_name} + PUBLIC + ${ARG_LIBS} + ) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rust") add_custom_command( @@ -517,10 +524,11 @@ function(rust_cxx_bridge TARGET CXX_BRIDGE_FILE) COMMENT "Generating cxx bindings for crate ${crate_name}" ) - target_sources(${crate_name} + target_sources( + ${crate_name} PRIVATE - "${CMAKE_CURRENT_BINARY_DIR}/${cxx_header}" - "${CMAKE_CURRENT_BINARY_DIR}/rust/cxx.h" - "${CMAKE_CURRENT_BINARY_DIR}/${cxx_source}" + "${CMAKE_CURRENT_BINARY_DIR}/${cxx_header}" + "${CMAKE_CURRENT_BINARY_DIR}/rust/cxx.h" + "${CMAKE_CURRENT_BINARY_DIR}/${cxx_source}" ) endfunction()