Skip to content

Commit

Permalink
Conan v2 support. (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd authored Jul 25, 2024
1 parent 4ef0843 commit 30d63bd
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ cmake-*/**

# Visual Studio
CMakeSettings.json
CMakeUserPresets.json
.vs/**
.cache
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ include (cmake/Flags.cmake)
set(CMAKE_CXX_STANDARD 20)
enable_testing()

if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
else ()
message(WARNING "Conan Build file does not exist, trying to build without!")
endif ()
include (cmake/test_mode.cmake)

if (DEFINED CONAN_BUILD_COVERAGE)
if (${CONAN_BUILD_COVERAGE})
Expand Down
18 changes: 18 additions & 0 deletions cmake/test_mode.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.11)

if (${BUILD_TESTING})
if (DEFINED TEST_TARGET)
macro(can_build_io_tests ret)
set(${ret} false)
Expand Down Expand Up @@ -40,3 +41,20 @@ if (DEFINED TEST_TARGET)
endif()
endmacro()
endif ()
else()
macro(can_build_io_tests ret)
set(${ret} false)
endmacro()
macro(can_build_nonio_tests ret)
set(${ret} false)
endmacro()
macro(is_non_coverage_build ret)
set(${ret} false)
endmacro()
macro(can_build_spdk_io_tests ret)
set(${ret} false)
endmacro()
macro(can_build_epoll_io_tests ret)
set(${ret} false)
endmacro()
endif()
96 changes: 56 additions & 40 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from os.path import join
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.files import copy
from conans import CMake
from os.path import join

required_conan_version = ">=1.60.0"

class HomestoreConan(ConanFile):
name = "homestore"
version = "6.4.27"
version = "6.4.28"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
topics = ("ebay", "nublox")
Expand All @@ -20,67 +25,75 @@ class HomestoreConan(ConanFile):
"coverage": ['True', 'False'],
"sanitize": ['True', 'False'],
"testing" : ['full', 'min', 'off', 'epoll_mode', 'spdk_mode'],
"skip_testing": ['True', 'False'],
}
default_options = {
'shared': False,
'fPIC': True,
'coverage': False,
'sanitize': False,
'testing': 'epoll_mode',
'skip_testing': False,
'shared': False,
'fPIC': True,
'coverage': False,
'sanitize': False,
'testing': 'epoll_mode',
}

generators = "cmake", "cmake_find_package"
exports_sources = "cmake/*", "src/*", "CMakeLists.txt", "test_wrap.sh", "LICENSE"
keep_imports = True

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")
if self.settings.build_type == "Debug":
if self.options.coverage and self.options.sanitize:
raise ConanInvalidConfiguration("Sanitizer does not work with Code Coverage!")
if self.options.testing == 'off':
if self.conf.get("tools.build:skip_test", default=False):
if self.options.coverage or self.options.sanitize:
raise ConanInvalidConfiguration("Coverage/Sanitizer requires Testing!")

def imports(self):
self.copy(root_package="sisl", pattern="*", dst="bin/scripts/python/flip/", src="bindings/flip/python/", keep_path=False)

def build_requirements(self):
self.build_requires("benchmark/1.8.2")
self.build_requires("gtest/1.14.0")
self.test_requires("benchmark/1.8.2")
self.test_requires("gtest/1.14.0")

def requirements(self):
self.requires("iomgr/[~11.3, include_prerelease=True]@oss/master")
self.requires("sisl/[~12.2, include_prerelease=True]@oss/master")
self.requires("nuraft_mesg/[^3.4, include_prerelease=True]@oss/main")
self.requires("iomgr/[~11.3, include_prerelease=True]@oss/master", transitive_headers=True)
self.requires("sisl/[~12.2, include_prerelease=True]@oss/master", transitive_headers=True)
self.requires("nuraft_mesg/[^3.4, include_prerelease=True]@oss/main", transitive_headers=True)

self.requires("farmhash/cci.20190513@")
self.requires("farmhash/cci.20190513@", transitive_headers=True)
if self.settings.arch in ['x86', 'x86_64']:
self.requires("isa-l/2.30.0")
self.requires("spdk/nbi.21.07.y")
self.requires("isa-l/2.30.0", transitive_headers=True)

def imports(self):
self.copy(root_package="sisl", pattern="*", dst="bin/scripts/python/flip/", src="bindings/flip/python/", keep_path=False)

def layout(self):
cmake_layout(self)

def generate(self):
# This generates "conan_toolchain.cmake" in self.generators_folder
tc = CMakeToolchain(self)
if not self.conf.get("tools.build:skip_test", default=False):
tc.variables["BUILD_TESTING"] = "ON"
tc.variables["CONAN_CMAKE_SILENT_OUTPUT"] = "ON"
tc.variables['CMAKE_EXPORT_COMPILE_COMMANDS'] = 'ON'
tc.variables["CTEST_OUTPUT_ON_FAILURE"] = "ON"
tc.variables["MEMORY_SANITIZER_ON"] = "OFF"
tc.variables["BUILD_COVERAGE"] = "OFF"
tc.variables["TEST_TARGET"] = self.options.testing
if self.settings.build_type == "Debug":
if self.options.get_safe("coverage"):
tc.variables['BUILD_COVERAGE'] = 'ON'
elif self.options.get_safe("sanitize"):
tc.variables['MEMORY_SANITIZER_ON'] = 'ON'
tc.generate()

# This generates "boost-config.cmake" and "grpc-config.cmake" etc in self.generators_folder
deps = CMakeDeps(self)
deps.generate()

def build(self):
cmake = CMake(self)

definitions = {'TEST_TARGET': 'off',
'CONAN_CMAKE_SILENT_OUTPUT': 'ON',
'CMAKE_EXPORT_COMPILE_COMMANDS': 'ON',
'MEMORY_SANITIZER_ON': 'OFF'}
test_target = None

definitions['TEST_TARGET'] = self.options.testing
if self.settings.build_type == 'Debug':
if self.options.sanitize:
definitions['MEMORY_SANITIZER_ON'] = 'ON'
elif self.options.coverage:
definitions['CONAN_BUILD_COVERAGE'] = 'ON'
cmake.configure(defs=definitions)
cmake.configure()
cmake.build()
if not self.options.testing == 'off' and not self.options.skip_testing:
cmake.test(target=test_target, output_on_failure=True)
if not self.conf.get("tools.build:skip_test", default=False):
cmake.test()

def package(self):
copy(self, "LICENSE", self.source_folder, join(self.package_folder, "licenses"), keep_path=False)
Expand All @@ -94,6 +107,9 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["homestore"]
if not self.settings.arch in ['x86', 'x86_64']:
self.cpp_info.defines.append("NO_ISAL")

if self.options.sanitize:
self.cpp_info.sharedlinkflags.append("-fsanitize=address")
self.cpp_info.exelinkflags.append("-fsanitize=address")
Expand Down
4 changes: 1 addition & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ find_package(NuraftMesg QUIET REQUIRED)
list(APPEND COMMON_DEPS
iomgr::iomgr
farmhash::farmhash
-Wl,--whole-archive
NuraftMesg::proto
-Wl,--no-whole-archive
nuraft_mesg::proto
nuraft::nuraft
sisl::sisl
)
Expand Down
2 changes: 0 additions & 2 deletions src/lib/blkdata_svc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include (${CMAKE_SOURCE_DIR}/cmake/test_mode.cmake)

include_directories (BEFORE ..)
include_directories (BEFORE .)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ target_sources(hs_common PRIVATE
)
target_link_libraries(hs_common ${COMMON_DEPS})

set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_LIB_DIRS}/../bin/flatc)
set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_INCLUDE_DIR}/../bin/flatc)
settings_gen_cpp(${FLATBUFFERS_FLATC_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/generated/ hs_common homestore_config.fbs)
2 changes: 0 additions & 2 deletions src/lib/device/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include (${CMAKE_SOURCE_DIR}/cmake/test_mode.cmake)

include_directories (BEFORE ..)
include_directories (BEFORE .)

Expand Down
3 changes: 1 addition & 2 deletions src/lib/logstore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.13)

include(${CMAKE_SOURCE_DIR}/cmake/test_mode.cmake)
include_directories (BEFORE ..)
include_directories (BEFORE .)

Expand All @@ -12,4 +11,4 @@ target_sources(hs_logdev PRIVATE
log_store.cpp
log_store_service.cpp
)
target_link_libraries(hs_logdev ${COMMON_DEPS})
target_link_libraries(hs_logdev ${COMMON_DEPS})
4 changes: 1 addition & 3 deletions src/lib/replication/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include (${CMAKE_SOURCE_DIR}/cmake/test_mode.cmake)

include_directories (BEFORE ..)
include_directories (BEFORE .)

Expand All @@ -24,6 +22,6 @@ target_sources(hs_replication PRIVATE
)
target_link_libraries(hs_replication PRIVATE ${COMMON_DEPS} hs_common hs_replication_fb)

#set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_LIB_DIRS}/../bin/flatc)
#set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_INCLUDE_DIR}/../bin/flatc)
#flatbuffer_gen_cpp(${FLATBUFFERS_FLATC_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/generated/ hs_replication rpc/push_data_rpc.fbs rpc/fetch_data_rpc.fbs)

27 changes: 13 additions & 14 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.13)

include (${CMAKE_SOURCE_DIR}/cmake/test_mode.cmake)
include_directories (BEFORE ../include/)
include_directories (BEFORE ../lib/)
include_directories (BEFORE ../tests/)
Expand All @@ -16,7 +15,7 @@ if (${build_nonio_tests})
add_executable(test_blkalloc)
target_sources(test_blkalloc PRIVATE test_blkalloc.cpp $<TARGET_OBJECTS:hs_blkalloc>)
target_link_libraries(test_blkalloc homestore ${COMMON_TEST_DEPS} )
add_test(NAME BlkAlloc COMMAND ${CMAKE_BINARY_DIR}/bin/test_blkalloc)
add_test(NAME BlkAlloc COMMAND test_blkalloc)

add_executable(test_blk_cache_queue)
target_sources(test_blk_cache_queue PRIVATE test_blk_cache_queue.cpp ../lib/blkalloc/blk_cache_queue.cpp)
Expand All @@ -26,7 +25,7 @@ if (${build_nonio_tests})
set(TEST_JOURNAL_VDEV_SOURCES test_journal_vdev.cpp)
add_executable(test_journal_vdev ${TEST_JOURNAL_VDEV_SOURCES})
target_link_libraries(test_journal_vdev homestore ${COMMON_TEST_DEPS} GTest::gmock)
add_test(NAME JournalVDev COMMAND ${CMAKE_BINARY_DIR}/bin/test_journal_vdev)
add_test(NAME JournalVDev COMMAND test_journal_vdev)

set(TEST_BTREENODE_SOURCE_FILES test_btree_node.cpp)
add_executable(test_btree_node ${TEST_BTREENODE_SOURCE_FILES})
Expand Down Expand Up @@ -122,10 +121,10 @@ if (${io_tests})

can_build_epoll_io_tests(epoll_tests)
if(${epoll_tests})
add_test(NAME LogDev-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_log_dev)
add_test(NAME LogStore-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_log_store)
add_test(NAME MetaBlkMgr-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_meta_blk_mgr)
add_test(NAME DataService-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_data_service)
add_test(NAME LogDev-Epoll COMMAND test_log_dev)
add_test(NAME LogStore-Epoll COMMAND test_log_store)
add_test(NAME MetaBlkMgr-Epoll COMMAND test_meta_blk_mgr)
add_test(NAME DataService-Epoll COMMAND test_data_service)

# add_test(NAME SoloReplDev-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_solo_repl_dev)
# add_test(NAME HomeRaftLogStore-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_home_raft_logstore)
Expand All @@ -134,13 +133,13 @@ if (${io_tests})

can_build_spdk_io_tests(spdk_tests)
if(${spdk_tests})
add_test(NAME LogStore-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_log_store -- --spdk "true")
add_test(NAME LogDev-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_log_dev -- --spdk "true")
add_test(NAME MetaBlkMgr-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_meta_blk_mgr -- --spdk "true")
add_test(NAME DataSerice-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_data_service -- --spdk "true")
add_test(NAME SoloReplDev-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_solo_repl_dev -- --spdk "true")
add_test(NAME HomeRaftLogStore-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_home_raft_logstore -- --spdk "true")
add_test(NAME RaftReplDev-Spdk COMMAND ${CMAKE_BINARY_DIR}/bin/test_raft_repl_dev -- --spdk "true")
add_test(NAME LogStore-Spdk COMMAND test_log_store -- --spdk "true")
add_test(NAME LogDev-Spdk COMMAND test_log_dev -- --spdk "true")
add_test(NAME MetaBlkMgr-Spdk COMMAND test_meta_blk_mgr -- --spdk "true")
add_test(NAME DataSerice-Spdk COMMAND test_data_service -- --spdk "true")
add_test(NAME SoloReplDev-Spdk COMMAND test_solo_repl_dev -- --spdk "true")
add_test(NAME HomeRaftLogStore-Spdk COMMAND test_home_raft_logstore -- --spdk "true")
add_test(NAME RaftReplDev-Spdk COMMAND test_raft_repl_dev -- --spdk "true")
if(${epoll_tests})
SET_TESTS_PROPERTIES(MetaBlkMgr-Spdk PROPERTIES DEPENDS LogStore-Spdk)
SET_TESTS_PROPERTIES(DataService-Spdk PROPERTIES DEPENDS MetaBlkMgr-Spdk)
Expand Down

0 comments on commit 30d63bd

Please sign in to comment.