Skip to content

Commit

Permalink
Move backingstore/c_api into include and src directories
Browse files Browse the repository at this point in the history
Summary: cxx.rs provides a more ergonomic and opinionated interop layer between Rust and C++ that we would like to leverage for future API chages. Before we get started, some preliminary changes to simplify the backingstore crate will make things easier down the line.

Reviewed By: xavierd

Differential Revision: D50998929

fbshipit-source-id: 388cb1d95d8f6d2401d373e7830c45893462044b
  • Loading branch information
jdelliot authored and facebook-github-bot committed Nov 15, 2023
1 parent 0ada94a commit ab5ab82
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 38 deletions.
2 changes: 1 addition & 1 deletion eden/fs/store/hg/HgDatapackStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "eden/fs/model/TreeFwd.h"
#include "eden/fs/telemetry/RequestMetricsScope.h"
#include "eden/fs/utils/PathFuncs.h"
#include "eden/scm/lib/backingstore/c_api/SaplingNativeBackingStore.h"
#include "eden/scm/lib/backingstore/include/SaplingNativeBackingStore.h"

namespace facebook::eden {

Expand Down
3 changes: 2 additions & 1 deletion eden/fs/store/hg/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ cpp_library(
"//eden/fs/model:model-fwd",
"//eden/fs/telemetry:telemetry",
"//eden/fs/utils:path",
"//eden/scm/lib/backingstore/c_api:c_api",
"//eden/scm/lib/backingstore:sapling_native_backingstore", # @manual
"//eden/scm/lib/backingstore:sapling_native_backingstore-include",
"//folly:range",
"//folly/futures:core",
],
Expand Down
7 changes: 4 additions & 3 deletions eden/scm/lib/backingstore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ install_rust_static_library(
INSTALL_DIR lib
)

file(GLOB C_API_SRCS "c_api/*.cpp")
file(GLOB C_API_SRCS "src/*.cpp")
file(GLOB C_API_HDRS "include/*.h")
add_library(backingstore "${C_API_SRCS}")
set_target_properties(
backingstore
PROPERTIES
PUBLIC_HEADER
"c_api/SaplingNativeBackingStore.h;c_api/BackingStoreBindings.h"
"${C_API_HDRS}"
)
target_include_directories(backingstore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -68,5 +69,5 @@ install(
TARGETS backingstore
EXPORT mercurial
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION "include/eden/scm/lib/backingstore/c_api"
PUBLIC_HEADER DESTINATION "include/eden/scm/lib/backingstore/include"
)
28 changes: 28 additions & 0 deletions eden/scm/lib/backingstore/TARGETS
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:rust_library.bzl", "rust_library")

oncall("mercurial_release")

cpp_library(
name = "sapling_native_backingstore-include",
srcs = [],
headers = glob(["include/**/*.h"]),
exported_deps = [
":backingstore",
"//folly:function",
"//folly:range",
"//folly:try",
],
)

cpp_library(
name = "sapling_native_backingstore",
srcs = glob(["src/**/*.cpp"]),
headers = [],
preferred_linkage = "static",
undefined_symbols = True,
deps = [
":sapling_native_backingstore-include",
"//folly:range",
"//folly:string",
"//folly/io:iobuf",
"//folly/logging:logging",
],
)

rust_library(
name = "backingstore",
srcs = glob(["src/**/*.rs"]),
Expand Down
25 changes: 0 additions & 25 deletions eden/scm/lib/backingstore/c_api/TARGETS

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <optional>
#include <string_view>

#include "eden/scm/lib/backingstore/c_api/BackingStoreBindings.h"
#include "eden/scm/lib/backingstore/include/BackingStoreBindings.h"

namespace folly {
class IOBuf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* GNU General Public License version 2.
*/

#include "eden/scm/lib/backingstore/c_api/SaplingNativeBackingStore.h"
#include "eden/scm/lib/backingstore/include/SaplingNativeBackingStore.h"

#include <folly/Range.h>
#include <folly/String.h>
Expand Down
4 changes: 2 additions & 2 deletions eden/scm/lib/backingstore/test/CBytesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

#include <folly/Range.h>
#include <gtest/gtest.h>
#include <folly/portability/GTest.h>
#include <cstring>

#include "eden/scm/lib/backingstore/c_api/BackingStoreBindings.h"
#include "eden/scm/lib/backingstore/include/BackingStoreBindings.h"

namespace {

Expand Down
4 changes: 2 additions & 2 deletions eden/scm/lib/backingstore/test/CFallibleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* GNU General Public License version 2.
*/

#include <gtest/gtest.h>
#include <folly/portability/GTest.h>
#include <cstdio>

#include "eden/scm/lib/backingstore/c_api/BackingStoreBindings.h"
#include "eden/scm/lib/backingstore/include/BackingStoreBindings.h"

namespace {

Expand Down
4 changes: 3 additions & 1 deletion eden/scm/lib/backingstore/test/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ cpp_unittest(
srcs = glob(["*Test.cpp"]),
supports_static_listing = False,
deps = [
"//eden/scm/lib/backingstore/c_api:c_api",
"//eden/scm/lib/backingstore:sapling_native_backingstore", # @manual
"//eden/scm/lib/backingstore:sapling_native_backingstore-include",
"//folly:range",
"//folly/portability:gtest",
],
)
2 changes: 1 addition & 1 deletion eden/scm/lib/backingstore/tools/cbindgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cd "$(dirname "$0")"/..
set -e

CONFIG="cbindgen.toml"
OUTPUT="c_api/BackingStoreBindings.h"
OUTPUT="include/BackingStoreBindings.h"

main() {
cbindgen --config "$CONFIG" --output "$OUTPUT"
Expand Down

0 comments on commit ab5ab82

Please sign in to comment.