mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
f16ef7dafd
Summary: Introduce `edenapithin` crate, which offers C bindings to EdenAPI Client. There are two top-level `owned` types, `EdenApiClient` and `TreeEntryFetch`, which represent `Box`ed results from calls to EdenAPI's blocking client. The C / C++ code is responsible for calling the associated `free` functions for these types, as well as `OwnedString`, which is used to represent error variants of a `Result` as a string. Most functionality is provided through functions which operate on and return references into these top-level owned types, providing access into Rust `Result`s and `Vec`s (manually-monomorphized), and EdenApi's `TreeEntry` and `TreeChildEntry`. Additional non-pointer types are defined in the `types` module, which do not require manual memory management. C++ bindings are not included currently, but will be introduced soon. Reviewed By: fanzeyi Differential Revision: D24866065 fbshipit-source-id: bb15127b84cdbc6487b2d0e1798f37ef62e5b32d
60 lines
1.3 KiB
CMake
60 lines
1.3 KiB
CMake
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
rust_static_library(rust_bindings CRATE edenapithin)
|
|
install_rust_static_library(
|
|
rust_bindings
|
|
EXPORT mercurial
|
|
INSTALL_DIR lib
|
|
)
|
|
|
|
file(GLOB C_API_SRCS "c_api/*.cpp")
|
|
add_library(edenapithin "${C_API_SRCS}")
|
|
set_target_properties(
|
|
bindings
|
|
PROPERTIES
|
|
PUBLIC_HEADER
|
|
"c_api/RustEdenApi.h;c_api/EdenApiThinWrapper.h"
|
|
)
|
|
target_include_directories(edenapithin PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
)
|
|
target_link_libraries(
|
|
edenapithin
|
|
PRIVATE
|
|
rust_bindings
|
|
Folly::folly
|
|
)
|
|
|
|
# curl used in the Rust crate has its own copy of curl compiled and it uses
|
|
# Crypt32 and Secur32 on Windows. We need to declare the link dependencies here
|
|
# to avoid linker errors.
|
|
if (WIN32)
|
|
target_link_libraries(
|
|
edenapithin
|
|
PRIVATE
|
|
Crypt32
|
|
Secur32
|
|
Ncrypt
|
|
)
|
|
endif()
|
|
|
|
# Reqwest links against the security framework.
|
|
if (APPLE)
|
|
target_link_libraries(
|
|
edenapithin
|
|
PRIVATE
|
|
"-framework Security"
|
|
)
|
|
endif()
|
|
|
|
install(
|
|
TARGETS edenapithin
|
|
EXPORT mercurial
|
|
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
|
PUBLIC_HEADER DESTINATION "include/eden/scm/lib/edenapi/bindings/c_api"
|
|
)
|