diff --git a/eden/fs/store/filter/CMakeLists.txt b/eden/fs/store/filter/CMakeLists.txt index 3f2998aef0aaa..49b1fcba6414b 100644 --- a/eden/fs/store/filter/CMakeLists.txt +++ b/eden/fs/store/filter/CMakeLists.txt @@ -24,5 +24,5 @@ target_link_libraries(eden_store_filter PUBLIC eden_config eden_model eden_utils - # hg_eden_ffi + edenfs_ffi ${RE2_LIBRARY}) diff --git a/eden/scm/lib/CMakeLists.txt b/eden/scm/lib/CMakeLists.txt index fbec5a4e500f0..8027482235e03 100644 --- a/eden/scm/lib/CMakeLists.txt +++ b/eden/scm/lib/CMakeLists.txt @@ -3,4 +3,5 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2. +add_subdirectory(edenfs_ffi) add_subdirectory(backingstore) diff --git a/eden/scm/lib/backingstore/CMakeLists.txt b/eden/scm/lib/backingstore/CMakeLists.txt index 211a3cbca024d..39e389689c27e 100644 --- a/eden/scm/lib/backingstore/CMakeLists.txt +++ b/eden/scm/lib/backingstore/CMakeLists.txt @@ -55,7 +55,7 @@ else() ) endif() -# Reqwest links against the security framework. +# Request links against the security framework. if (APPLE) target_link_libraries( backingstore diff --git a/eden/scm/lib/edenfs_ffi/CMakeLists.txt b/eden/scm/lib/edenfs_ffi/CMakeLists.txt index db45b7a9c2596..2751e58824170 100644 --- a/eden/scm/lib/edenfs_ffi/CMakeLists.txt +++ b/eden/scm/lib/edenfs_ffi/CMakeLists.txt @@ -3,80 +3,56 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2. -find_program(CARGO_COMMAND cargo REQUIRED) -set(crate_name edenfs_ffi) -if(DEFINED ARG_FEATURES) - set(cargo_flags build - $,,--release> - -p ${crate_name} - --features ${ARG_FEATURES}) -else() - set(cargo_flags build $,,--release> -p ${crate_name}) -endif() - -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(TARGET_DIR "debug") -else () - set(TARGET_DIR "release") -endif () - -if(USE_CARGO_VENDOR) - set(extra_cargo_env "CARGO_HOME=${RUST_CARGO_HOME}") - set(cargo_flags ${cargo_flags}) -endif() - -set(CARGO_MANIFEST ${CMAKE_SOURCE_DIR}/eden/scm/lib/edenfs_ffi/Cargo.toml) -set(CARGO_TARGET_DIR ${CMAKE_SOURCE_DIR}/eden/scm/lib/edenfs_ffi/target) - -set(FFI_SOURCE_FILE ${CMAKE_SOURCE_DIR}/eden/scm/lib/edenfs_ffi/src/lib.rs) -set(FFI_BRIDGE_CPP ${CARGO_TARGET_DIR}/cxxbridge/edenfs_ffi/src/lib.rs.cc) -set(FFI_LIB ${CARGO_TARGET_DIR}/${TARGET_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}edenfs_ffi${CMAKE_STATIC_LIBRARY_SUFFIX}) - -# Add a custom command that builds the rust crate and generates C++ bridge code -add_custom_command( - OUTPUT ${FFI_BRIDGE_CPP} ${FFI_LIB} - COMMAND ${extra_cargo_env} - ${CARGO_COMMAND} - ${cargo_flags} - --manifest-path ${CARGO_MANIFEST} - DEPENDS ${FFI_SOURCE_FILE} - USES_TERMINAL - COMMENT "Running cargo..." +rust_static_library(rust_edenfs_ffi CRATE edenfs_ffi) +install_rust_static_library( + rust_edenfs_ffi + INSTALL_DIR lib ) -file(GLOB STORE_FFI_SRCS ${FFI_BRIDGE_CPP}) - -add_library( - hg_eden_ffi STATIC - ${FFI_BRIDGE_CPP} +file(GLOB edenfs_ffi_srcs "src/ffi.cpp") +add_library(edenfs_ffi "${edenfs_ffi_srcs}") +set_target_properties( + edenfs_ffi + PROPERTIES + PUBLIC_HEADER + "src/ffi.h" ) - target_include_directories( - hg_eden_ffi - PRIVATE - include/ - ${CARGO_TARGET_DIR}/eden/scm/lib/edenfs_ffi/src/ + edenfs_ffi + PUBLIC + $ + $ + ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/ ) - -target_link_libraries(hg_eden_ffi PUBLIC - eden_model - eden_utils - ${RE2_LIBRARY} - ${FFI_LIB}) - -set_target_properties( - hg_eden_ffi - PROPERTIES ADDITIONAL_CLEAN_FILES ${CARGO_TARGET_DIR} +target_link_libraries( + edenfs_ffi + PRIVATE + rust_edenfs_ffi + Folly::folly + eden_model + eden_utils + ${RE2_LIBRARY} ) # Windows-only configuration if(WIN32) - target_link_libraries(hg_eden_ffi userenv ws2_32 bcrypt) - set_target_properties( - hg_eden_ffi - PROPERTIES - MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} - ) + target_link_libraries( + edenfs_ffi + userenv + ws2_32 + bcrypt + ) + set_target_properties( + edenfs_ffi + PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} + ) endif() + +install( + TARGETS edenfs_ffi + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + PUBLIC_HEADER DESTINATION "include/eden/scm/lib/edenfs_ffi/src" +) diff --git a/eden/scm/lib/edenfs_ffi/src/ffi.h b/eden/scm/lib/edenfs_ffi/src/ffi.h index 8dabfbb45c584..4bdf3480a4d5b 100644 --- a/eden/scm/lib/edenfs_ffi/src/ffi.h +++ b/eden/scm/lib/edenfs_ffi/src/ffi.h @@ -8,8 +8,8 @@ #pragma once #include +#include #include -#include "rust/cxx.h" namespace facebook::eden {