diff --git a/.gitmodules b/.gitmodules index f8ea5ed07..2d96d0d8e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,3 @@ [submodule "tools/yscope-dev-utils"] path = tools/yscope-dev-utils url = https://github.com/y-scope/yscope-dev-utils.git -[submodule "submodules/Catch2"] - path = submodules/Catch2 - url = https://github.com/catchorg/Catch2.git -[submodule "submodules/abseil-cpp"] - path = submodules/abseil-cpp - url = https://github.com/abseil/abseil-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d69104d8..e5063c164 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,11 @@ else() endif() message(STATUS "Building using ${SPIDER_LIBS_STRING} libraries") +if(PROJECT_IS_TOP_LEVEL) + # Include dependency settings if the project isn't being included as a subproject. + include("build/deps/cmake-settings/all.cmake") +endif() + # Find and setup Boost Library if(SPIDER_USE_STATIC_LIBS) set(Boost_USE_STATIC_LIBS ON) @@ -156,12 +161,35 @@ else() message(FATAL_ERROR "Could not find msgpack-cxx") endif() -# Add abseil-cpp +find_package(outcome REQUIRED) +if(outcome_FOUND) + message(STATUS "Found outcome.") +else() + message(FATAL_ERROR "Could not find libraries for outcome.") +endif() + +find_package(Catch2 3.8.0 REQUIRED) +if(Catch2_FOUND) + message(STATUS "Found Catch2 ${Catch2_VERSION}.") +else() + message(FATAL_ERROR "Could not find libraries for Catch2.") +endif() + +# Add abseil set(ABSL_PROPAGATE_CXX_STD ON) -add_subdirectory(submodules/abseil-cpp) +find_package(absl REQUIRED) +if(absl_FOUND) + message(STATUS "Found abseil ${absl_VERSION}.") +else() + message(FATAL_ERROR "Could not find libraries for abseil.") +endif() -# Add catch2 -add_subdirectory(submodules/Catch2) +# Add ystdlib-cpp +add_subdirectory( + "${SPIDER_YSTDLIB_SOURCE_DIRECTORY}" + "${CMAKE_BINARY_DIR}/ystdlib" + EXCLUDE_FROM_ALL +) find_package(Threads REQUIRED) diff --git a/README.md b/README.md index 98e294315..66fc1a65d 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Follow the steps below to develop and contribute to the project. * [Task] 3.40.0 or higher ## Set up -Initialize and update submodules: +Run dependency installation task: ```shell -git submodule update --init --recursive +task deps:dep_install ``` Set up the config files for our C++ linting tools: diff --git a/dep-tasks.yaml b/dep-tasks.yaml index a5cb8e17c..a2c7dbb84 100644 --- a/dep-tasks.yaml +++ b/dep-tasks.yaml @@ -14,6 +14,7 @@ tasks: dir: "{{.G_SCRIPT_DIR}}/lib_install/macOS" cmds: - "./install-lib.sh" + - task: "dep_install" lib_install_linux: internal: true @@ -21,3 +22,99 @@ tasks: dir: "{{.G_SCRIPT_DIR}}/lib_install/linux" cmds: - "./install-lib.sh" + - task: "dep_install" + + dep_install: + cmds: + - task: ":utils:cmake:install-deps-and-generate-settings" + vars: + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + DEP_TASK: "deps:install-all-run" + + install-all-run: + internal: true + deps: + - task: "install-abseil" + - task: "install-Catch2" + - task: "install-outcome" + - task: "download-ystdlib" + + install-abseil: + internal: true + run: "once" + cmds: + - task: ":utils:cmake:install-remote-tar" + vars: + NAME: "absl" + WORK_DIR: "{{.G_DEPS_DIR}}/absl" + FILE_SHA256: "b396401fd29e2e679cace77867481d388c807671dc2acc602a0259eeb79b7811" + URL: "https://github.com/abseil/abseil-cpp/archive/refs/tags/20250127.1.tar.gz" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + GEN_ARGS: + - "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + + install-Catch2: + internal: true + run: "once" + cmds: + - task: ":utils:cmake:install-remote-tar" + vars: + NAME: "Catch2" + WORK_DIR: "{{.G_DEPS_DIR}}/Catch2" + FILE_SHA256: "1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087" + URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + GEN_ARGS: + - "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + + install-outcome: + internal: true + run: "once" + deps: + - "install-quickcpplib" + cmds: + - task: ":utils:cmake:install-remote-tar" + vars: + NAME: "outcome" + WORK_DIR: "{{.G_DEPS_DIR}}/outcome" + FILE_SHA256: "0382248cbb00806ce4b5f3ce6939797dc3b597c85fd3531614959e31ef488b39" + URL: "https://github.com/ned14/outcome/archive/refs/tags/v2.2.11.tar.gz" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + GEN_ARGS: + - "-C {{.G_DEPS_CMAKE_SETTINGS_DIR}}/quickcpplib.cmake" + - "-DBUILD_TESTING=OFF" + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_POLICY_DEFAULT_CMP0074=NEW" + - "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + + install-quickcpplib: + internal: true + run: "once" + cmds: + - task: ":utils:cmake:install-remote-tar" + vars: + NAME: "quickcpplib" + WORK_DIR: "{{.G_DEPS_DIR}}/quickcpplib" + FILE_SHA256: "5d4c9b2d6fa177d3fb14f3fe3086867e43b44f4a7a944eb10ee4616b2b0f3c05" + URL: "https://github.com/ned14/quickcpplib/archive/f3e452e.tar.gz" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + GEN_ARGS: + - "-DBUILD_TESTING=OFF" + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + + download-ystdlib: + internal: true + run: "once" + cmds: + - task: ":utils:remote:download-and-extract-tar" + vars: + FILE_SHA256: "d3fc9804eacb3ee4f156ae0ca37151cb04847580" + OUTPUT_DIR: "{{.G_DEPS_DIR}}/ystdlib/ystdlib-src" + URL: "https://github.com/y-scope/ystdlib-cpp/archive/d3fc980.tar.gz" + - | + cat <> "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/ystdlib.cmake" + set( + SPIDER_YSTDLIB_SOURCE_DIRECTORY "{{.G_DEPS_DIR}}/ystdlib/ystdlib-src" + ) + EOF diff --git a/examples/quick-start/CMakeLists.txt b/examples/quick-start/CMakeLists.txt index 119007660..1173f89c5 100644 --- a/examples/quick-start/CMakeLists.txt +++ b/examples/quick-start/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.22.1) project(spider_getting_started) +if(PROJECT_IS_TOP_LEVEL) + # Include dependency settings if the project isn't being included as a subproject. + include("${CMAKE_SOURCE_DIR}/../../build/deps/cmake-settings/all.cmake") +endif() + # Add the Spider library add_subdirectory(../../ spider EXCLUDE_FROM_ALL) diff --git a/lint-tasks.yaml b/lint-tasks.yaml index b99795673..d81b7247d 100644 --- a/lint-tasks.yaml +++ b/lint-tasks.yaml @@ -88,12 +88,21 @@ tasks: - "--config-file '{{.ROOT_DIR}}/.clang-tidy'" - "-p '{{.G_SPIDER_COMPILE_COMMANDS_DB}}'" INCLUDE_PATTERNS: - - "{{.G_EXAMPLES_DIR}}/**" - "{{.G_SRC_SPIDER_DIR}}/**" - "{{.G_TEST_DIR}}/**" OUTPUT_DIR: "{{.G_LINT_CLANG_TIDY_DIR}}" ROOT_PATHS: *cpp_source_files VENV_DIR: "{{.G_LINT_VENV_DIR}}" + - task: ":utils:cpp-lint:clang-tidy-find" + vars: + FLAGS: + - "--config-file '{{.ROOT_DIR}}/.clang-tidy'" + - "-p '{{.G_EXAMPLES_COMPILE_COMMANDS_DB}}'" + INCLUDE_PATTERNS: + - "{{.G_EXAMPLES_DIR}}/**" + OUTPUT_DIR: "{{.G_LINT_CLANG_TIDY_DIR}}" + ROOT_PATHS: *cpp_source_files + VENV_DIR: "{{.G_LINT_VENV_DIR}}" py-check: cmds: diff --git a/src/spider/.clang-format b/src/spider/.clang-format index 06150eeaf..18897e341 100644 --- a/src/spider/.clang-format +++ b/src/spider/.clang-format @@ -10,7 +10,7 @@ IncludeCategories: # Ex: # - Regex: "<(fmt|spdlog)" # Priority: 3 - - Regex: "^<(absl|boost|catch2|fmt|mariadb|msgpack|spdlog)" + - Regex: "^<(absl|boost|catch2|fmt|mariadb|msgpack|spdlog|ystdlib)" Priority: 3 # C system headers - Regex: "^<.+\\.h>" diff --git a/src/spider/CMakeLists.txt b/src/spider/CMakeLists.txt index db0a773c0..b8f51c735 100644 --- a/src/spider/CMakeLists.txt +++ b/src/spider/CMakeLists.txt @@ -52,6 +52,7 @@ target_link_libraries( MariaDBClientCpp::MariaDBClientCpp msgpack-cxx spdlog::spdlog + ystdlib::error_handling ) target_link_libraries(spider_core PRIVATE fmt::fmt) diff --git a/src/spider/worker/DllLoader.cpp b/src/spider/worker/DllLoader.cpp index 59e26b1bb..1b202a25d 100644 --- a/src/spider/worker/DllLoader.cpp +++ b/src/spider/worker/DllLoader.cpp @@ -25,7 +25,7 @@ auto DllLoader::load_dll(std::string const& path_str) -> bool { auto const function_manager_func = boost::dll::import_alias( library, - "function_manager_get_instance" + "g_function_manager_get_instance" ); core::FunctionManager const& function_manager = function_manager_func(); core::FunctionMap const& function_map = function_manager.get_function_map(); @@ -39,7 +39,7 @@ auto DllLoader::load_dll(std::string const& path_str) -> bool { auto const function_name_manager_func = boost::dll::import_alias( library, - "function_name_manager_get_instance" + "g_function_name_manager_get_instance" ); core::FunctionNameManager const& function_name_manager = function_name_manager_func(); core::FunctionNameMap const& function_name_map diff --git a/src/spider/worker/FunctionManager.cpp b/src/spider/worker/FunctionManager.cpp index b7d31da39..719c7583a 100644 --- a/src/spider/worker/FunctionManager.cpp +++ b/src/spider/worker/FunctionManager.cpp @@ -115,4 +115,4 @@ auto FunctionManager::get_function(std::string const& name) const -> Function co } // namespace spider::core // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) -BOOST_DLL_ALIAS(spider::core::FunctionManager::get_instance, function_manager_get_instance) +BOOST_DLL_ALIAS(spider::core::FunctionManager::get_instance, g_function_manager_get_instance) diff --git a/src/spider/worker/FunctionNameManager.cpp b/src/spider/worker/FunctionNameManager.cpp index 9d356ef32..ec36a0019 100644 --- a/src/spider/worker/FunctionNameManager.cpp +++ b/src/spider/worker/FunctionNameManager.cpp @@ -22,5 +22,5 @@ auto FunctionNameManager::get_function_name(void const* ptr) const -> std::optio // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) BOOST_DLL_ALIAS( spider::core::FunctionNameManager::get_instance, - function_name_manager_get_instance + g_function_name_manager_get_instance ); diff --git a/submodules/Catch2 b/submodules/Catch2 deleted file mode 160000 index a6ee7e20c..000000000 --- a/submodules/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a6ee7e20cd4011129816df7992c1a9db2ef4b58f diff --git a/submodules/abseil-cpp b/submodules/abseil-cpp deleted file mode 160000 index 07fff76ed..000000000 --- a/submodules/abseil-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 07fff76ed619672bb7bf00939231ba45aef2b043 diff --git a/taskfile.yaml b/taskfile.yaml index cd5884ad3..556ef3486 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -20,6 +20,11 @@ vars: G_TEST_DIR: "{{.ROOT_DIR}}/tests" G_EXAMPLES_DIR: "{{.ROOT_DIR}}/examples" + G_DEPS_DIR: "{{.G_BUILD_DIR}}/deps" + # These should be kept in-sync with its usage in CMakeLists.txt + G_DEPS_CMAKE_SETTINGS_DIR: "{{.G_DEPS_DIR}}/cmake-settings" + G_DEPS_CMAKE_SETTINGS_FILE: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/settings.cmake" + tasks: clean: cmds: diff --git a/tools/yscope-dev-utils b/tools/yscope-dev-utils index d22183ffa..e300d1bab 160000 --- a/tools/yscope-dev-utils +++ b/tools/yscope-dev-utils @@ -1 +1 @@ -Subproject commit d22183ffa3fb95745b012eb38a6e13b7e5f06fca +Subproject commit e300d1bab4c2f33cbf9ddf9f0c08185faf035070