sapling/eden/scm/lib/edenapi/bindings/CMakeLists.txt
Meyer Jacobs f16ef7dafd bindings: introduce C / C++ bindings to EdenAPI for use by EdenFS
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
2020-12-01 19:07:25 -08:00

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"
)