mirror of
https://github.com/facebook/sapling.git
synced 2024-12-26 06:21:48 +03:00
make support for Eden SCM optional
Summary: Add a CMake option to control whether or not we should build support for fb-mercurial (aka Eden SCM). If this is disabled we avoid building anything under eden/fs/store/hg and drop support for the "hg" backing store. Reviewed By: wez Differential Revision: D15980320 fbshipit-source-id: 23a49d3e5cf89199666ff4a0bf46626502c12171
This commit is contained in:
parent
19f2d16c33
commit
7ee2610c78
@ -62,6 +62,23 @@ else()
|
||||
set(EDEN_HAVE_GIT OFF)
|
||||
endif()
|
||||
|
||||
if("${ENABLE_EDENSCM}" STREQUAL "AUTO")
|
||||
find_package(EdenSCM MODULE)
|
||||
set(EDEN_HAVE_EDENSCM "${EdenSCM_FOUND}")
|
||||
if(NOT EDEN_HAVE_EDENSCM)
|
||||
message(STATUS "Building with EdenSCM support disabled")
|
||||
endif()
|
||||
elseif(ENABLE_EDENSCM)
|
||||
find_package(EdenSCM MODULE REQUIRED)
|
||||
set(EDEN_HAVE_EDENSCM "${EdenSCM_FOUND}")
|
||||
else()
|
||||
set(EDEN_HAVE_EDENSCM OFF)
|
||||
endif()
|
||||
|
||||
if("${EDEN_HAVE_EDENSCM}")
|
||||
include(FBMercurialFeatures)
|
||||
endif()
|
||||
|
||||
# The following packages ship with their own CMake configuration files
|
||||
find_package(cpptoml CONFIG REQUIRED)
|
||||
find_package(gflags CONFIG REQUIRED)
|
||||
|
@ -3,70 +3,64 @@
|
||||
# This software may be used and distributed according to the terms of the
|
||||
# GNU General Public License version 2.
|
||||
|
||||
# Allow symlinking the fb-mercurial dir in directly
|
||||
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fb-mercurial)
|
||||
set(FB_MERCURIAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fb-mercurial")
|
||||
else()
|
||||
# Otherwise, look for where getdeps has "installed" the source
|
||||
find_file(EDENSCM_DATAPACKSTORE_CPP "edenscm/hgext/extlib/cstore/datapackstore.cpp")
|
||||
if (EDENSCM_DATAPACKSTORE_CPP)
|
||||
get_filename_component(CSTORE_DIR "${EDENSCM_DATAPACKSTORE_CPP}" DIRECTORY)
|
||||
get_filename_component(FB_MERCURIAL_DIR "${CSTORE_DIR}/../../../../" REALPATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO: once we've gotten the rust datapack code integrated and
|
||||
# building, update getdeps.py to optionally pull from the fb-mercurial
|
||||
# repo on github and adjust this logic to use either the code from
|
||||
# the local fbsource repo when building at FB, or from the
|
||||
# external dir when building the OSS build.
|
||||
if (IS_DIRECTORY "${FB_MERCURIAL_DIR}")
|
||||
find_package(LZ4 MODULE REQUIRED)
|
||||
include_directories(${FB_MERCURIAL_DIR})
|
||||
add_library(
|
||||
find_package(LZ4 MODULE REQUIRED)
|
||||
add_library(
|
||||
libmpatch
|
||||
STATIC
|
||||
${EDENSCM_DIR}/edenscm/mercurial/mpatch.c
|
||||
)
|
||||
target_include_directories(
|
||||
libmpatch
|
||||
PUBLIC
|
||||
${EDENSCM_DIR}
|
||||
)
|
||||
|
||||
add_library(
|
||||
buffer
|
||||
STATIC
|
||||
${EDENSCM_DIR}/lib/clib/buffer.c
|
||||
)
|
||||
target_include_directories(
|
||||
buffer
|
||||
PUBLIC
|
||||
${EDENSCM_DIR}
|
||||
)
|
||||
|
||||
add_library(
|
||||
datapack
|
||||
STATIC
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/cstore/datapackstore.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/cstore/deltachain.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/cstore/uniondatapackstore.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest_entry.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest_fetcher.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest_ptr.cpp
|
||||
${EDENSCM_DIR}/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp
|
||||
${EDENSCM_DIR}/lib/cdatapack/cdatapack.c
|
||||
)
|
||||
target_link_libraries(
|
||||
datapack
|
||||
PUBLIC
|
||||
libmpatch
|
||||
STATIC
|
||||
${FB_MERCURIAL_DIR}/edenscm/mercurial/mpatch.c
|
||||
)
|
||||
|
||||
add_library(
|
||||
buffer
|
||||
STATIC
|
||||
${FB_MERCURIAL_DIR}/lib/clib/buffer.c
|
||||
)
|
||||
|
||||
add_library(
|
||||
datapack
|
||||
STATIC
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/cstore/datapackstore.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/cstore/deltachain.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/cstore/uniondatapackstore.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest_entry.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest_fetcher.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/ctreemanifest/manifest_ptr.cpp
|
||||
${FB_MERCURIAL_DIR}/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp
|
||||
${FB_MERCURIAL_DIR}/lib/cdatapack/cdatapack.c
|
||||
)
|
||||
target_link_libraries(
|
||||
datapack
|
||||
PUBLIC
|
||||
libmpatch
|
||||
buffer
|
||||
${OPENSSL_LIBRARIES}
|
||||
${LZ4_LIBRARY}
|
||||
)
|
||||
target_include_directories(
|
||||
datapack
|
||||
PUBLIC
|
||||
${OPENSSL_LIBRARIES}
|
||||
${LZ4_LIBRARY}
|
||||
)
|
||||
target_include_directories(
|
||||
datapack
|
||||
PUBLIC
|
||||
${EDENSCM_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${LZ4_INCLUDE_DIR}
|
||||
)
|
||||
if (WIN32)
|
||||
)
|
||||
if (WIN32)
|
||||
# We need to define EDEN_WIN to include the correct definition of mman.h,
|
||||
# which is different for Mercurial Windows and Eden Windows.
|
||||
target_compile_definitions(datapack PUBLIC -DEDEN_WIN)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "fb-mercurial treemanifest support not found")
|
||||
target_compile_definitions(datapack PUBLIC -DEDEN_WIN)
|
||||
endif()
|
||||
|
30
CMake/FindEdenSCM.cmake
Normal file
30
CMake/FindEdenSCM.cmake
Normal file
@ -0,0 +1,30 @@
|
||||
# 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.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# Allow symlinking the fb-mercurial dir in directly
|
||||
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/fb-mercurial)
|
||||
set(EDENSCM_DIR "${CMAKE_SOURCE_DIR}/fb-mercurial")
|
||||
else()
|
||||
# Otherwise, look for where getdeps has "installed" the source
|
||||
find_file(
|
||||
EDENSCM_DATAPACKSTORE_CPP
|
||||
"edenscm/hgext/extlib/cstore/datapackstore.cpp"
|
||||
)
|
||||
if (EDENSCM_DATAPACKSTORE_CPP)
|
||||
get_filename_component(CSTORE_DIR "${EDENSCM_DATAPACKSTORE_CPP}" DIRECTORY)
|
||||
get_filename_component(EDENSCM_DIR "${CSTORE_DIR}/../../../../" REALPATH)
|
||||
endif()
|
||||
if (NOT IS_DIRECTORY "${EDENSCM_DIR}")
|
||||
set(EDENSCM_DIR "EDENSCM_DIR-NOTFOUND")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(
|
||||
EdenSCM
|
||||
REQUIRED_VARS EDENSCM_DIR
|
||||
FAIL_MESSAGE "Unable to find EdenSCM fb-mercurial directory"
|
||||
)
|
@ -10,6 +10,7 @@
|
||||
#define EDEN_ETC_EDEN_DIR "${ETC_EDEN_DIR}"
|
||||
|
||||
#cmakedefine EDEN_HAVE_CURL
|
||||
#cmakedefine EDEN_HAVE_EDENSCM
|
||||
#cmakedefine EDEN_HAVE_GIT
|
||||
#cmakedefine EDEN_HAVE_ROCKSDB
|
||||
#cmakedefine EDEN_HAVE_SELINUX
|
||||
|
@ -46,6 +46,8 @@ endif()
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Configuration options
|
||||
set(ENABLE_EDENSCM AUTO CACHE STRING "Enable support for Eden SCM repositories")
|
||||
set_property(CACHE ENABLE_EDENSCM PROPERTY STRINGS AUTO ON OFF)
|
||||
set(ENABLE_GIT AUTO CACHE STRING "Enable support for Git repositories")
|
||||
set_property(CACHE ENABLE_GIT PROPERTY STRINGS AUTO ON OFF)
|
||||
|
||||
@ -53,7 +55,6 @@ if (NOT WIN32)
|
||||
include(CompilerSettingsUnix)
|
||||
endif()
|
||||
include(EdenConfigChecks)
|
||||
include(FBMercurialFeatures)
|
||||
include(FBPythonBinary)
|
||||
include(FBThriftLibrary)
|
||||
|
||||
|
@ -57,7 +57,9 @@ if (WIN32)
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND EDEN_STORE_IMPLEMENTATIONS eden_store_hg)
|
||||
if(EDEN_HAVE_EDENSCM)
|
||||
list(APPEND EDEN_STORE_IMPLEMENTATIONS eden_store_hg)
|
||||
endif()
|
||||
if(EDEN_HAVE_GIT)
|
||||
list(APPEND EDEN_STORE_IMPLEMENTATIONS eden_store_git)
|
||||
endif()
|
||||
|
@ -58,10 +58,12 @@
|
||||
#include "eden/fs/store/MemoryLocalStore.h"
|
||||
#include "eden/fs/store/ObjectStore.h"
|
||||
#include "eden/fs/store/SqliteLocalStore.h"
|
||||
#include "eden/fs/store/hg/HgBackingStore.h"
|
||||
#include "eden/fs/utils/Clock.h"
|
||||
#include "eden/fs/utils/ProcUtil.h"
|
||||
|
||||
#ifdef EDEN_HAVE_EDENSCM
|
||||
#include "eden/fs/store/hg/HgBackingStore.h"
|
||||
#endif // EDEN_HAVE_EDENSCM
|
||||
#ifdef EDEN_HAVE_GIT
|
||||
#include "eden/fs/store/git/GitBackingStore.h" // @manual
|
||||
#endif
|
||||
@ -1161,6 +1163,7 @@ shared_ptr<BackingStore> EdenServer::createBackingStore(
|
||||
if (type == "null") {
|
||||
return make_shared<EmptyBackingStore>();
|
||||
} else if (type == "hg") {
|
||||
#ifdef EDEN_HAVE_EDENSCM
|
||||
const auto repoPath = realpath(name);
|
||||
return make_shared<HgBackingStore>(
|
||||
repoPath,
|
||||
@ -1169,6 +1172,10 @@ shared_ptr<BackingStore> EdenServer::createBackingStore(
|
||||
shared_ptr<ReloadableConfig>(
|
||||
serverState_, &serverState_->getReloadableConfig()),
|
||||
getSharedStats());
|
||||
#else // EDEN_HAVE_EDENSCM
|
||||
throw std::domain_error(
|
||||
"support for Eden SCM was not enabled in this EdenFS build");
|
||||
#endif // EDEN_HAVE_EDENSCM
|
||||
} else if (type == "git") {
|
||||
#ifdef EDEN_HAVE_GIT
|
||||
const auto repoPath = realpath(name);
|
||||
|
@ -40,7 +40,9 @@ if (NOT WIN32)
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectory(hg)
|
||||
if("${EDEN_HAVE_EDENSCM}")
|
||||
add_subdirectory(hg)
|
||||
endif()
|
||||
if("${EDEN_HAVE_GIT}")
|
||||
add_subdirectory(git)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user