From b26c793a2b4e47d77ccea49a2c77e97cea9f199a Mon Sep 17 00:00:00 2001 From: sitao Date: Fri, 25 Apr 2025 15:00:21 -0400 Subject: [PATCH 01/38] Add tasks to install boost libraries --- exports/taskfiles/utils/boost.yaml | 166 +++++++++++++++++++++++++++++ exports/taskfiles/utils/utils.yaml | 1 + 2 files changed, 167 insertions(+) create mode 100644 exports/taskfiles/utils/boost.yaml diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml new file mode 100644 index 0000000..6d038dd --- /dev/null +++ b/exports/taskfiles/utils/boost.yaml @@ -0,0 +1,166 @@ +version: "3" + +includes: + remote: "remote.yaml" + +set: ["u", "pipefail"] +shopt: ["globstar"] + +tasks: + # Runs the bootstrap.sh generate step in the given source directory. Boost only supports + # in-source generation and building. + # + # @param {string} SOURCE_DIR Project source directory. + # @param {string} INSTALL_PREFIX Path prefix of where the project should be installed. + # @param {string[]} TARGETS Target libraries to build. + # @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the generate command. + boost-generate: + internal: true + dir: "{{.SOURCE_DIR}}" + cmds: + - >- + ./bootstrap.sh + --prefix="{{.INSTALL_PREFIX}}" + --exec-prefix="{{.INSTALL_PREFIX}}" + --with-libraries={{(join "," .TARGETS)}} + {{- range .EXTRA_ARGS}} + "{{.}}" + {{- end}} + + # Runs the b2 build step for boost. The caller must have previously called `generate` on + # `SOURCE_DIR` for this task to succeed. + # + # @param {string} SOURCE_DIR Directory containing the boost source. + # @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the build command. + # @param {int} [JOBS] The maximum number of concurrent processes to use when building. If + # omitted, the b2 default number is used. Before 1.76.0, the number was 1. Since 1.76.0, the + # default is the number of cores. + boost-build: + internal: true + dir: "{{.SOURCE_DIR}}" + cmds: + - >- + ./b2 + {{- range .EXTRA_ARGS}} + "{{.}}" + {{- end}} + {{- if .JOBS}} + "-j{{.JOBS}}" + {{- end}} + + # Runs the b2 install step for boost. The caller must have previously called `build` on + # `SOURCE_DIR` for this task to succeed. If `CMAKE_SETTINGS_DIR` is set, a settings file will be + # created in that directory, containing a `boost_ROOT` CMake variable that points to + # `INSTALL_PREFIX`. + # + # @param {string} SOURCE_DIR Directory containing the boost source. + # @param {string} INSTALL_PREFIX Path prefix of where the project should be installed. + # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings + # file should be stored. + # @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the install command. + boost-install: + internal: true + dir: "{{.SOURCE_DIR}}" + cmds: + - >- + ./b2 + install + {{- range .EXTRA_ARGS}} + "{{.}}" + {{- end}} + - >- + {{- if .CMAKE_SETTINGS_DIR}} + echo "set(BOOST_ROOT + \"{{.INSTALL_PREFIX}}\" + CACHE PATH + \"Package root for boost.\" + )" >> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" + {{- end}} + + # Downloads boost from `URL` and installs boost. + # + # General parameters + # @param {string} [WORK_DIR={{.TASK_DIR}}] Base directory to store the install and src + # directories inside. + # @param {string} [SOURCE_DIR={{.WORK_DIR}}/boost-src] Directory in which to extract the tar + # file. + # + # Download parameters + # @param {string} FILE_SHA256 Content hash to verify the downloaded tar file against. + # @param {string} URL + # + # Boost generate parameters + # @param {string} [INSTALL_PREFIX={{.WORK_DIR}}/boost-install] Path prefix of where the project + # should be installed. + # @param {string[]} TARGETS Target libraries to build. + # @param {string[]} [GEN_ARGS] Any additional arguments to pass to the generate command. + # + # Boost build parameters + # @param {int} [JOBS] The maximum number of concurrent processes to use when building. If + # omitted, the b2 default number is used. Before 1.76.0, the number was 1. Since 1.76.0, the + # default is the number of cores. + # @param {string[]} [BUILD_ARGS] Any additional arguments to pass to the build command. + # + # Boost install parameters + # @param {string[]} [INSTALL_ARGS] Any additional arguments to pass to the install command. + # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings + # file should be stored. + boost-download-and-install: + internal: true + label: "{{.TASK}}:{{.URL}}-{{.INSTALL_PREFIX}}" + vars: + # General parameters + WORK_DIR: >- + {{default .ROOT_DIR .WORK_DIR}} + SOURCE_DIR: >- + {{default (printf "%s/boost-src" .WORK_DIR) .SOURCE_DIR}} + + # Boost generate parameters + INSTALL_PREFIX: >- + {{default (printf "%s/boost-install" .WORK_DIR) .INSTALL_PREFIX}} + TARGETS: + ref: "default (list) .TARGETS" + GEN_ARGS: + ref: "default (list) .GEN_ARGS" + + # Boost build parameters + BUILD_ARGS: + ref: "default (list) .BUILD_ARGS" + JOBS: >- + {{default "" .JOBS}} + + # Boost install parameters + INSTALL_ARGS: + ref: "default (list) .INSTALL_ARGS" + CMAKE_SETTINGS_DIR: >- + {{default "" .CMAKE_SETTINGS_DIR}} + requires: + vars: ["FILE_SHA256", "URL"] + deps: + - task: "remote:download-and-extract-tar" + vars: + FILE_SHA256: "{{.FILE_SHA256}}" + OUTPUT_DIR: "{{.SOURCE_DIR}}" + URL: "{{.URL}}" + cmds: + - task: "boost-generate" + vars: + SOURCE_DIR: "{{.SOURCE_DIR}}" + INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + TARGETS: + ref: ".TARGETS" + EXTRA_ARGS: + ref: ".GEN_ARGS" + - task: "boost-build" + vars: + SOURCE_DIR: "{{.SOURCE_DIR}}" + JOBS: "{{.JOBS}}" + EXTRA_ARGS: + ref: ".BUILD_ARGS" + - task: "boost-install" + vars: + SOURCE_DIR: "{{.SOURCE_DIR}}" + INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}" + EXTRA_ARGS: + ref: ".INSTALL_ARGS" diff --git a/exports/taskfiles/utils/utils.yaml b/exports/taskfiles/utils/utils.yaml index 92520ac..565d87b 100644 --- a/exports/taskfiles/utils/utils.yaml +++ b/exports/taskfiles/utils/utils.yaml @@ -1,6 +1,7 @@ version: "3" includes: + boost: boost.yaml checksum: checksum.yaml cmake: cmake.yaml cpp-lint: cpp-lint.yaml From a7ce19353951a94fbd1179554c95875d65e0dffe Mon Sep 17 00:00:00 2001 From: sitao Date: Fri, 25 Apr 2025 17:00:20 -0400 Subject: [PATCH 02/38] Add boost install test --- taskfile.yaml | 2 + tests/boost/CMakeLists.txt | 42 +++++++++++++++++++ tests/boost/boost-test.cpp | 62 ++++++++++++++++++++++++++++ tests/boost/boost-test.yaml | 82 +++++++++++++++++++++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 tests/boost/CMakeLists.txt create mode 100644 tests/boost/boost-test.cpp create mode 100644 tests/boost/boost-test.yaml diff --git a/taskfile.yaml b/taskfile.yaml index 0153a0f..7a6fcb5 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -2,6 +2,7 @@ version: "3" includes: tests: "./taskfiles/tests.yaml" + boost-test: "./tests/boost/boost-test.yaml" set: ["u", "pipefail"] shopt: ["globstar"] @@ -17,3 +18,4 @@ tasks: test: cmds: - task: "tests:download-and-extract-zip-basic" + - task: "boost-test:boost-test" diff --git a/tests/boost/CMakeLists.txt b/tests/boost/CMakeLists.txt new file mode 100644 index 0000000..1d2b1ec --- /dev/null +++ b/tests/boost/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.22.1) + +project( + boost-test + LANGUAGES + CXX + VERSION 0.1.0 +) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation." FORCE) + +include("build/deps/cmake-settings/all.cmake") + +find_package( + Boost + 1.74 + REQUIRED + COMPONENTS + headers + program_options + system +) +if(Boost_FOUND) + message(STATUS "Found Boost ${Boost_VERSION}") +else() + message(FATAL_ERROR "Could not find ${SPIDER_LIBS_STRING} libraries for Boost") +endif() + +add_executable(boost-test) +target_sources(boost-test + PRIVATE + boost-test.cpp +) +target_link_libraries(boost-test + PRIVATE + Boost::headers + Boost::program_options + Boost::system +) diff --git a/tests/boost/boost-test.cpp b/tests/boost/boost-test.cpp new file mode 100644 index 0000000..3dba43e --- /dev/null +++ b/tests/boost/boost-test.cpp @@ -0,0 +1,62 @@ + +#include +#include + +#include +#include +#include +#include +#include + +namespace { + +auto parse_args(int argc, char** argv) -> boost::program_options::variables_map { + boost::program_options::options_description desc; + desc.add_options()("help", "Boost task test. Check the string against its size."); + desc.add_options()("input", boost::program_options::value(), "Input string."); + desc.add_options()("size", boost::program_options::value(), "Size of the string."); + boost::program_options::variables_map variables; + boost::program_options::store( + // NOLINTNEXTLINE(misc-include-cleaner) + boost::program_options::parse_command_line(argc, argv, desc), + variables + ); + boost::program_options::notify(variables); + return variables; +} +constexpr int cCmdArgParseErr = 1; +constexpr int cSizeErr = 2; +} + +auto main(int argc, char** argv) -> int { + boost::program_options::variables_map const args = parse_args(argc, argv); + + std::string input; + int size; + + try { + if (!args.contains("input")) { + std::cerr << "Error: Missing input argument.\n"; + return cCmdArgParseErr; + } + input = args["input"].as(); + if (!args.contains("size")) { + std::cerr << "Error: Missing size argument.\n"; + return cCmdArgParseErr; + } + size = args["size"].as(); + } catch (boost::bad_any_cast const& e) { + std::cerr << "Error: Bad any cast: " << e.what() << "\n"; + return cCmdArgParseErr; + } catch (boost::program_options::error const& e) { + std::cerr << "Error: Program options error: " << e.what() << "\n"; + return cCmdArgParseErr; + } + + if (size != input.size()) { + std::cerr << "Error: Size mismatch. Expected " << input.size() << ", got " << size << ".\n"; + return cSizeErr; + } + + return 0; +} \ No newline at end of file diff --git a/tests/boost/boost-test.yaml b/tests/boost/boost-test.yaml new file mode 100644 index 0000000..88803a9 --- /dev/null +++ b/tests/boost/boost-test.yaml @@ -0,0 +1,82 @@ +version: "3" + +includes: + utils: "../../exports/taskfiles/utils/utils.yaml" + +vars: + G_BUILD_DIR: "{{.TASKFILE_DIR}}/build" + G_DEPS_DIR: "{{.G_BUILD_DIR}}/deps" + G_DEPS_CMAKE_SETTINGS_DIR: "{{.G_DEPS_DIR}}/cmake-settings" + G_DEPS_CMAKE_SETTINGS_FILE: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/settings.cmake" + + G_BUILD_BOOST_TEST_DIR: "{{.G_BUILD_DIR}}/boost-test" + G_BOOST_TEST_CMAKE_CACHE: "{{.G_BUILD_BOOST_TEST_DIR}}/CMakeCache.txt" + G_BOOST_TEST_COMPILE_COMMANDS_DB: "{{.G_BUILD_BOOST_TEST_DIR}}/compile_commands.json" + G_BOOST_TEST_EXECUTABLE: "{{.G_BUILD_BOOST_TEST_DIR}}/boost-test" + +tasks: + clean: + internal: true + cmds: + - "rm -rf {{.G_BUILD_DIR}}" + + config-cmake-project: + internal: true + sources: + - "{{.TASKFILE}}" + - "CMakeLists.txt" + generates: + - "{{.G_BOOST_TEST_CMAKE_CACHE}}" + - "{{.G_BOOST_TEST_COMPILE_COMMANDS_DB}}" + cmds: + - "cmake -S '{{.TASKFILE_DIR}}' -B '{{.G_BUILD_BOOST_TEST_DIR}}'" + + init: + internal: true + silent: true + run: "once" + cmds: + - "mkdir -p {{.G_BUILD_DIR}}" + + install-boost: + internal: true + run: "once" + cmds: + - task: "utils:boost:boost-download-and-install" + vars: + WORK_DIR: "{{.G_DEPS_DIR}}/boost" + FILE_SHA256: "2128a4c96862b5c0970c1e34d76b1d57e4a1016b80df85ad39667f30b1deba26" + URL: "https://github.com/boostorg/boost/releases/download/boost-1.86.0/\ + boost-1.86.0-b2-nodocs.tar.gz" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + TARGETS: + - "program_options" + - "system" + + build-boost-test: + internal: true + sources: + - "{{.TASKFILE}}" + - "CMakeLists.txt" + - "boost-test.cpp" + cmds: + - "cmake --build '{{.G_BUILD_BOOST_TEST_DIR}}' --target all" + + run-boost-test: + internal: true + sources: + - "{{.G_BOOST_TEST_EXECUTABLE}}" + cmds: + - "{{.G_BOOST_TEST_EXECUTABLE}} --input 'testtest' --size 8" + + boost-test: + cmds: + - task: "init" + - task: "utils:cmake:install-deps-and-generate-settings" + vars: + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + DEP_TASK: "install-boost" + - task: "config-cmake-project" + - task: "build-boost-test" + - task: "run-boost-test" + - task: "clean" \ No newline at end of file From c2d72f197088cc040d74cd3ad376c0516d28a4a8 Mon Sep 17 00:00:00 2001 From: sitao Date: Fri, 25 Apr 2025 17:05:38 -0400 Subject: [PATCH 03/38] Reformat files --- tests/boost/.clang-format | 20 ++++++++++++++++++++ tests/boost/boost-test.cpp | 7 +++---- tests/boost/boost-test.yaml | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 tests/boost/.clang-format diff --git a/tests/boost/.clang-format b/tests/boost/.clang-format new file mode 100644 index 0000000..97a51f3 --- /dev/null +++ b/tests/boost/.clang-format @@ -0,0 +1,20 @@ +BasedOnStyle: "InheritParentConfig" + +IncludeCategories: + # NOTE: A header is grouped by first matching regex + # Project headers + # - Regex: "^" + Priority: 1 + # C++ standard libraries + - Regex: "^<.+>" + Priority: 2 \ No newline at end of file diff --git a/tests/boost/boost-test.cpp b/tests/boost/boost-test.cpp index 3dba43e..fe6946d 100644 --- a/tests/boost/boost-test.cpp +++ b/tests/boost/boost-test.cpp @@ -1,4 +1,3 @@ - #include #include @@ -9,7 +8,6 @@ #include namespace { - auto parse_args(int argc, char** argv) -> boost::program_options::variables_map { boost::program_options::options_description desc; desc.add_options()("help", "Boost task test. Check the string against its size."); @@ -24,9 +22,10 @@ auto parse_args(int argc, char** argv) -> boost::program_options::variables_map boost::program_options::notify(variables); return variables; } + constexpr int cCmdArgParseErr = 1; constexpr int cSizeErr = 2; -} +} // namespace auto main(int argc, char** argv) -> int { boost::program_options::variables_map const args = parse_args(argc, argv); @@ -59,4 +58,4 @@ auto main(int argc, char** argv) -> int { } return 0; -} \ No newline at end of file +} diff --git a/tests/boost/boost-test.yaml b/tests/boost/boost-test.yaml index 88803a9..e3f5b60 100644 --- a/tests/boost/boost-test.yaml +++ b/tests/boost/boost-test.yaml @@ -36,7 +36,7 @@ tasks: silent: true run: "once" cmds: - - "mkdir -p {{.G_BUILD_DIR}}" + - "mkdir -p {{.G_BUILD_DIR}}" install-boost: internal: true @@ -79,4 +79,4 @@ tasks: - task: "config-cmake-project" - task: "build-boost-test" - task: "run-boost-test" - - task: "clean" \ No newline at end of file + - task: "clean" From 01a18ab56aa13672a2f88207837292c5dc7d0f0e Mon Sep 17 00:00:00 2001 From: sitao Date: Fri, 25 Apr 2025 17:07:52 -0400 Subject: [PATCH 04/38] Reformat cmake files --- tests/boost/CMakeLists.txt | 42 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/tests/boost/CMakeLists.txt b/tests/boost/CMakeLists.txt index 1d2b1ec..eb4ccbf 100644 --- a/tests/boost/CMakeLists.txt +++ b/tests/boost/CMakeLists.txt @@ -1,42 +1,32 @@ cmake_minimum_required(VERSION 3.22.1) -project( - boost-test - LANGUAGES - CXX - VERSION 0.1.0 -) +project(boost-test LANGUAGES CXX VERSION 0.1.0) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation." FORCE) +set(CMAKE_EXPORT_COMPILE_COMMANDS + ON + CACHE BOOL + "Enable/Disable output of compile commands during generation." + FORCE +) include("build/deps/cmake-settings/all.cmake") -find_package( - Boost - 1.74 - REQUIRED - COMPONENTS - headers - program_options - system -) +find_package(Boost 1.74 REQUIRED COMPONENTS headers program_options system) if(Boost_FOUND) message(STATUS "Found Boost ${Boost_VERSION}") else() - message(FATAL_ERROR "Could not find ${SPIDER_LIBS_STRING} libraries for Boost") + message( + FATAL_ERROR + "Could not find ${SPIDER_LIBS_STRING} libraries for Boost" + ) endif() add_executable(boost-test) -target_sources(boost-test - PRIVATE - boost-test.cpp -) -target_link_libraries(boost-test - PRIVATE - Boost::headers - Boost::program_options - Boost::system +target_sources(boost-test PRIVATE boost-test.cpp) +target_link_libraries( + boost-test + PRIVATE Boost::headers Boost::program_options Boost::system ) From 0b70373ed579c9d07fefc5c7e5dadb94f137e455 Mon Sep 17 00:00:00 2001 From: sitao Date: Fri, 25 Apr 2025 17:18:07 -0400 Subject: [PATCH 05/38] Fix clang-tidy --- tests/boost/boost-test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/boost/boost-test.cpp b/tests/boost/boost-test.cpp index fe6946d..7e1abb2 100644 --- a/tests/boost/boost-test.cpp +++ b/tests/boost/boost-test.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,7 @@ auto main(int argc, char** argv) -> int { boost::program_options::variables_map const args = parse_args(argc, argv); std::string input; - int size; + int size = 0; try { if (!args.contains("input")) { From 1ba12d3ec153438697d69e952caca322bdd1d2f6 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Fri, 25 Apr 2025 17:33:30 -0400 Subject: [PATCH 06/38] Fix if comparison to follow style guideline. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- tests/boost/boost-test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/boost/boost-test.cpp b/tests/boost/boost-test.cpp index 7e1abb2..beabd01 100644 --- a/tests/boost/boost-test.cpp +++ b/tests/boost/boost-test.cpp @@ -35,12 +35,12 @@ auto main(int argc, char** argv) -> int { int size = 0; try { - if (!args.contains("input")) { + if (false == args.contains("input")) { std::cerr << "Error: Missing input argument.\n"; return cCmdArgParseErr; } input = args["input"].as(); - if (!args.contains("size")) { + if (false == args.contains("size")) { std::cerr << "Error: Missing size argument.\n"; return cCmdArgParseErr; } From 8aca0052b21b7c6db1bf2639d67b594f5352d678 Mon Sep 17 00:00:00 2001 From: sitao Date: Fri, 25 Apr 2025 17:34:26 -0400 Subject: [PATCH 07/38] Fix cmake for wrong reference --- tests/boost/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/boost/CMakeLists.txt b/tests/boost/CMakeLists.txt index eb4ccbf..39cff34 100644 --- a/tests/boost/CMakeLists.txt +++ b/tests/boost/CMakeLists.txt @@ -18,10 +18,7 @@ find_package(Boost 1.74 REQUIRED COMPONENTS headers program_options system) if(Boost_FOUND) message(STATUS "Found Boost ${Boost_VERSION}") else() - message( - FATAL_ERROR - "Could not find ${SPIDER_LIBS_STRING} libraries for Boost" - ) + message(FATAL_ERROR "Could not find libraries for Boost") endif() add_executable(boost-test) From b0b9c9c8b28d5ed217088bb1d1963e3e39511769 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 28 Apr 2025 13:37:10 -0400 Subject: [PATCH 08/38] Remove unnecessary check for library not found. Co-authored-by: davidlion --- tests/boost/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/boost/CMakeLists.txt b/tests/boost/CMakeLists.txt index 39cff34..7568cfc 100644 --- a/tests/boost/CMakeLists.txt +++ b/tests/boost/CMakeLists.txt @@ -16,9 +16,7 @@ include("build/deps/cmake-settings/all.cmake") find_package(Boost 1.74 REQUIRED COMPONENTS headers program_options system) if(Boost_FOUND) - message(STATUS "Found Boost ${Boost_VERSION}") -else() - message(FATAL_ERROR "Could not find libraries for Boost") + message(STATUS "Found Boost ${Boost_VERSION}.") endif() add_executable(boost-test) From 744d42c58a0c5e6893442601438a3a1d051575c2 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 28 Apr 2025 17:42:10 +0000 Subject: [PATCH 09/38] Use target_compile_feature to set c++ version --- tests/boost/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/boost/CMakeLists.txt b/tests/boost/CMakeLists.txt index 39cff34..cab0893 100644 --- a/tests/boost/CMakeLists.txt +++ b/tests/boost/CMakeLists.txt @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.22.1) project(boost-test LANGUAGES CXX VERSION 0.1.0) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL @@ -22,6 +19,7 @@ else() endif() add_executable(boost-test) +target_compile_features(boost-test PRIVATE cxx_std_20) target_sources(boost-test PRIVATE boost-test.cpp) target_link_libraries( boost-test From 186204f36849e073afd6d45e9c94558f2d1522e8 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 28 Apr 2025 17:46:54 +0000 Subject: [PATCH 10/38] Remove unused code in .clang-format --- tests/boost/.clang-format | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/boost/.clang-format b/tests/boost/.clang-format index 97a51f3..8853989 100644 --- a/tests/boost/.clang-format +++ b/tests/boost/.clang-format @@ -2,9 +2,6 @@ BasedOnStyle: "InheritParentConfig" IncludeCategories: # NOTE: A header is grouped by first matching regex - # Project headers - # - Regex: "^ Date: Mon, 28 Apr 2025 17:56:23 +0000 Subject: [PATCH 11/38] Use tasks from cmake to configure and build boost test project --- tests/boost/boost-test.yaml | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/tests/boost/boost-test.yaml b/tests/boost/boost-test.yaml index e3f5b60..eb98fe4 100644 --- a/tests/boost/boost-test.yaml +++ b/tests/boost/boost-test.yaml @@ -20,17 +20,6 @@ tasks: cmds: - "rm -rf {{.G_BUILD_DIR}}" - config-cmake-project: - internal: true - sources: - - "{{.TASKFILE}}" - - "CMakeLists.txt" - generates: - - "{{.G_BOOST_TEST_CMAKE_CACHE}}" - - "{{.G_BOOST_TEST_COMPILE_COMMANDS_DB}}" - cmds: - - "cmake -S '{{.TASKFILE_DIR}}' -B '{{.G_BUILD_BOOST_TEST_DIR}}'" - init: internal: true silent: true @@ -53,15 +42,6 @@ tasks: - "program_options" - "system" - build-boost-test: - internal: true - sources: - - "{{.TASKFILE}}" - - "CMakeLists.txt" - - "boost-test.cpp" - cmds: - - "cmake --build '{{.G_BUILD_BOOST_TEST_DIR}}' --target all" - run-boost-test: internal: true sources: @@ -76,7 +56,12 @@ tasks: vars: CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" DEP_TASK: "install-boost" - - task: "config-cmake-project" - - task: "build-boost-test" + - task: "utils:cmake:generate" + vars: + SOURCE_DIR: "{{.TASKFILE_DIR}}" + BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" + - task: "utils:cmake:build" + vars: + BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" - task: "run-boost-test" - task: "clean" From 0968a4a91d2a368c6837e197cfa1cf06d375252c Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 28 Apr 2025 18:22:00 +0000 Subject: [PATCH 12/38] Restructure the tests folder --- taskfile.yaml | 4 +- {tests => taskfiles}/boost/.clang-format | 0 {tests => taskfiles}/boost/CMakeLists.txt | 0 {tests => taskfiles}/boost/boost-test.cpp | 0 .../boost/tests.yaml | 35 +++---- taskfiles/remote/tests.yaml | 97 +++++++++++++++++++ taskfiles/tests.yaml | 96 ++---------------- 7 files changed, 126 insertions(+), 106 deletions(-) rename {tests => taskfiles}/boost/.clang-format (100%) rename {tests => taskfiles}/boost/CMakeLists.txt (100%) rename {tests => taskfiles}/boost/boost-test.cpp (100%) rename tests/boost/boost-test.yaml => taskfiles/boost/tests.yaml (98%) create mode 100644 taskfiles/remote/tests.yaml diff --git a/taskfile.yaml b/taskfile.yaml index 7a6fcb5..1e83d24 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -2,7 +2,6 @@ version: "3" includes: tests: "./taskfiles/tests.yaml" - boost-test: "./tests/boost/boost-test.yaml" set: ["u", "pipefail"] shopt: ["globstar"] @@ -17,5 +16,4 @@ tasks: test: cmds: - - task: "tests:download-and-extract-zip-basic" - - task: "boost-test:boost-test" + - task: "tests:all" diff --git a/tests/boost/.clang-format b/taskfiles/boost/.clang-format similarity index 100% rename from tests/boost/.clang-format rename to taskfiles/boost/.clang-format diff --git a/tests/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt similarity index 100% rename from tests/boost/CMakeLists.txt rename to taskfiles/boost/CMakeLists.txt diff --git a/tests/boost/boost-test.cpp b/taskfiles/boost/boost-test.cpp similarity index 100% rename from tests/boost/boost-test.cpp rename to taskfiles/boost/boost-test.cpp diff --git a/tests/boost/boost-test.yaml b/taskfiles/boost/tests.yaml similarity index 98% rename from tests/boost/boost-test.yaml rename to taskfiles/boost/tests.yaml index eb98fe4..0a2d95c 100644 --- a/tests/boost/boost-test.yaml +++ b/taskfiles/boost/tests.yaml @@ -15,6 +15,24 @@ vars: G_BOOST_TEST_EXECUTABLE: "{{.G_BUILD_BOOST_TEST_DIR}}/boost-test" tasks: + test: + internal: true + cmds: + - task: "init" + - task: "utils:cmake:install-deps-and-generate-settings" + vars: + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + DEP_TASK: "install-boost" + - task: "utils:cmake:generate" + vars: + SOURCE_DIR: "{{.TASKFILE_DIR}}" + BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" + - task: "utils:cmake:build" + vars: + BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" + - task: "run-boost-test" + - task: "clean" + clean: internal: true cmds: @@ -48,20 +66,3 @@ tasks: - "{{.G_BOOST_TEST_EXECUTABLE}}" cmds: - "{{.G_BOOST_TEST_EXECUTABLE}} --input 'testtest' --size 8" - - boost-test: - cmds: - - task: "init" - - task: "utils:cmake:install-deps-and-generate-settings" - vars: - CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" - DEP_TASK: "install-boost" - - task: "utils:cmake:generate" - vars: - SOURCE_DIR: "{{.TASKFILE_DIR}}" - BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" - - task: "utils:cmake:build" - vars: - BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" - - task: "run-boost-test" - - task: "clean" diff --git a/taskfiles/remote/tests.yaml b/taskfiles/remote/tests.yaml new file mode 100644 index 0000000..59cffa7 --- /dev/null +++ b/taskfiles/remote/tests.yaml @@ -0,0 +1,97 @@ +version: "3" + +includes: + remote: "../../exports/taskfiles/utils/remote.yaml" + +vars: + G_EXTRACTED_ZIP_CODEOWNERS_PATH: "yscope-dev-utils-main/.github/CODEOWNERS" + G_EXTRACTED_ZIP_LICENSE_PATH: "yscope-dev-utils-main/LICENSE" + G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH: >- + yscope-dev-utils-main/.github/PULL_REQUEST_TEMPLATE.md + G_TEST_ZIP_FILE_SHA256: "2c9a21f83484e004c41c28be759451dbdc787190eb044365ba58f7bb846418f6" + G_TEST_ZIP_FILE_URL: "https://github.com/y-scope/yscope-dev-utils/archive/refs/heads/main.zip" + +tasks: + default: + internal: true + cmds: + - task: "download-and-extract-zip-test-basic" + - task: "download-and-extract-zip-test-exclusions" + - task: "download-and-extract-zip-test-inclusions" + + download-and-extract-zip-test-basic: + vars: + OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" + cmds: + - task: "download-and-extract-zip-test-cleaner" + vars: + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + - task: "remote:download-and-extract-zip" + vars: + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + URL: "{{.G_TEST_ZIP_FILE_URL}}" + FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}" + + # Test that an expected file exists + - "diff -q '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_LICENSE_PATH}}' '{{.ROOT_DIR}}/LICENSE'" + + # Test that the output files are in the expected locations + - "test -e '{{.OUTPUT_DIR}}.md5'" + - "test -e '{{.OUTPUT_DIR}}.zip'" + + download-and-extract-zip-test-exclusions: + vars: + OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" + cmds: + - task: "download-and-extract-zip-test-cleaner" + vars: + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + - task: "remote:download-and-extract-zip" + vars: + EXCLUDE_PATTERNS: + - "*/CODEOWNERS" + - "{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}" + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + URL: "{{.G_TEST_ZIP_FILE_URL}}" + FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}" + + # Test that the excluded files don't exist + - "test ! -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_CODEOWNERS_PATH}}'" + - "test ! -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}'" + + # Test that other files do exist + - "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_LICENSE_PATH}}'" + + download-and-extract-zip-test-inclusions: + vars: + OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" + cmds: + - task: "download-and-extract-zip-test-cleaner" + vars: + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + - task: "remote:download-and-extract-zip" + vars: + INCLUDE_PATTERNS: + - "*/CODEOWNERS" + - "{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}" + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + URL: "{{.G_TEST_ZIP_FILE_URL}}" + FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}" + + # Test that only the included files exist + - "test ! -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_LICENSE_PATH}}'" + - "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_CODEOWNERS_PATH}}'" + - "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}'" + + # Cleans up the files output by download-and-extract-zip (assuming their default paths weren't + # changed). + # + # @param {string} OUTPUT_DIR Output directory passed to download-and-extract-zip. + download-and-extract-zip-test-cleaner: + internal: true + requires: + vars: ["OUTPUT_DIR"] + cmds: + - "rm -rf '{{.OUTPUT_DIR}}'" + - "rm -f '{{.OUTPUT_DIR}}.md5'" + - "rm -f '{{.OUTPUT_DIR}}.zip'" diff --git a/taskfiles/tests.yaml b/taskfiles/tests.yaml index a330305..b979eca 100644 --- a/taskfiles/tests.yaml +++ b/taskfiles/tests.yaml @@ -1,96 +1,20 @@ version: "3" includes: - remote: "../exports/taskfiles/utils/remote.yaml" - -vars: - G_EXTRACTED_ZIP_CODEOWNERS_PATH: "yscope-dev-utils-main/.github/CODEOWNERS" - G_EXTRACTED_ZIP_LICENSE_PATH: "yscope-dev-utils-main/LICENSE" - G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH: >- - yscope-dev-utils-main/.github/PULL_REQUEST_TEMPLATE.md - G_TEST_ZIP_FILE_SHA256: "2c9a21f83484e004c41c28be759451dbdc787190eb044365ba58f7bb846418f6" - G_TEST_ZIP_FILE_URL: "https://github.com/y-scope/yscope-dev-utils/archive/refs/heads/main.zip" + boost: "boost/tests.yaml" + remote: "remote/tests.yaml" tasks: - default: - cmds: - - task: "download-and-extract-zip-test-basic" - - task: "download-and-extract-zip-test-exclusions" - - task: "download-and-extract-zip-test-inclusions" - - download-and-extract-zip-test-basic: - vars: - OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" - cmds: - - task: "download-and-extract-zip-test-cleaner" - vars: - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - - task: "remote:download-and-extract-zip" - vars: - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - URL: "{{.G_TEST_ZIP_FILE_URL}}" - FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}" - - # Test that an expected file exists - - "diff -q '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_LICENSE_PATH}}' '{{.ROOT_DIR}}/LICENSE'" - - # Test that the output files are in the expected locations - - "test -e '{{.OUTPUT_DIR}}.md5'" - - "test -e '{{.OUTPUT_DIR}}.zip'" - - download-and-extract-zip-test-exclusions: - vars: - OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" + all: + internal: true cmds: - - task: "download-and-extract-zip-test-cleaner" - vars: - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - - task: "remote:download-and-extract-zip" - vars: - EXCLUDE_PATTERNS: - - "*/CODEOWNERS" - - "{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}" - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - URL: "{{.G_TEST_ZIP_FILE_URL}}" - FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}" - - # Test that the excluded files don't exist - - "test ! -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_CODEOWNERS_PATH}}'" - - "test ! -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}'" + - task: "boost" + - task: "remote" - # Test that other files do exist - - "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_LICENSE_PATH}}'" - - download-and-extract-zip-test-inclusions: - vars: - OUTPUT_DIR: "{{.G_OUTPUT_DIR}}/{{.TASK | replace \":\" \"#\"}}" + boost: cmds: - - task: "download-and-extract-zip-test-cleaner" - vars: - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - - task: "remote:download-and-extract-zip" - vars: - INCLUDE_PATTERNS: - - "*/CODEOWNERS" - - "{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}" - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - URL: "{{.G_TEST_ZIP_FILE_URL}}" - FILE_SHA256: "{{.G_TEST_ZIP_FILE_SHA256}}" - - # Test that only the included files exist - - "test ! -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_LICENSE_PATH}}'" - - "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_CODEOWNERS_PATH}}'" - - "test -e '{{.OUTPUT_DIR}}/{{.G_EXTRACTED_ZIP_PULL_REQUEST_TEMPLATE_PATH}}'" + - task: "boost:test" - # Cleans up the files output by download-and-extract-zip (assuming their default paths weren't - # changed). - # - # @param {string} OUTPUT_DIR Output directory passed to download-and-extract-zip. - download-and-extract-zip-test-cleaner: - internal: true - requires: - vars: ["OUTPUT_DIR"] + remote: cmds: - - "rm -rf '{{.OUTPUT_DIR}}'" - - "rm -f '{{.OUTPUT_DIR}}.md5'" - - "rm -f '{{.OUTPUT_DIR}}.zip'" + - task: "remote:default" From 75d0aeda14f84723e80d22603c9f86986c61218f Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 28 Apr 2025 19:08:09 +0000 Subject: [PATCH 13/38] Bump boost min requirement for potential url library --- taskfiles/boost/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index 139924b..cab6107 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS include("build/deps/cmake-settings/all.cmake") -find_package(Boost 1.74 REQUIRED COMPONENTS headers program_options system) +find_package(Boost 1.83 REQUIRED COMPONENTS headers program_options system) if(Boost_FOUND) message(STATUS "Found Boost ${Boost_VERSION}.") endif() From 8ca176d71b055d40b87644738bb1ba96230f803d Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 28 Apr 2025 19:16:00 +0000 Subject: [PATCH 14/38] Add more boost libraries --- taskfiles/boost/CMakeLists.txt | 15 ++++++++++++++- taskfiles/boost/tests.yaml | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index cab6107..7275bb0 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -11,7 +11,20 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS include("build/deps/cmake-settings/all.cmake") -find_package(Boost 1.83 REQUIRED COMPONENTS headers program_options system) +find_package( + Boost + 1.83 + REQUIRED + COMPONENTS + filesystem + headers + iostreams + process + program_options + regex + system + url +) if(Boost_FOUND) message(STATUS "Found Boost ${Boost_VERSION}.") endif() diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index 0a2d95c..ecc3ba4 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -57,8 +57,14 @@ tasks: boost-1.86.0-b2-nodocs.tar.gz" CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" TARGETS: + - "filesystem" + - "headers" + - "iostreams" + - "process" - "program_options" + - "regex" - "system" + - "url" run-boost-test: internal: true From 0ab8ca5dcd8def0c67cd94fafdef4e8d1ec2f3ce Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Tue, 29 Apr 2025 18:39:42 -0400 Subject: [PATCH 15/38] Use absolute include path for taskfiles. Co-authored-by: davidlion --- taskfiles/boost/tests.yaml | 2 +- taskfiles/remote/tests.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index ecc3ba4..edc751f 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -1,7 +1,7 @@ version: "3" includes: - utils: "../../exports/taskfiles/utils/utils.yaml" + utils: "{{.ROOT_DIR}}/exports/taskfiles/utils/utils.yaml" vars: G_BUILD_DIR: "{{.TASKFILE_DIR}}/build" diff --git a/taskfiles/remote/tests.yaml b/taskfiles/remote/tests.yaml index 59cffa7..0d2f7a2 100644 --- a/taskfiles/remote/tests.yaml +++ b/taskfiles/remote/tests.yaml @@ -1,7 +1,7 @@ version: "3" includes: - remote: "../../exports/taskfiles/utils/remote.yaml" + remote: "{{.ROOT_DIR}}/exports/taskfiles/utils/remote.yaml" vars: G_EXTRACTED_ZIP_CODEOWNERS_PATH: "yscope-dev-utils-main/.github/CODEOWNERS" From 6158dc7f85481ca9a86e945d637b14c57b89cb24 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Tue, 29 Apr 2025 22:51:37 +0000 Subject: [PATCH 16/38] Revert "Use absolute include path for taskfiles." This reverts commit 0ab8ca5dcd8def0c67cd94fafdef4e8d1ec2f3ce. --- taskfiles/boost/tests.yaml | 2 +- taskfiles/remote/tests.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index edc751f..ecc3ba4 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -1,7 +1,7 @@ version: "3" includes: - utils: "{{.ROOT_DIR}}/exports/taskfiles/utils/utils.yaml" + utils: "../../exports/taskfiles/utils/utils.yaml" vars: G_BUILD_DIR: "{{.TASKFILE_DIR}}/build" diff --git a/taskfiles/remote/tests.yaml b/taskfiles/remote/tests.yaml index 0d2f7a2..59cffa7 100644 --- a/taskfiles/remote/tests.yaml +++ b/taskfiles/remote/tests.yaml @@ -1,7 +1,7 @@ version: "3" includes: - remote: "{{.ROOT_DIR}}/exports/taskfiles/utils/remote.yaml" + remote: "../../exports/taskfiles/utils/remote.yaml" vars: G_EXTRACTED_ZIP_CODEOWNERS_PATH: "yscope-dev-utils-main/.github/CODEOWNERS" From 6ee995dfb21a945a7d51a8268168cb9e344d764a Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Tue, 29 Apr 2025 23:20:11 +0000 Subject: [PATCH 17/38] Add all boost libraries linkage in cmake --- taskfiles/boost/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index 7275bb0..bb9e8b5 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -34,5 +34,13 @@ target_compile_features(boost-test PRIVATE cxx_std_20) target_sources(boost-test PRIVATE boost-test.cpp) target_link_libraries( boost-test - PRIVATE Boost::headers Boost::program_options Boost::system + PRIVATE + Boost::filesystem + Boost::headers + Boost::iostreams + Boost::process + Boost::program_options + Boost::regex + Boost::system + Boost::url ) From 0f4fc49ab920b7c985aeb322c30f51e61d64708d Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Tue, 29 Apr 2025 23:51:16 +0000 Subject: [PATCH 18/38] Rename boost tasks to remove prefix --- exports/taskfiles/utils/boost.yaml | 14 +++++++------- taskfiles/boost/tests.yaml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index 6d038dd..a24bf3a 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -14,7 +14,7 @@ tasks: # @param {string} INSTALL_PREFIX Path prefix of where the project should be installed. # @param {string[]} TARGETS Target libraries to build. # @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the generate command. - boost-generate: + generate: internal: true dir: "{{.SOURCE_DIR}}" cmds: @@ -35,7 +35,7 @@ tasks: # @param {int} [JOBS] The maximum number of concurrent processes to use when building. If # omitted, the b2 default number is used. Before 1.76.0, the number was 1. Since 1.76.0, the # default is the number of cores. - boost-build: + build: internal: true dir: "{{.SOURCE_DIR}}" cmds: @@ -58,7 +58,7 @@ tasks: # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings # file should be stored. # @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the install command. - boost-install: + install: internal: true dir: "{{.SOURCE_DIR}}" cmds: @@ -105,7 +105,7 @@ tasks: # @param {string[]} [INSTALL_ARGS] Any additional arguments to pass to the install command. # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings # file should be stored. - boost-download-and-install: + download-and-install: internal: true label: "{{.TASK}}:{{.URL}}-{{.INSTALL_PREFIX}}" vars: @@ -143,7 +143,7 @@ tasks: OUTPUT_DIR: "{{.SOURCE_DIR}}" URL: "{{.URL}}" cmds: - - task: "boost-generate" + - task: "generate" vars: SOURCE_DIR: "{{.SOURCE_DIR}}" INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" @@ -151,13 +151,13 @@ tasks: ref: ".TARGETS" EXTRA_ARGS: ref: ".GEN_ARGS" - - task: "boost-build" + - task: "build" vars: SOURCE_DIR: "{{.SOURCE_DIR}}" JOBS: "{{.JOBS}}" EXTRA_ARGS: ref: ".BUILD_ARGS" - - task: "boost-install" + - task: "install" vars: SOURCE_DIR: "{{.SOURCE_DIR}}" INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index ecc3ba4..84f871b 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -49,7 +49,7 @@ tasks: internal: true run: "once" cmds: - - task: "utils:boost:boost-download-and-install" + - task: "utils:boost:download-and-install" vars: WORK_DIR: "{{.G_DEPS_DIR}}/boost" FILE_SHA256: "2128a4c96862b5c0970c1e34d76b1d57e4a1016b80df85ad39667f30b1deba26" From dabe6b2f85fd9997eab531b0e640b6acab48d804 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 30 Apr 2025 01:09:19 +0000 Subject: [PATCH 19/38] Add simple tests for each library --- taskfiles/boost/boost-test.cpp | 85 ++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/taskfiles/boost/boost-test.cpp b/taskfiles/boost/boost-test.cpp index beabd01..4a21af0 100644 --- a/taskfiles/boost/boost-test.cpp +++ b/taskfiles/boost/boost-test.cpp @@ -1,12 +1,25 @@ +#include +#include #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include #include #include #include +#include +#include +#include namespace { auto parse_args(int argc, char** argv) -> boost::program_options::variables_map { @@ -24,8 +37,60 @@ auto parse_args(int argc, char** argv) -> boost::program_options::variables_map return variables; } +auto test_filesystem() -> bool { + boost::filesystem::path const path = boost::filesystem::path(__FILE__); + return path.has_parent_path(); +} + +auto test_iostreams() -> bool { + std::string result; + boost::iostreams::filtering_ostream out{boost::iostreams::back_inserter(result)}; + out << "Hello World!"; + out.flush(); + return result == "Hello World!"; +} + +constexpr int cWaitTime = 10; + +auto test_process() -> bool { + boost::asio::io_context io_context; + boost::process::v2::process process{io_context, "/bin/true", {}}; + std::future result = process.async_wait(boost::asio::use_future); + io_context.run_for(std::chrono::milliseconds(cWaitTime)); + if (std::future_status::ready != result.wait_for(std::chrono::milliseconds(cWaitTime))) { + return false; + } + return 0 == result.get(); +} + +constexpr std::string_view cRegex = "(\\d{4}[- ]){3}\\d{4}"; +constexpr std::string_view cMatch = "1234-5678 9012-3456"; + +auto test_regex() -> bool { + boost::regex const e{std::string{cRegex}}; + return boost::regex_match(std::string{cMatch}, e); +} + +constexpr std::string_view cUrl + = "https://user:pass@example.com:443/path/to/" + "my%2dfile.txt?id=42&name=John%20Doe+Jingleheimer%2DSchmidt#page%20anchor"; + +auto test_url() -> bool { + boost::system::result result = boost::urls::parse_uri(cUrl); + if (result.has_error()) { + return false; + } + boost::urls::url_view url_view = result.value(); + return "example.com" == url_view.encoded_host_address(); +} + constexpr int cCmdArgParseErr = 1; constexpr int cSizeErr = 2; +constexpr int cFileSystemErr = 3; +constexpr int cIoStreamsErr = 4; +constexpr int cProcessErr = 5; +constexpr int cRegexErr = 6; +constexpr int cUrlErr = 7; } // namespace auto main(int argc, char** argv) -> int { @@ -58,5 +123,25 @@ auto main(int argc, char** argv) -> int { return cSizeErr; } + if (false == test_filesystem()) { + return cFileSystemErr; + } + + if (false == test_iostreams()) { + return cIoStreamsErr; + } + + if (false == test_process()) { + return cProcessErr; + } + + if (false == test_regex()) { + return cRegexErr; + } + + if (false == test_url()) { + return cUrlErr; + } + return 0; } From 92f1d44d1b85b0fd304c0be9b01ff526758f7420 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 30 Apr 2025 01:56:56 +0000 Subject: [PATCH 20/38] Fix clang tidy --- taskfiles/boost/boost-test.cpp | 44 +++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/taskfiles/boost/boost-test.cpp b/taskfiles/boost/boost-test.cpp index 4a21af0..b2eb3ce 100644 --- a/taskfiles/boost/boost-test.cpp +++ b/taskfiles/boost/boost-test.cpp @@ -1,9 +1,9 @@ #include +#include #include #include #include #include -#include #include #include @@ -17,7 +17,9 @@ #include #include #include -#include +#include // IWYU pragma: keep +#include +#include #include #include @@ -44,31 +46,45 @@ auto test_filesystem() -> bool { auto test_iostreams() -> bool { std::string result; - boost::iostreams::filtering_ostream out{boost::iostreams::back_inserter(result)}; - out << "Hello World!"; - out.flush(); + try { + boost::iostreams::filtering_ostream out{boost::iostreams::back_inserter(result)}; + out << "Hello World!"; + out.flush(); + } catch (std::exception const& e) { + return false; + } return result == "Hello World!"; } constexpr int cWaitTime = 10; auto test_process() -> bool { - boost::asio::io_context io_context; - boost::process::v2::process process{io_context, "/bin/true", {}}; - std::future result = process.async_wait(boost::asio::use_future); - io_context.run_for(std::chrono::milliseconds(cWaitTime)); - if (std::future_status::ready != result.wait_for(std::chrono::milliseconds(cWaitTime))) { + try { + boost::asio::io_context io_context; + boost::process::v2::process process{io_context, "/bin/true", {}}; + std::future result = process.async_wait(boost::asio::use_future); + io_context.run_for(std::chrono::milliseconds(cWaitTime)); + if (std::future_status::ready != result.wait_for(std::chrono::milliseconds(cWaitTime))) { + return false; + } + return 0 == result.get(); + } catch (std::exception const& e) { return false; } - return 0 == result.get(); } constexpr std::string_view cRegex = "(\\d{4}[- ]){3}\\d{4}"; constexpr std::string_view cMatch = "1234-5678 9012-3456"; auto test_regex() -> bool { - boost::regex const e{std::string{cRegex}}; - return boost::regex_match(std::string{cMatch}, e); + try { + // NOLINTNEXTLINE(misc-include-cleaner) + boost::regex const e{std::string{cRegex}}; + // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) + return boost::regex_match(std::string{cMatch}, e); + } catch (std::exception const& e) { + return false; + } } constexpr std::string_view cUrl @@ -80,7 +96,7 @@ auto test_url() -> bool { if (result.has_error()) { return false; } - boost::urls::url_view url_view = result.value(); + boost::urls::url_view const url_view = result.value(); return "example.com" == url_view.encoded_host_address(); } From 9ae22310c62e741aa8f69ec0c521777c6df2886c Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 30 Apr 2025 01:58:12 +0000 Subject: [PATCH 21/38] Fix clang tidy --- taskfiles/boost/{boost-test.cpp => test_boost.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename taskfiles/boost/{boost-test.cpp => test_boost.cpp} (100%) diff --git a/taskfiles/boost/boost-test.cpp b/taskfiles/boost/test_boost.cpp similarity index 100% rename from taskfiles/boost/boost-test.cpp rename to taskfiles/boost/test_boost.cpp From 77428149fc9640f19c5aec2f8cc08f9bed5c0596 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 30 Apr 2025 01:58:58 +0000 Subject: [PATCH 22/38] Fix file name change --- taskfiles/boost/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index bb9e8b5..6d6b9ff 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -31,7 +31,7 @@ endif() add_executable(boost-test) target_compile_features(boost-test PRIVATE cxx_std_20) -target_sources(boost-test PRIVATE boost-test.cpp) +target_sources(boost-test PRIVATE test_boost.cpp) target_link_libraries( boost-test PRIVATE From c8e016292caae93b543978af086ff0b8127e491a Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Fri, 2 May 2025 13:18:37 -0400 Subject: [PATCH 23/38] Do not clean up after tests. Co-authored-by: davidlion --- taskfiles/boost/tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index 84f871b..75cfe67 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -31,7 +31,6 @@ tasks: vars: BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" - task: "run-boost-test" - - task: "clean" clean: internal: true From 863b9c3a892023d52577028b65f16b1a11d4f6e9 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Fri, 2 May 2025 17:30:39 +0000 Subject: [PATCH 24/38] Make including depdencies install cmake optional --- taskfiles/boost/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index 6d6b9ff..5ecbe4e 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -9,7 +9,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS FORCE ) -include("build/deps/cmake-settings/all.cmake") +if(PROJECT_IS_TOP_LEVEL) + # Include dependency setting if the project isn't being included as a subproject. + # NOTE: We mark the file as optional not required if the user happens to have the dependencies + # installed already + include("build/deps/cmake-settings/all.cmake" OPTIONAL) +endif() find_package( Boost From 66670cf8c1b879069f3d3e4b128a806e3a5e6d6e Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Fri, 2 May 2025 13:39:57 -0400 Subject: [PATCH 25/38] Use InitCap for boost cmake package name. Co-authored-by: davidlion --- exports/taskfiles/utils/boost.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index a24bf3a..98f7269 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -70,7 +70,7 @@ tasks: {{- end}} - >- {{- if .CMAKE_SETTINGS_DIR}} - echo "set(BOOST_ROOT + echo "set(Boost_ROOT \"{{.INSTALL_PREFIX}}\" CACHE PATH \"Package root for boost.\" From a5ea408e569c7ebc173961b366ea357b09556547 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Fri, 2 May 2025 13:44:03 -0400 Subject: [PATCH 26/38] Use top level build directory for boost tests. Co-authored-by: davidlion --- taskfiles/boost/tests.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index 75cfe67..9b0cd03 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -4,15 +4,12 @@ includes: utils: "../../exports/taskfiles/utils/utils.yaml" vars: - G_BUILD_DIR: "{{.TASKFILE_DIR}}/build" - G_DEPS_DIR: "{{.G_BUILD_DIR}}/deps" - G_DEPS_CMAKE_SETTINGS_DIR: "{{.G_DEPS_DIR}}/cmake-settings" - G_DEPS_CMAKE_SETTINGS_FILE: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}/settings.cmake" + G_BOOST_BUILD_DIR: "{{.ROOT_DIR}}/build" + G_BOOST_DEPS_DIR: "{{.G_BOOST_BUILD_DIR}}/deps" + G_BOOST_DEPS_CMAKE_SETTINGS_DIR: "{{.G_BOOST_DEPS_DIR}}/cmake-settings" - G_BUILD_BOOST_TEST_DIR: "{{.G_BUILD_DIR}}/boost-test" - G_BOOST_TEST_CMAKE_CACHE: "{{.G_BUILD_BOOST_TEST_DIR}}/CMakeCache.txt" - G_BOOST_TEST_COMPILE_COMMANDS_DB: "{{.G_BUILD_BOOST_TEST_DIR}}/compile_commands.json" - G_BOOST_TEST_EXECUTABLE: "{{.G_BUILD_BOOST_TEST_DIR}}/boost-test" + G_BOOST_TEST_BUILD_DIR: "{{.G_BOOST_BUILD_DIR}}/boost-test" + G_BOOST_TEST_EXECUTABLE: "{{.G_BOOST_TEST_BUILD_DIR}}/boost-test" tasks: test: From 7163bc85756d137835c9e569869dd5a36d06c64a Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Fri, 2 May 2025 18:11:01 +0000 Subject: [PATCH 27/38] Fix the directory in taskfiles and cmake --- taskfiles/boost/CMakeLists.txt | 5 ++++- taskfiles/boost/tests.yaml | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index 5ecbe4e..49cff0b 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -13,7 +13,10 @@ if(PROJECT_IS_TOP_LEVEL) # Include dependency setting if the project isn't being included as a subproject. # NOTE: We mark the file as optional not required if the user happens to have the dependencies # installed already - include("build/deps/cmake-settings/all.cmake" OPTIONAL) + include( + "${CMAKE_CURRENT_SOURCE_DIR}/../../build/deps/cmake-settings/all.cmake" + OPTIONAL + ) endif() find_package( diff --git a/taskfiles/boost/tests.yaml b/taskfiles/boost/tests.yaml index 9b0cd03..f6544bc 100644 --- a/taskfiles/boost/tests.yaml +++ b/taskfiles/boost/tests.yaml @@ -18,28 +18,28 @@ tasks: - task: "init" - task: "utils:cmake:install-deps-and-generate-settings" vars: - CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + CMAKE_SETTINGS_DIR: "{{.G_BOOST_DEPS_CMAKE_SETTINGS_DIR}}" DEP_TASK: "install-boost" - task: "utils:cmake:generate" vars: SOURCE_DIR: "{{.TASKFILE_DIR}}" - BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" + BUILD_DIR: "{{.G_BOOST_TEST_BUILD_DIR}}" - task: "utils:cmake:build" vars: - BUILD_DIR: "{{.G_BUILD_BOOST_TEST_DIR}}" + BUILD_DIR: "{{.G_BOOST_TEST_BUILD_DIR}}" - task: "run-boost-test" clean: internal: true cmds: - - "rm -rf {{.G_BUILD_DIR}}" + - "rm -rf {{.G_BOOST_TEST_BUILD_DIR}}" init: internal: true silent: true run: "once" cmds: - - "mkdir -p {{.G_BUILD_DIR}}" + - "mkdir -p {{.G_BOOST_TEST_BUILD_DIR}}" install-boost: internal: true @@ -47,11 +47,11 @@ tasks: cmds: - task: "utils:boost:download-and-install" vars: - WORK_DIR: "{{.G_DEPS_DIR}}/boost" + WORK_DIR: "{{.G_BOOST_DEPS_DIR}}/boost" FILE_SHA256: "2128a4c96862b5c0970c1e34d76b1d57e4a1016b80df85ad39667f30b1deba26" URL: "https://github.com/boostorg/boost/releases/download/boost-1.86.0/\ boost-1.86.0-b2-nodocs.tar.gz" - CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + CMAKE_SETTINGS_DIR: "{{.G_BOOST_DEPS_CMAKE_SETTINGS_DIR}}" TARGETS: - "filesystem" - "headers" From 99f5616c27adbebd473c86d1457aa1e04a41d282 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 5 May 2025 19:25:19 +0000 Subject: [PATCH 28/38] Add requried and default arguments for boost --- exports/taskfiles/utils/boost.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index 98f7269..469d54b 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -17,6 +17,11 @@ tasks: generate: internal: true dir: "{{.SOURCE_DIR}}" + vars: + EXTRA_ARGS: + ref: "default (list) .EXTRA_ARGS" + requires: + vars: ["SOURCE_DIR", "INSTALL_PREFIX", "TARGETS"] cmds: - >- ./bootstrap.sh @@ -38,6 +43,13 @@ tasks: build: internal: true dir: "{{.SOURCE_DIR}}" + vars: + EXTRA_ARGS: + ref: "default (list) .EXTRA_ARGS" + JOBS: >- + {{default "" .JOBS}} + requires: + vars: ["SOURCE_DIR"] cmds: - >- ./b2 @@ -61,6 +73,15 @@ tasks: install: internal: true dir: "{{.SOURCE_DIR}}" + vars: + EXTRA_ARGS: + ref: "default (list) .EXTRA_ARGS" + INSTALL_PREFIX: >- + {{default "" .INSTALL_PREFIX}} + CMAKE_SETTINGS_DIR: >- + {{default "" .CMAKE_SETTINGS_DIR}} + requires: + vars: ["SOURCE_DIR", "INSTALL_PREFIX"] cmds: - >- ./b2 From 8e9b7a03008c1c78a8f104efb255ac847f0535bd Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 5 May 2025 20:00:04 +0000 Subject: [PATCH 29/38] Fix cmake comment about including optional files --- taskfiles/boost/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taskfiles/boost/CMakeLists.txt b/taskfiles/boost/CMakeLists.txt index 49cff0b..fd3e1aa 100644 --- a/taskfiles/boost/CMakeLists.txt +++ b/taskfiles/boost/CMakeLists.txt @@ -10,9 +10,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ) if(PROJECT_IS_TOP_LEVEL) - # Include dependency setting if the project isn't being included as a subproject. - # NOTE: We mark the file as optional not required if the user happens to have the dependencies - # installed already + # Include dependency settings if the project isn't being included as a subproject. + # NOTE: We mark the file optional because if the user happens to have the dependencies + # installed, this file is not necessary. include( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/deps/cmake-settings/all.cmake" OPTIONAL From d80421709c0584bc12f6990048c78de8354e429c Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 5 May 2025 16:09:53 -0400 Subject: [PATCH 30/38] Use heredoc to write to cmake file. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- exports/taskfiles/utils/boost.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index 469d54b..7b3ebe4 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -91,13 +91,10 @@ tasks: {{- end}} - >- {{- if .CMAKE_SETTINGS_DIR}} - echo "set(Boost_ROOT - \"{{.INSTALL_PREFIX}}\" - CACHE PATH - \"Package root for boost.\" - )" >> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" + cat <> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" + set(Boost_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Package root for boost.") + EOF {{- end}} - # Downloads boost from `URL` and installs boost. # # General parameters From b7302f7d445a0495a769d69a14295cfb716ca719 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 5 May 2025 20:24:46 +0000 Subject: [PATCH 31/38] Fix heredoc --- exports/taskfiles/utils/boost.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index 7b3ebe4..2ec8a45 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -89,11 +89,11 @@ tasks: {{- range .EXTRA_ARGS}} "{{.}}" {{- end}} - - >- + - | {{- if .CMAKE_SETTINGS_DIR}} - cat <> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" - set(Boost_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Package root for boost.") - EOF + cat <> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" + set(Boost_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Package root for boost.") + EOF {{- end}} # Downloads boost from `URL` and installs boost. # From 31749645a1e8e4bde8c1c46d4af1e7a5871bc869 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Mon, 5 May 2025 20:27:01 +0000 Subject: [PATCH 32/38] Replace ROOT_DIR with TASK_DIR and mark TARGET optional in docstring --- exports/taskfiles/utils/boost.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index 2ec8a45..f01534e 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -110,7 +110,7 @@ tasks: # Boost generate parameters # @param {string} [INSTALL_PREFIX={{.WORK_DIR}}/boost-install] Path prefix of where the project # should be installed. - # @param {string[]} TARGETS Target libraries to build. + # @param {string[]} [TARGETS] Target libraries to build. # @param {string[]} [GEN_ARGS] Any additional arguments to pass to the generate command. # # Boost build parameters @@ -129,7 +129,7 @@ tasks: vars: # General parameters WORK_DIR: >- - {{default .ROOT_DIR .WORK_DIR}} + {{default .TASK_DIR .WORK_DIR}} SOURCE_DIR: >- {{default (printf "%s/boost-src" .WORK_DIR) .SOURCE_DIR}} From 9468ae1b657f590e1519dbb350144e31d0c9f55b Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 7 May 2025 14:21:12 -0400 Subject: [PATCH 33/38] Add indentation for shell in yaml. Co-authored-by: davidlion --- exports/taskfiles/utils/boost.yaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index f01534e..a8991b3 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -29,7 +29,7 @@ tasks: --exec-prefix="{{.INSTALL_PREFIX}}" --with-libraries={{(join "," .TARGETS)}} {{- range .EXTRA_ARGS}} - "{{.}}" + "{{.}}" {{- end}} # Runs the b2 build step for boost. The caller must have previously called `generate` on @@ -54,10 +54,10 @@ tasks: - >- ./b2 {{- range .EXTRA_ARGS}} - "{{.}}" + "{{.}}" {{- end}} {{- if .JOBS}} - "-j{{.JOBS}}" + "-j{{.JOBS}}" {{- end}} # Runs the b2 install step for boost. The caller must have previously called `build` on @@ -87,13 +87,15 @@ tasks: ./b2 install {{- range .EXTRA_ARGS}} - "{{.}}" + "{{.}}" {{- end}} - - | + - >- {{- if .CMAKE_SETTINGS_DIR}} - cat <> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" - set(Boost_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Package root for boost.") - EOF + echo "set(Boost_ROOT + \"{{.INSTALL_PREFIX}}\" + CACHE PATH + \"Package root for boost.\" + )" >> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake" {{- end}} # Downloads boost from `URL` and installs boost. # From 49b06838b59946c978bc3606ab1cdcdcd315de6b Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 7 May 2025 14:22:23 -0400 Subject: [PATCH 34/38] Remove `misc-include-cleaner`. Co-authored-by: davidlion --- taskfiles/boost/test_boost.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/taskfiles/boost/test_boost.cpp b/taskfiles/boost/test_boost.cpp index b2eb3ce..c8d4a4a 100644 --- a/taskfiles/boost/test_boost.cpp +++ b/taskfiles/boost/test_boost.cpp @@ -31,7 +31,6 @@ auto parse_args(int argc, char** argv) -> boost::program_options::variables_map desc.add_options()("size", boost::program_options::value(), "Size of the string."); boost::program_options::variables_map variables; boost::program_options::store( - // NOLINTNEXTLINE(misc-include-cleaner) boost::program_options::parse_command_line(argc, argv, desc), variables ); @@ -78,7 +77,6 @@ constexpr std::string_view cMatch = "1234-5678 9012-3456"; auto test_regex() -> bool { try { - // NOLINTNEXTLINE(misc-include-cleaner) boost::regex const e{std::string{cRegex}}; // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) return boost::regex_match(std::string{cMatch}, e); From e30937182c3f50aba9278a31b257025a1b340bbe Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 7 May 2025 18:41:40 +0000 Subject: [PATCH 35/38] Use recommended boost headers instead of exact boost headers --- taskfiles/boost/test_boost.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/taskfiles/boost/test_boost.cpp b/taskfiles/boost/test_boost.cpp index c8d4a4a..7db6780 100644 --- a/taskfiles/boost/test_boost.cpp +++ b/taskfiles/boost/test_boost.cpp @@ -5,23 +5,16 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include // IWYU pragma: keep -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace { auto parse_args(int argc, char** argv) -> boost::program_options::variables_map { From 67146a9aa3498c2f5f31722dcdb27993cf7ccf8b Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 7 May 2025 18:44:51 +0000 Subject: [PATCH 36/38] Improve error message according to coderabbit --- taskfiles/boost/test_boost.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/taskfiles/boost/test_boost.cpp b/taskfiles/boost/test_boost.cpp index 7db6780..bf3d9b9 100644 --- a/taskfiles/boost/test_boost.cpp +++ b/taskfiles/boost/test_boost.cpp @@ -126,7 +126,8 @@ auto main(int argc, char** argv) -> int { } if (size != input.size()) { - std::cerr << "Error: Size mismatch. Expected " << input.size() << ", got " << size << ".\n"; + std::cerr << "Error: Size mismatch. Expected size: " << size + << ", actual string length: " << input.size() << ".\n"; return cSizeErr; } From fb06df145c2a1ce7402488bc90cad1f60ae252a9 Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 7 May 2025 18:51:48 +0000 Subject: [PATCH 37/38] Use ROOT_DIR instead of TASK_DIR --- exports/taskfiles/utils/boost.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index a8991b3..3de30fc 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -100,7 +100,7 @@ tasks: # Downloads boost from `URL` and installs boost. # # General parameters - # @param {string} [WORK_DIR={{.TASK_DIR}}] Base directory to store the install and src + # @param {string} [WORK_DIR={{.ROOT_DIR}}] Base directory to store the install and src # directories inside. # @param {string} [SOURCE_DIR={{.WORK_DIR}}/boost-src] Directory in which to extract the tar # file. @@ -131,7 +131,7 @@ tasks: vars: # General parameters WORK_DIR: >- - {{default .TASK_DIR .WORK_DIR}} + {{default .ROOT_DIR .WORK_DIR}} SOURCE_DIR: >- {{default (printf "%s/boost-src" .WORK_DIR) .SOURCE_DIR}} From ac05a93990c286768d8b58256b0564c4c8aff60c Mon Sep 17 00:00:00 2001 From: sitaowang1998 Date: Wed, 7 May 2025 14:54:42 -0400 Subject: [PATCH 38/38] Add error messages for each tests. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- taskfiles/boost/test_boost.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/taskfiles/boost/test_boost.cpp b/taskfiles/boost/test_boost.cpp index bf3d9b9..7391b32 100644 --- a/taskfiles/boost/test_boost.cpp +++ b/taskfiles/boost/test_boost.cpp @@ -132,22 +132,27 @@ auto main(int argc, char** argv) -> int { } if (false == test_filesystem()) { + std::cerr << "Error: Filesystem test failed. Could not verify parent path.\n"; return cFileSystemErr; } if (false == test_iostreams()) { + std::cerr << "Error: IoStreams test failed. Could not write and verify string.\n"; return cIoStreamsErr; } if (false == test_process()) { + std::cerr << "Error: Process test failed. Could not execute process or verify exit code.\n"; return cProcessErr; } if (false == test_regex()) { + std::cerr << "Error: Regex test failed. Could not match pattern.\n"; return cRegexErr; } if (false == test_url()) { + std::cerr << "Error: URL test failed. Could not parse URL or verify host.\n"; return cUrlErr; }