add CMake build files

Summary: Add CMakeFiles to build Eden.

Reviewed By: wez

Differential Revision: D7479587

fbshipit-source-id: 7e0b4a756005dadc3af5c13c36ce22d1dcc15071
This commit is contained in:
Adam Simpkins 2018-04-30 14:28:44 -07:00 committed by Facebook Github Bot
parent 534f6ee996
commit dea514bbef
32 changed files with 848 additions and 26 deletions

View File

@ -0,0 +1,28 @@
set(CMAKE_CXX_FLAGS_COMMON "-g -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_COMMON}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_COMMON} -O3")
list(APPEND CMAKE_REQUIRED_FLAGS -std=gnu++14)
function(apply_eden_compile_options_to_target THETARGET)
target_compile_options(${THETARGET}
PUBLIC
-g
-std=gnu++14
-finput-charset=UTF-8
-fsigned-char
-Werror
-Wall
-Wno-deprecated
-Wdeprecated-declarations
-Wno-error=deprecated-declarations
-Wno-sign-compare
-Wno-unused
-Wunused-label
-Wunused-result
-Wnon-virtual-dtor
${FOLLY_CXX_FLAGS}
PRIVATE
-D_REENTRANT
-D_GNU_SOURCE
)
endfunction()

View File

@ -0,0 +1,27 @@
include(FindPkgConfig)
find_package(folly CONFIG REQUIRED)
find_package(wangle CONFIG REQUIRED)
find_package(FBThrift CONFIG REQUIRED)
find_package(GMock MODULE REQUIRED)
find_package(SELinux)
set(EDEN_HAVE_SELINUX SELINUX_FOUND)
find_package(LibGit2 REQUIRED)
# The following packages ship with their own CMake configuration files
find_package(cpptoml CONFIG REQUIRED)
find_package(gflags CONFIG REQUIRED)
# TODO: It shouldn't be too hard to turn RocksDB and sqlite3 into optional
# dependencies, since we have alternate LocalStore implementations.
find_package(RocksDB CONFIG REQUIRED)
set(EDEN_HAVE_ROCKSDB RocksDB_FOUND)
find_package(Sqlite3 REQUIRED)
set(EDEN_HAVE_SQLITE3 SQLITE3_FOUND)
find_package(cpptoml REQUIRED)
# We currently do not have treemanifest support in the opensource build
set(EDEN_HAVE_HG_TREEMANIFEST OFF)

126
CMake/FindGMock.cmake Normal file
View File

@ -0,0 +1,126 @@
#
# Find libgmock
#
# LIBGMOCK_DEFINES - List of defines when using libgmock.
# LIBGMOCK_INCLUDE_DIR - where to find gmock/gmock.h, etc.
# LIBGMOCK_LIBRARIES - List of libraries when using libgmock.
# LIBGMOCK_FOUND - True if libgmock found.
find_package(PkgConfig)
IF (LIBGMOCK_INCLUDE_DIR)
# Already in cache, be silent
SET(GMock_FIND_QUIETLY TRUE)
ENDIF ()
set(CMAKE_IMPORT_FILE_VERSION 1)
pkg_check_modules(GMOCK gmock QUIET)
if(GMOCK_FOUND)
add_library(gmock UNKNOWN IMPORTED)
set_target_properties(
gmock PROPERTIES
IMPORTED_CONFIGURATIONS NOCONFIG
IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX"
IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "${GMOCK_LDFLAGS}"
INTERFACE_COMPILE_OPTIONS "${GMOCK_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${GMOCK_INCLUDE_DIRS}"
)
set(GMOCK_LIBRARY gmock)
endif()
pkg_check_modules(GMOCK_MAIN gmock_main QUIET)
if(GMOCK_MAIN_FOUND)
add_library(gmock_main UNKNOWN IMPORTED)
set_target_properties(
gmock_main PROPERTIES
IMPORTED_CONFIGURATIONS NOCONFIG
IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX"
IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "${GMOCK_MAIN_LDFLAGS}"
INTERFACE_COMPILE_OPTIONS "${GMOCK_MAIN_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${GMOCK_MAIN_INCLUDE_DIRS}"
)
set(GMOCK_MAIN_LIBRARY gmock_main)
endif()
pkg_check_modules(GTEST gtest QUIET)
if(GTEST_FOUND)
add_library(gtest UNKNOWN IMPORTED)
set_target_properties(
gtest PROPERTIES
IMPORTED_CONFIGURATIONS NOCONFIG
IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX"
IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "${GTEST_LDFLAGS}"
INTERFACE_COMPILE_OPTIONS "${GTEST_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}"
)
set(GTEST_LIBRARY gtest)
endif()
pkg_check_modules(GTEST_MAIN gtest_main QUIET)
if(GTEST_MAIN_FOUND)
add_library(gtest_main UNKNOWN IMPORTED)
set_target_properties(
gtest_main PROPERTIES
IMPORTED_CONFIGURATIONS NOCONFIG
IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX"
IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "${GTEST_MAIN_LDFLAGS}"
INTERFACE_COMPILE_OPTIONS "${GTEST_MAIN_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_MAIN_INCLUDE_DIRS}"
)
set(GTEST_MAIN_LIBRARY gtest_main)
endif()
set(CMAKE_IMPORT_FILE_VERSION)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
LIBGMOCK
DEFAULT_MSG
GMOCK_INCLUDEDIR
GMOCK_LIBRARY
GMOCK_MAIN_LIBRARY
GTEST_LIBRARY
GTEST_MAIN_LIBRARY
)
return()
FIND_PATH(LIBGMOCK_INCLUDE_DIR gmock/gmock.h)
FIND_LIBRARY(LIBGMOCK_MAIN_LIBRARY gmock_main)
FIND_LIBRARY(LIBGMOCK_LIBRARY gmock)
FIND_LIBRARY(LIBGTEST_LIBRARY gtest)
set(LIBGMOCK_LIBRARIES
${LIBGMOCK_MAIN_LIBRARY}
${LIBGMOCK_LIBRARY}
${LIBGTEST_LIBRARY}
)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# The GTEST_LINKED_AS_SHARED_LIBRARY macro must be set properly on Windows.
#
# There isn't currently an easy way to determine if a library was compiled as
# a shared library on Windows, so just assume we've been built against a
# shared build of gmock for now.
SET(LIBGMOCK_DEFINES "GTEST_LINKED_AS_SHARED_LIBRARY=1" CACHE STRING "")
endif()
# handle the QUIETLY and REQUIRED arguments and set LIBGMOCK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
LIBGMOCK
DEFAULT_MSG
LIBGMOCK_MAIN_LIBRARY
LIBGMOCK_LIBRARY
LIBGTEST_LIBRARY
LIBGMOCK_LIBRARIES
LIBGMOCK_INCLUDE_DIR
)
MARK_AS_ADVANCED(
LIBGMOCK_DEFINES
LIBGMOCK_MAIN_LIBRARY
LIBGMOCK_LIBRARY
LIBGTEST_LIBRARY
LIBGMOCK_LIBRARIES
LIBGMOCK_INCLUDE_DIR
)

41
CMake/FindLibGit2.cmake Normal file
View File

@ -0,0 +1,41 @@
#
# Find libgit2
#
# This package sets:
# LIBGIT2_FOUND - Whether libgit2 was found
# LIBGIT2_INCLUDE_DIR - The include directory for libgit2
# LIBGIT2_LIBRARY - The libgit2 library
#
include(FindPackageHandleStandardArgs)
find_package(PkgConfig)
pkg_check_modules(LIBGIT2 libgit2 QUIET)
if(LIBGIT2_FOUND)
set(CMAKE_IMPORT_FILE_VERSION 1)
add_library(libgit2 INTERFACE)
target_compile_options(libgit2 INTERFACE "${LIBGIT2_CFLAGS_OTHER}")
target_compile_options(
libgit2 INTERFACE
"${LIBGIT2_CFLAGS_OTHER}"
)
target_include_directories(
libgit2 INTERFACE
"${LIBGIT2_INCLUDE_DIR}"
)
target_link_libraries(
libgit2 INTERFACE
"${LIBGIT2_LDFLAGS}"
)
set(LIBGIT2_LIBRARY libgit2)
set(CMAKE_IMPORT_FILE_VERSION)
endif()
find_package_handle_standard_args(
LIBGIT2
DEFAULT_MSG
LIBGIT2_PREFIX
LIBGIT2_VERSION
LIBGIT2_LIBRARY
)
mark_as_advanced(LIBGIT2_LIBRARY)

28
CMake/FindSELinux.cmake Normal file
View File

@ -0,0 +1,28 @@
#
# Find libselinux
#
# This package sets:
# SELINUX_FOUND - Whether selinux was found
# SELINUX_INCLUDE_DIR - The include directory for selinux
# SELINUX_LIBRARIES - The selinux libraries
#
include(FindPackageHandleStandardArgs)
find_path(SELINUX_INCLUDE_DIR NAMES selinux/selinux.h)
find_library(SEPOL_LIBRARY NAMES sepol)
find_library(SELINUX_LIBRARY NAMES selinux)
list(APPEND SELINUX_LIBRARIES ${SELINUX_LIBRARY} ${SEPOL_LIBRARY})
find_package_handle_standard_args(
SELINUX
DEFAULT_MSG
SELINUX_INCLUDE_DIR
SELINUX_LIBRARY
SEPOL_LIBRARY
SELINUX_LIBRARIES
)
mark_as_advanced(
SELINUX_INCLUDE_DIR
SELINUX_LIBRARY
SEPOL_LIBRARY
SELINUX_LIBRARIES
)

19
CMake/FindSqlite3.cmake Normal file
View File

@ -0,0 +1,19 @@
#
# Find sqlite3
#
# This package sets:
# SQLITE3_FOUND - Whether sqlite3 was found
# SQLITE3_INCLUDE_DIR - The include directory for sqlite3
# SQLITE3_LIBRARY - The sqlite3 library
#
include(FindPackageHandleStandardArgs)
find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)
find_library(SQLITE3_LIBRARY NAMES sqlite3)
find_package_handle_standard_args(
SQLITE3
DEFAULT_MSG
SQLITE3_INCLUDE_DIR
SQLITE3_LIBRARY
)
mark_as_advanced(SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY)

17
CMake/Findcpptoml.cmake Normal file
View File

@ -0,0 +1,17 @@
#
# Find cpptoml
#
# This package sets:
# CPPTOML_FOUND - Whether cpptoml was found
# CPPTOML_INCLUDE_DIR - The include directory for cpptoml
# cpptoml is a header-only library, so there is no CPPTOML_LIBRARY variable.
#
include(FindPackageHandleStandardArgs)
find_path(CPPTOML_INCLUDE_DIR NAMES cpptoml.h)
find_package_handle_standard_args(
CPPTOML
DEFAULT_MSG
CPPTOML_INCLUDE_DIR
)
mark_as_advanced(CPPTOML_INCLUDE_DIR)

View File

@ -0,0 +1,114 @@
function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
# Parse the arguments
set(SERVICES)
set(DEPENDS)
set(GEN_ARGS)
set(mode "UNSET")
foreach(arg IN LISTS ARGN)
if("${arg}" STREQUAL "SERVICES")
set(mode "SERVICES")
elseif("${arg}" STREQUAL "DEPENDS")
set(mode "DEPENDS")
elseif("${arg}" STREQUAL "OPTIONS")
set(mode "OPTIONS")
else()
if("${mode}" STREQUAL "SERVICES")
list(APPEND SERVICES "${arg}")
elseif("${mode}" STREQUAL "DEPENDS")
list(APPEND DEPENDS "${arg}")
elseif("${mode}" STREQUAL "OPTIONS")
list(APPEND GEN_ARGS "${arg}")
else()
message(
FATAL_ERROR
"expected SERVICES, DEPENDS, or OPTIONS argument, found ${arg}"
)
endif()
endif()
endforeach()
get_filename_component(base ${THRIFT_FILE} NAME_WE)
get_filename_component(
output_dir
${CMAKE_CURRENT_BINARY_DIR}/${THRIFT_FILE}
DIRECTORY
)
list(APPEND GEN_ARGS "include_prefix=${output_dir}")
# CMake 3.12 is finally getting a list(JOIN) function, but until then
# treating the list as a string and replacing the semicolons is good enough.
string(REPLACE ";" "," GEN_ARG_STR "${GEN_ARGS}")
# Compute the list of generated files
list(APPEND generated_headers
${output_dir}/gen-cpp2/${base}_constants.h
${output_dir}/gen-cpp2/${base}_constants.cpp
${output_dir}/gen-cpp2/${base}_types.h
${output_dir}/gen-cpp2/${base}_types.tcc
${output_dir}/gen-cpp2/${base}_types_custom_protocol.h
)
list(APPEND generated_sources
${output_dir}/gen-cpp2/${base}_data.h
${output_dir}/gen-cpp2/${base}_data.cpp
${output_dir}/gen-cpp2/${base}_types.cpp
)
foreach(service IN LISTS SERVICES)
list(APPEND generated_headers
${output_dir}/gen-cpp2/${service}.h
${output_dir}/gen-cpp2/${service}.tcc
${output_dir}/gen-cpp2/${service}AsyncClient.h
${output_dir}/gen-cpp2/${service}_custom_protocol.h
)
list(APPEND generated_sources
${output_dir}/gen-cpp2/${service}.cpp
${output_dir}/gen-cpp2/${service}_client.cpp
${output_dir}/gen-cpp2/${service}_processmap_binary.cpp
${output_dir}/gen-cpp2/${service}_processmap_compact.cpp
)
endforeach()
# Emit the rule to run the thrift compiler
add_custom_command(
OUTPUT
${generated_headers}
${generated_sources}
COMMAND
${CMAKE_COMMAND} -E make_directory ${output_dir}
COMMAND
${FBTHRIFT_COMPILER}
--strict
--templates ${FBTHRIFT_TEMPLATES_DIR}
--gen "mstch_cpp2:${GEN_ARG_STR}"
-I ${CMAKE_SOURCE_DIR}
-o ${output_dir}
${CMAKE_CURRENT_SOURCE_DIR}/${THRIFT_FILE}
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}
MAIN_DEPENDENCY
${THRIFT_FILE}
DEPENDS
${DEPENDS}
)
# Now emit the library rule to compile the sources
add_library(${LIB_NAME} STATIC
${generated_sources}
)
set_property(
TARGET ${LIB_NAME}
PROPERTY PUBLIC_HEADER
${generated_headers}
)
target_include_directories(
${LIB_NAME}
PUBLIC
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
target_link_libraries(
${LIB_NAME}
PUBLIC
${DEPENDS}
FBThrift::thriftcpp2
)
endfunction()

18
CMake/eden-config.h.in Normal file
View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#define EDEN_VERSION "${PACKAGE_VERSION}"
#cmakedefine EDEN_HAVE_HG_TREEMANIFEST
#cmakedefine EDEN_HAVE_ROCKSDB
#cmakedefine EDEN_HAVE_SQLITE3
#cmakedefine EDEN_HAVE_SELINUX

36
CMakeLists.txt Normal file
View File

@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR)
# We use the GoogleTest module if it is available (only in CMake 3.9+)
# It requires CMP0054 and CMP0057 to be enabled.
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
# Project information
project("eden" LANGUAGES CXX C)
# Tell CMake to also look in the directories where getdeps.py installs
# our third-party dependencies.
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/install")
# CMake include directories
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
set(CMAKE_CXX_STANDARD 14)
include(CompilerSettingsUnix)
include(EdenConfigChecks)
include(ThriftCppLibrary)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/eden-config.h.in
${CMAKE_CURRENT_BINARY_DIR}/eden/fs/eden-config.h
)
add_subdirectory(common)
add_subdirectory(eden/fs)

36
common/CMakeLists.txt Normal file
View File

@ -0,0 +1,36 @@
add_thrift_cpp2_library(
fb303_thrift_cpp2
fb303/if/fb303.thrift
SERVICES
FacebookService
)
add_library(
common_stats STATIC
stats/ServiceData.cpp
)
set_property(
TARGET common_stats
PROPERTY PUBLIC_HEADER
stats/ExportedHistogramMap.h
stats/ExportedHistogramMapImpl.h
stats/ExportedStatMap.h
stats/ExportedStatMapImpl.h
stats/ExportType.h
stats/DynamicCounters.h
stats/MonotonicCounter.h
stats/ServiceData.h
stats/ThreadCachedServiceData.h
stats/ThreadLocalStats.h
)
target_include_directories(
common_stats
PUBLIC
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
target_link_libraries(
common_stats
PUBLIC
Folly::folly
)

27
eden/fs/CMakeLists.txt Normal file
View File

@ -0,0 +1,27 @@
add_executable(
edenfs
service/main.cpp
)
target_include_directories(
edenfs
PUBLIC
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
target_link_libraries(
edenfs
eden_service
Folly::folly
)
add_subdirectory(config)
add_subdirectory(fuse)
add_subdirectory(inodes)
add_subdirectory(journal)
add_subdirectory(model)
add_subdirectory(rocksdb)
add_subdirectory(service)
add_subdirectory(sqlite)
add_subdirectory(store)
add_subdirectory(takeover)
add_subdirectory(utils)

View File

@ -0,0 +1,15 @@
file(GLOB CONFIG_SRCS "*.cpp")
add_library(
eden_config STATIC
${CONFIG_SRCS}
)
target_link_libraries(
eden_config
PUBLIC
eden_utils
)
target_include_directories(
eden_config
PRIVATE
${CPPTOML_INCLUDE_DIR}
)

16
eden/fs/eden-config.h Normal file
View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#define EDEN_HAVE_HG_TREEMANIFEST 1
#define EDEN_HAVE_ROCKSDB 1
#define EDEN_HAVE_SQLITE3 1
#define EDEN_HAVE_SELINUX 1

View File

@ -0,0 +1,24 @@
add_thrift_cpp2_library(
eden_fuse_handlemap
handlemap.thrift
)
file(GLOB FUSE_SRCS "*.cpp")
add_library(
eden_fuse STATIC
${FUSE_SRCS}
privhelper/PrivHelper.cpp
privhelper/PrivHelperConn.cpp
privhelper/PrivHelperServer.cpp
privhelper/UserInfo.cpp
)
target_link_libraries(
eden_fuse
PUBLIC
eden_fuse_handlemap
eden_fuse_privhelper
common_stats
Folly::folly
)
add_subdirectory(privhelper)

View File

@ -0,0 +1,17 @@
file(GLOB PRIVHELPER_SRCS "*.cpp")
add_library(
eden_fuse_privhelper STATIC
${PRIVHELPER_SRCS}
)
target_include_directories(
eden_fuse_privhelper
PRIVATE
${SELINUX_INCLUDE_DIR}
)
target_link_libraries(
eden_fuse_privhelper
PUBLIC
eden_utils
Folly::folly
${SELINUX_LIBRARIES}
)

View File

@ -9,14 +9,17 @@
*/
#include "eden/fs/fuse/privhelper/UserInfo.h"
#include <grp.h>
#include <pwd.h>
#include <selinux/selinux.h>
#include <sys/prctl.h>
#include <vector>
#include <folly/Exception.h>
#include <folly/experimental/logging/xlog.h>
#include <grp.h>
#include <pwd.h>
#include <sys/prctl.h>
#include <vector>
#include "eden/fs/eden-config.h"
#ifdef EDEN_HAVE_SELINUX
#include <selinux/selinux.h>
#endif // EDEN_HAVE_SELINUX
using folly::checkUnixError;
using folly::throwSystemError;
@ -30,6 +33,7 @@ struct UserInfo::PasswdEntry {
};
static void dropToBasicSELinuxPrivileges() {
#ifdef EDEN_HAVE_SELINUX
const char* baseContext = "user_u:base_r:base_t";
XLOG(DBG2) << "Dropping SELinux context..." << [&] {
@ -48,6 +52,7 @@ static void dropToBasicSELinuxPrivileges() {
if (setcon(const_cast<char*>(baseContext))) {
XLOG(WARN) << "setcon() failed when dropping SELinux context";
}
#endif // EDEN_HAVE_SELINUX
}
void UserInfo::dropPrivileges() {

View File

@ -0,0 +1,19 @@
add_thrift_cpp2_library(
eden_overlay_thrift
overlay.thrift
)
file(GLOB INODES_SRCS "*.cpp")
add_library(
eden_inodes STATIC
${INODES_SRCS}
)
target_link_libraries(
eden_inodes
PUBLIC
eden_overlay_thrift
eden_fuse
eden_journal
eden_store
eden_utils
)

View File

@ -0,0 +1,11 @@
file(GLOB JOURNAL_SRCS "*.cpp")
add_library(
eden_journal STATIC
${JOURNAL_SRCS}
)
target_link_libraries(
eden_journal
PUBLIC
eden_model
eden_utils
)

View File

@ -0,0 +1,13 @@
file(GLOB MODEL_SRCS "*.cpp")
add_library(
eden_model STATIC
${MODEL_SRCS}
)
target_link_libraries(
eden_model
PUBLIC
eden_utils
Folly::folly
)
add_subdirectory(git)

View File

@ -0,0 +1,10 @@
file(GLOB MODEL_GIT_SRCS "*.cpp")
add_library(
eden_model_git STATIC
${MODEL_GIT_SRCS}
)
target_link_libraries(
eden_model_git
PUBLIC
eden_model
)

View File

@ -0,0 +1,10 @@
file(GLOB ROCKSDB_SRCS "*.cpp")
add_library(
eden_rocksdb STATIC
${ROCKSDB_SRCS}
)
target_link_libraries(
eden_rocksdb
PUBLIC
RocksDB::rocksdb
)

View File

@ -0,0 +1,38 @@
add_thrift_cpp2_library(
eden_service_thrift
eden.thrift
SERVICES
EdenService
DEPENDS
fb303_thrift_cpp2
)
add_thrift_cpp2_library(
streamingeden_thrift
streamingeden.thrift
SERVICES
StreamingEdenService
DEPENDS
eden_service_thrift
)
file(GLOB SERVICE_SRCS "*.cpp")
add_library(
eden_service STATIC
${SERVICE_SRCS}
oss/RunServer.cpp
)
target_link_libraries(
eden_service
PUBLIC
eden_service_thrift
streamingeden_thrift
eden_config
eden_fuse
eden_inodes
eden_model
eden_model_git
eden_store_hg
eden_store_git
eden_takeover
Folly::folly
)

View File

@ -0,0 +1,16 @@
file(GLOB SQLITE_SRCS "*.cpp")
add_library(
eden_sqlite STATIC
${SQLITE_SRCS}
)
target_include_directories(
eden_sqlite
PUBLIC
${SQLITE3_INCLUDE_DIR}
)
target_link_libraries(
eden_sqlite
PUBLIC
Folly::folly
${SQLITE3_LIBRARY}
)

View File

@ -0,0 +1,17 @@
file(GLOB STORE_SRCS "*.cpp")
add_library(
eden_store STATIC
${STORE_SRCS}
)
target_link_libraries(
eden_store
PUBLIC
eden_model
eden_model_git
eden_rocksdb
eden_service_thrift
eden_sqlite
)
add_subdirectory(hg)
add_subdirectory(git)

View File

@ -0,0 +1,11 @@
file(GLOB STORE_GIT_SRCS "*.cpp")
add_library(
eden_store_git STATIC
${STORE_GIT_SRCS}
)
target_link_libraries(
eden_store_git
PUBLIC
eden_model
${LIBGIT2_LIBRARY}
)

View File

@ -0,0 +1,22 @@
file(GLOB STORE_HG_SRCS "*.cpp")
list(REMOVE_ITEM STORE_HG_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tester.cpp)
add_library(
eden_store_hg STATIC
${STORE_HG_SRCS}
)
target_link_libraries(
eden_store_hg
PUBLIC
eden_model
eden_store
eden_utils
)
add_executable(
hg_store_tester
tester.cpp
)
target_link_libraries(
hg_store_tester
eden_store_hg
)

View File

@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include "HgImporter.h"
#include "eden/fs/store/hg/HgImporter.h"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
@ -24,17 +24,19 @@
#include <unistd.h>
#include <mutex>
#include "HgManifestImporter.h"
#include "eden/fs/model/Tree.h"
#include "eden/fs/model/TreeEntry.h"
#include "eden/fs/store/LocalStore.h"
#include "eden/fs/store/StoreResult.h"
#include "eden/fs/store/hg/HgImportPyError.h"
#include "eden/fs/store/hg/HgManifestImporter.h"
#include "eden/fs/utils/PathFuncs.h"
#include "eden/fs/utils/TimeUtil.h"
#if EDEN_HAVE_HG_TREEMANIFEST
#include "hgext/extlib/cstore/uniondatapackstore.h" // @manual=//scm/hg:datapack
#include "hgext/extlib/ctreemanifest/treemanifest.h" // @manual=//scm/hg:datapack
#endif // EDEN_HAVE_HG_TREEMANIFEST
using folly::ByteRange;
using folly::Endian;
@ -452,6 +454,7 @@ HgImporter::Options HgImporter::waitForHelperStart() {
}
void HgImporter::initializeTreeManifestImport(const Options& options) {
#if EDEN_HAVE_HG_TREEMANIFEST
if (!FLAGS_use_hg_tree_manifest) {
XLOG(DBG2) << "treemanifest import disabled via command line flags "
"for repository "
@ -477,6 +480,7 @@ void HgImporter::initializeTreeManifestImport(const Options& options) {
unionStore_ = std::make_unique<UnionDatapackStore>(storePtrs);
XLOG(DBG2) << "treemanifest import enabled in repository " << repoPath_;
#endif // EDEN_HAVE_HG_TREEMANIFEST
}
HgImporter::~HgImporter() {
@ -485,6 +489,7 @@ HgImporter::~HgImporter() {
}
std::unique_ptr<Tree> HgImporter::importTree(const Hash& id) {
#if EDEN_HAVE_HG_TREEMANIFEST
// importTree() only works with treemanifest.
// This can only be called if the root tree was imported with treemanifest,
// and we are now trying to import data for some subdirectory.
@ -509,8 +514,15 @@ std::unique_ptr<Tree> HgImporter::importTree(const Hash& id) {
writeBatch.get());
writeBatch->flush();
return tree;
#else // !EDEN_HAVE_HG_TREEMANIFEST
throw std::domain_error(folly::to<string>(
"requested to import subtree ",
id.toString(),
" but flatmanifest import should have already imported all subtrees"));
#endif // EDEN_HAVE_HG_TREEMANIFEST
}
#if EDEN_HAVE_HG_TREEMANIFEST
std::unique_ptr<Tree> HgImporter::importTreeImpl(
const Hash& manifestNode,
const Hash& edenTreeID,
@ -679,24 +691,6 @@ std::unique_ptr<Tree> HgImporter::importTreeImpl(
return tree;
}
Hash HgImporter::importManifest(StringPiece revName) {
if (unionStore_) {
try {
return importTreeManifest(revName);
} catch (const MissingKeyError&) {
if (!FLAGS_allow_flatmanifest_fallback) {
throw;
}
// We don't have a tree manifest available for the target rev,
// so let's fall through to the full flat manifest importer.
XLOG(INFO) << "no treemanifest data available for revision " << revName
<< ": falling back to slower flatmanifest import";
}
}
return importFlatManifest(revName);
}
Hash HgImporter::importTreeManifest(StringPiece revName) {
auto manifestNode = resolveManifestNode(revName);
XLOG(DBG2) << "revision " << revName << " has manifest node " << manifestNode;
@ -714,6 +708,27 @@ Hash HgImporter::importTreeManifest(StringPiece revName) {
return tree->getHash();
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
Hash HgImporter::importManifest(StringPiece revName) {
#if EDEN_HAVE_HG_TREEMANIFEST
if (unionStore_) {
try {
return importTreeManifest(revName);
} catch (const MissingKeyError&) {
if (!FLAGS_allow_flatmanifest_fallback) {
throw;
}
// We don't have a tree manifest available for the target rev,
// so let's fall through to the full flat manifest importer.
XLOG(INFO) << "no treemanifest data available for revision " << revName
<< ": falling back to slower flatmanifest import";
}
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
return importFlatManifest(revName);
}
Hash HgImporter::importFlatManifest(StringPiece revName) {
// Send the manifest request to the helper process

View File

@ -12,6 +12,7 @@
#include <folly/Range.h>
#include <folly/Subprocess.h>
#include "eden/fs/eden-config.h"
#include "eden/fs/store/LocalStore.h"
#include "eden/fs/utils/PathFuncs.h"
@ -22,9 +23,11 @@ class Cursor;
}
} // namespace folly
#if EDEN_HAVE_HG_TREEMANIFEST
/* forward declare support classes from mercurial */
class DatapackStore;
class UnionDatapackStore;
#endif // EDEN_HAVE_HG_TREEMANIFEST
namespace facebook {
namespace eden {
@ -66,6 +69,7 @@ class HgImporter {
*/
Hash importManifest(folly::StringPiece revName);
#if EDEN_HAVE_HG_TREEMANIFEST
/**
* Import the manifest for the specified revision using mercurial
* treemanifest data.
@ -75,6 +79,7 @@ class HgImporter {
* This method is exposed publicly primarily for testing purposes.
*/
Hash importTreeManifest(folly::StringPiece revName);
#endif // EDEN_HAVE_HG_TREEMANIFEST
/**
* Import the manifest for the specified revision using mercurial
@ -262,11 +267,13 @@ class HgImporter {
*/
void sendFetchTreeRequest(RelativePathPiece path, Hash pathManifestNode);
#if EDEN_HAVE_HG_TREEMANIFEST
std::unique_ptr<Tree> importTreeImpl(
const Hash& manifestNode,
const Hash& edenTreeID,
RelativePathPiece path,
LocalStore::WriteBatch* writeBatch);
#endif
folly::Subprocess helper_;
const AbsolutePath repoPath_;
@ -283,8 +290,10 @@ class HgImporter {
int helperIn_{-1};
int helperOut_{-1};
#if EDEN_HAVE_HG_TREEMANIFEST
std::vector<std::unique_ptr<DatapackStore>> dataPackStores_;
std::unique_ptr<UnionDatapackStore> unionStore_;
#endif // EDEN_HAVE_HG_TREEMANIFEST
};
} // namespace eden
} // namespace facebook

View File

@ -123,6 +123,7 @@ void importTreeRecursive(
}
}
#if EDEN_HAVE_HG_TREEMANIFEST
int importTree(
LocalStore* store,
AbsolutePathPiece repoPath,
@ -159,6 +160,7 @@ int importTree(
return EX_OK;
}
#endif // EDEN_HAVE_HG_TREEMANIFEST
} // namespace
int main(int argc, char* argv[]) {
@ -205,8 +207,14 @@ int main(int argc, char* argv[]) {
auto rootHash = importer.importFlatManifest(revName);
printf("Imported root tree: %s\n", rootHash.toString().c_str());
} else if (FLAGS_import_type == "tree") {
#if EDEN_HAVE_HG_TREEMANIFEST
RelativePath path{FLAGS_subdir};
returnCode = importTree(&store, repoPath, revName, path);
#else // !EDEN_HAVE_HG_TREEMANIFEST
fprintf(
stderr, "error: treemanifest import is not supported by this build\n");
return EX_UNAVAILABLE;
#endif // EDEN_HAVE_HG_TREEMANIFEST
} else {
fprintf(
stderr,

View File

@ -0,0 +1,19 @@
add_thrift_cpp2_library(
eden_takeover_thrift
takeover.thrift
DEPENDS
eden_fuse_handlemap
)
file(GLOB TAKEOVER_SRCS "*.cpp")
add_library(
eden_takeover STATIC
${TAKEOVER_SRCS}
)
target_link_libraries(
eden_takeover
PUBLIC
eden_fuse
eden_utils
eden_takeover_thrift
)

View File

@ -0,0 +1,10 @@
file(GLOB UTILS_SRCS "*.cpp")
add_library(
eden_utils STATIC
${UTILS_SRCS}
)
target_link_libraries(
eden_utils
PUBLIC
Folly::folly
)