From 60e443690617ea2046eebbdeae32379d36191c84 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Sun, 5 Oct 2025 13:20:16 -0400 Subject: [PATCH 1/7] fix cmake settings --- exports/taskfiles/utils/cmake.yaml | 17 +++++++++++++---- exports/taskfiles/utils/misc.yaml | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/exports/taskfiles/utils/cmake.yaml b/exports/taskfiles/utils/cmake.yaml index 63ee963..d2bb606 100644 --- a/exports/taskfiles/utils/cmake.yaml +++ b/exports/taskfiles/utils/cmake.yaml @@ -1,6 +1,7 @@ version: "3" includes: + misc: "misc.yaml" remote: "remote.yaml" set: ["u", "pipefail"] @@ -227,8 +228,7 @@ tasks: # @param {string} CMAKE_SETTINGS_DIR The directory where CMake settings files should be stored. # @param {string} DEP_TASK The task to run that will install all dependencies. NOTE: # - The task name must be qualified from the root of the project. - # - The task must not require any arguments (to use a task with arguments create a new task that - # calls the original with any arguments set). + # - The task takes in CMAKE_SETTINGS_DIR and CMAKE_SETTINGS_FILE as optional arguments. # - Dependencies must write their settings file to CMAKE_SETTINGS_DIR in order to have them # included in CMAKE_SETTINGS_FILE. # @param {string} [CMAKE_SETTINGS_FILE={{.CMAKE_SETTINGS_DIR}}/all.cmake] The file in which to @@ -242,12 +242,21 @@ tasks: requires: vars: ["CMAKE_SETTINGS_DIR", "DEP_TASK"] cmds: - - "rm -rf {{.CMAKE_SETTINGS_DIR}}" - - "mkdir -p {{.CMAKE_SETTINGS_DIR}}" + - task: "misc:reset-dir" + vars: + DIR_PATH: "{{.CMAKE_SETTINGS_DIR}}" + - task: "misc:reset-file" + vars: + DIR_PATH: "{{.CMAKE_SETTINGS_FILE}}" # NOTE: We prefix DEP_TASK with `::` assuming that this taskfile is included through the # `utils` taskfile, and that in turn is included in the user's taskfile. - task: "::{{.DEP_TASK}}" + vars: + CMAKE_SETTINGS_DIR: {{.CMAKE_SETTINGS_DIR}} + CMAKE_SETTINGS_FILE: {{.CMAKE_SETTINGS_FILE}} + + # Combine CMake settings - |- for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do if [[ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]]; then diff --git a/exports/taskfiles/utils/misc.yaml b/exports/taskfiles/utils/misc.yaml index d78dd95..d770f69 100644 --- a/exports/taskfiles/utils/misc.yaml +++ b/exports/taskfiles/utils/misc.yaml @@ -41,3 +41,23 @@ tasks: . "{{.OUTPUT_DIR}}/bin/activate" pip3 install --upgrade pip pip3 install --upgrade -r "{{.REQUIREMENTS_FILE}}" + + reset-dir: + desc: "Removes the given directory and create it empty. Runs once per directory path." + internal: true + requires: + vars: ["DIR_PATH"] + run: "when_changed" + cmds: + - "rm -rf {{.DIR_PATH}}" + - "mkdir -p {{.DIR_PATH}}" + + reset-file: + desc: "Removes the given file. Runs once per file path." + internal: true + requires: + vars: ["FILE_PATH"] + run: "when_changed" + cmds: + - "rm -rf {{.DIR_PATH}}" + - "mkdir -p $(dirname -- {{.FILE_PATH}})" From 2e05b9f7a25f4c89229fcc0493fd06667225e7e6 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Sun, 5 Oct 2025 13:35:13 -0400 Subject: [PATCH 2/7] Add fixxing quote --- exports/taskfiles/utils/cmake.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exports/taskfiles/utils/cmake.yaml b/exports/taskfiles/utils/cmake.yaml index d2bb606..01922c5 100644 --- a/exports/taskfiles/utils/cmake.yaml +++ b/exports/taskfiles/utils/cmake.yaml @@ -253,8 +253,8 @@ tasks: # `utils` taskfile, and that in turn is included in the user's taskfile. - task: "::{{.DEP_TASK}}" vars: - CMAKE_SETTINGS_DIR: {{.CMAKE_SETTINGS_DIR}} - CMAKE_SETTINGS_FILE: {{.CMAKE_SETTINGS_FILE}} + CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}" + CMAKE_SETTINGS_FILE: "{{.CMAKE_SETTINGS_FILE}}" # Combine CMake settings - |- From 025e0704144642de47f6c9cf87226abe4e351b8d Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Sun, 5 Oct 2025 13:44:05 -0400 Subject: [PATCH 3/7] typo fix --- exports/taskfiles/utils/cmake.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exports/taskfiles/utils/cmake.yaml b/exports/taskfiles/utils/cmake.yaml index 01922c5..62d0845 100644 --- a/exports/taskfiles/utils/cmake.yaml +++ b/exports/taskfiles/utils/cmake.yaml @@ -247,7 +247,7 @@ tasks: DIR_PATH: "{{.CMAKE_SETTINGS_DIR}}" - task: "misc:reset-file" vars: - DIR_PATH: "{{.CMAKE_SETTINGS_FILE}}" + FILE_PATH: "{{.CMAKE_SETTINGS_FILE}}" # NOTE: We prefix DEP_TASK with `::` assuming that this taskfile is included through the # `utils` taskfile, and that in turn is included in the user's taskfile. @@ -256,7 +256,6 @@ tasks: CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}" CMAKE_SETTINGS_FILE: "{{.CMAKE_SETTINGS_FILE}}" - # Combine CMake settings - |- for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do if [[ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]]; then From 00bb47b997ec7bf0bb670cbfd4f04958ffaf2315 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 6 Oct 2025 05:09:47 -0400 Subject: [PATCH 4/7] Add labels for task that runs when changed --- exports/taskfiles/utils/misc.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exports/taskfiles/utils/misc.yaml b/exports/taskfiles/utils/misc.yaml index d770f69..e61cea1 100644 --- a/exports/taskfiles/utils/misc.yaml +++ b/exports/taskfiles/utils/misc.yaml @@ -45,6 +45,7 @@ tasks: reset-dir: desc: "Removes the given directory and create it empty. Runs once per directory path." internal: true + label: "{{.TASK}}:{{.DIR_PATH}}" requires: vars: ["DIR_PATH"] run: "when_changed" @@ -55,9 +56,10 @@ tasks: reset-file: desc: "Removes the given file. Runs once per file path." internal: true + label: "{{.TASK}}:{{.FILE_PATH}}" requires: vars: ["FILE_PATH"] run: "when_changed" cmds: - - "rm -rf {{.DIR_PATH}}" + - "rm -rf {{.FILE_PATH}}" - "mkdir -p $(dirname -- {{.FILE_PATH}})" From 1126ba68d466a520823846497dfb51ba0062b644 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 6 Oct 2025 06:33:42 -0400 Subject: [PATCH 5/7] Split out generate cmake settings from the install task --- exports/taskfiles/utils/cmake.yaml | 73 ++++++++++++++---------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/exports/taskfiles/utils/cmake.yaml b/exports/taskfiles/utils/cmake.yaml index 62d0845..7afd22b 100644 --- a/exports/taskfiles/utils/cmake.yaml +++ b/exports/taskfiles/utils/cmake.yaml @@ -9,8 +9,10 @@ shopt: ["globstar"] tasks: # Runs the CMake build step for the given build directory. The caller must have previously called - # `generate` on `BUILD_DIR` for this task to succeed. We purposely omit `sources` and `generates` - # as we defer to `cmake` to decide whether it should perform any actions. + # `generate` on `BUILD_DIR` for this task to succeed. + # + # NOTE: We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it + # should perform any actions. # # @param {string} BUILD_DIR Directory containing the generated build system to use. # @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the build command. @@ -61,9 +63,10 @@ tasks: ref: ".EXTRA_ARGS" TARGETS: ["clean"] - # Runs the CMake generate step for the given source and build directories. We purposely omit - # `sources` and `generates` as we defer to `cmake` to decide whether it should perform any - # actions. + # Runs the CMake generate step for the given source and build directories. + # + # NOTE: We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it + # should perform any actions. # # @param {string} BUILD_DIR Directory in which to generate the build system. # @param {string} SOURCE_DIR Project source directory containing the CMakeLists.txt file. @@ -86,38 +89,22 @@ tasks: {{- end}} # Runs the CMake install step for the given build directory. The caller must have previously - # called `build` on `BUILD_DIR` for this task to succeed. If `CMAKE_SETTINGS_DIR` is set, a - # settings file will be created in that directory, containing a `{{.CMAKE_PACKAGE_NAME}}_ROOT` - # CMake variable that points to `INSTALL_PREFIX`. + # called `build` on `BUILD_DIR` for this task to succeed. # # NOTE: We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it # should perform any actions. # # @param {string} BUILD_DIR Directory containing the completed build to use. # @param {string} INSTALL_PREFIX Path prefix of where the project should be installed. - # @param {string} [CMAKE_PACKAGE_NAME] CMake project name (used in directory names and the CMake - # settings file). Required if `CMAKE_SETTINGS_DIR` is set. - # @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. install: internal: true label: "{{.TASK}}:{{.BUILD_DIR}}-{{.INSTALL_PREFIX}}-{{.EXTRA_ARGS}}" vars: - CMAKE_SETTINGS_DIR: >- - {{default "" .CMAKE_SETTINGS_DIR}} EXTRA_ARGS: ref: "default (list) .EXTRA_ARGS" requires: vars: ["BUILD_DIR", "INSTALL_PREFIX"] - preconditions: - - sh: >- - {{if .CMAKE_SETTINGS_DIR}} - {{not (empty .CMAKE_PACKAGE_NAME)}} - {{end}} - msg: |- - CMAKE_PACKAGE_NAME must be set if CMAKE_SETTINGS_DIR is set. - CMAKE_SETTINGS_DIR: {{.CMAKE_SETTINGS_DIR}} cmds: - >- cmake @@ -126,18 +113,12 @@ tasks: {{- range .EXTRA_ARGS}} {{.}} {{- end}} - - >- - {{- if .CMAKE_SETTINGS_DIR}} - echo "set({{.CMAKE_PACKAGE_NAME}}_ROOT - \"{{.INSTALL_PREFIX}}\" - CACHE PATH - \"Package root for {{.CMAKE_PACKAGE_NAME}}.\" - )" >> "{{.CMAKE_SETTINGS_DIR}}/{{.CMAKE_PACKAGE_NAME}}.cmake" - {{- end}} # Downloads a CMake project tar file from `TAR_URL` and then generates, builds, and installs the - # project. We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it - # should perform any actions. However, the download and extraction will be skipped if unnecessary. + # project. + # + # NOTE: We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it + # should perform any actions. # # Required parameters # @param {string} CMAKE_PACKAGE_NAME CMake package name. @@ -155,8 +136,6 @@ tasks: # command. # @param {int} [CMAKE_JOBS] The maximum number of concurrent processes to use when building. If # omitted, the native build tool's default number is used. See `man cmake`. - # @param {string} [CMAKE_SETTINGS_DIR] The directory where the project's CMake settings file - # should be stored. # @param {string} [CMAKE_SOURCE_DIR=.] The path, within the extraction directory, containing the # project's top level CMakeLists.txt. # @param {string[]} [CMAKE_TARGETS] A list of specific targets to build instead of the default @@ -174,8 +153,6 @@ tasks: ref: "default (list) .CMAKE_INSTALL_ARGS" CMAKE_JOBS: >- {{default "" .CMAKE_JOBS}} - CMAKE_SETTINGS_DIR: >- - {{default "" .CMAKE_SETTINGS_DIR}} CMAKE_SOURCE_DIR: >- {{default "." .CMAKE_SOURCE_DIR}} CMAKE_TARGETS: @@ -212,12 +189,32 @@ tasks: - task: "install" vars: BUILD_DIR: "{{.BUILD_DIR}}" - CMAKE_PACKAGE_NAME: "{{.CMAKE_PACKAGE_NAME}}" - CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}" EXTRA_ARGS: ref: ".CMAKE_INSTALL_ARGS" INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + # Create a settings file in CMAKE_SETTINGS_DIR, containing a `{{.CMAKE_PACKAGE_NAME}}_ROOT` CMake + # variable that points to `PACKAGE_INSTALL_PREFIX`. + # + # Required parameters + # @param {string} CMAKE_PACKAGE_NAME CMake package name. + # @param {string} CMAKE_SETTINGS_DIR The directory where the project's CMake settings file should + # be stored. + # @param {string} PACKAGE_INSTALL_PREFIX The location where the project is installed. + generate-cmake-settings: + internal: true + label: "{{.TASK}}:{{.CMAKE_PACKAGE_NAME}}-{{.CMAKE_SETTINGS_DIR}}-{{.PACKAGE_INSTALL_PREFIX}}" + requires: + vars: ["CMAKE_PACKAGE_NAME", "CMAKE_SETTINGS_DIR", "PACKAGE_INSTALL_PREFIX"] + cmds: + - "mkdir -p {{.CMAKE_SETTINGS_DIR}}" + - >- + echo "set({{.CMAKE_PACKAGE_NAME}}_ROOT + \"{{.PACKAGE_INSTALL_PREFIX}}\" + CACHE PATH + \"Package root for {{.CMAKE_PACKAGE_NAME}}.\" + )" >> "{{.CMAKE_SETTINGS_DIR}}/{{.CMAKE_PACKAGE_NAME}}.cmake" + # Sets up all CMake dependencies for a project by: # # 1. creating a directory to contain all CMake settings files (CMAKE_SETTINGS_DIR). From 022fe92906ed030812277fe7d044d1335ffb5de2 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 6 Oct 2025 11:52:39 -0400 Subject: [PATCH 6/7] Boost rework --- exports/taskfiles/utils/boost.yaml | 51 ++++++++++++------------------ 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/exports/taskfiles/utils/boost.yaml b/exports/taskfiles/utils/boost.yaml index 33fec0a..3caa239 100644 --- a/exports/taskfiles/utils/boost.yaml +++ b/exports/taskfiles/utils/boost.yaml @@ -8,7 +8,7 @@ set: ["u", "pipefail"] shopt: ["globstar"] tasks: - # Generates `GENERATE_DIR` by copying `SOURCE_DIR` and then running boost's bootstrap step. + # Generates `GENERATE_DIR` by copying `SOURCE_DIR` and then running Boost's bootstrap step. # # @param {string} SOURCE_DIR Project source directory. # @param {string} GENERATE_DIR Directory in which to generate `b2` and the build configuration. @@ -54,19 +54,17 @@ tasks: INCLUDE_PATTERNS: - "{{.GENERATE_DIR}}" - # Runs boost's b2 build and install step, and creates a CMake settings file. The caller must have + # Runs Boost's b2 build and install step, and creates a CMake settings file. The caller must have # previously called `generate` on `SOURCE_DIR` (to produce the `GENERATE_DIR`) for this task to # succeed. # - # @param {string} GENERATE_DIR Directory containing boost's source and build files. - # @param {string} BUILD_DIR Directory in which to build boost. + # @param {string} GENERATE_DIR Directory containing Boost's source and build files. + # @param {string} BUILD_DIR Directory in which to build Boost. # @param {string} INSTALL_PREFIX Path prefix of where the project should be installed. # @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. - # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings - # file should be stored. build-and-install: internal: true vars: @@ -89,21 +87,13 @@ tasks: "-j{{.JOBS}}" {{- end}}; popd; - - >- - {{- 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. + # Downloads Boost from `URL` and installs Boost. # # General parameters # @param {string} [WORK_DIR={{.ROOT_DIR}}] Base directory in which to store the source, generate, # build, and install directories. - # @param {string} [SOURCE_DIR={{.WORK_DIR}}/boost-src] Directory in which to extract the tar + # @param {string} [SOURCE_DIR={{.WORK_DIR}}/Boost-src] Directory in which to extract the tar # file. # # Download parameters @@ -111,41 +101,40 @@ tasks: # @param {string} URL # # Boost generate parameters - # @param {string} [GENERATE_DIR={{.WORK_DIR}}/boost-generate] Directory in which to generate the + # @param {string} [GENERATE_DIR={{.WORK_DIR}}/Boost-generate] Directory in which to generate the # project build files. - # @param {string} [GENERATE_CHECKSUM_FILE={{.WORK_DIR}}/boost-generate.md5] Checksum file for the + # @param {string} [GENERATE_CHECKSUM_FILE={{.WORK_DIR}}/Boost-generate.md5] Checksum file for the # generate directory. - # @param {string} [INSTALL_PREFIX={{.WORK_DIR}}/boost-install] Path prefix of where the project + # @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[]} [GENERATE_ARGS] Any additional arguments to pass to the generate command. # # Boost build-and-install parameters - # @param {string} [BUILD_DIR={{.WORK_DIR}}/boost-build] Directory in which to build the project. + # @param {string} [BUILD_DIR={{.WORK_DIR}}/Boost-build] Directory in which to build the project. # @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_AND_INSTALL_ARGS] Any additional arguments to pass to boost's build + # @param {string[]} [BUILD_AND_INSTALL_ARGS] Any additional arguments to pass to Boost's build # and install command. - # @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings - # file should be stored. download-and-install: internal: true label: "{{.TASK}}:{{.URL}}-{{.INSTALL_PREFIX}}" vars: # General parameters + BOOST_PACKAGE_NAME: "Boost" WORK_DIR: >- {{default .ROOT_DIR .WORK_DIR}} SOURCE_DIR: >- - {{default (printf "%s/boost-src" .WORK_DIR) .SOURCE_DIR}} + {{default (printf "%s/%s-src" .WORK_DIR .BOOST_PACKAGE_NAME) .SOURCE_DIR}} # Boost generate parameters GENERATE_DIR: >- - {{default (printf "%s/boost-generate" .WORK_DIR) .GENERATE_DIR}} + {{default (printf "%s/%s-generate" .WORK_DIR .BOOST_PACKAGE_NAME) .GENERATE_DIR}} GENERATE_CHECKSUM_FILE: >- - {{default (printf "%s/boost-generate.md5" .WORK_DIR) .GENERATE_CHECKSUM_FILE}} + {{default (printf "%s.md5" .GENERATE_DIR) .GENERATE_CHECKSUM_FILE}} INSTALL_PREFIX: >- - {{default (printf "%s/boost-install" .WORK_DIR) .INSTALL_PREFIX}} + {{default (printf "%s/%s-install" .WORK_DIR .BOOST_PACKAGE_NAME) .INSTALL_PREFIX}} TARGETS: ref: "default (list) .TARGETS" GENERATE_ARGS: @@ -153,15 +142,16 @@ tasks: # Boost build-and-install parameters BUILD_DIR: >- - {{default (printf "%s/boost-build" .WORK_DIR) .BUILD_DIR}} + {{default (printf "%s/%s-build" .WORK_DIR .BOOST_PACKAGE_NAME) .BUILD_DIR}} BUILD_AND_INSTALL_ARGS: ref: "default (list) .BUILD_AND_INSTALL_ARGS" JOBS: >- {{default "" .JOBS}} - CMAKE_SETTINGS_DIR: >- - {{default "" .CMAKE_SETTINGS_DIR}} requires: vars: ["FILE_SHA256", "URL"] + # TODO: use install directory checksum to properly decide if the task is up-to-date. Right now, + # the task gets re-run for each unique task label. + run: "when_changed" deps: - task: "remote:download-and-extract-tar" vars: @@ -187,4 +177,3 @@ tasks: EXTRA_ARGS: ref: ".BUILD_AND_INSTALL_ARGS" JOBS: "{{.JOBS}}" - CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}" From 73d6e964d1432dd5f5d7a9c3d945437d689834cc Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 6 Oct 2025 11:55:55 -0400 Subject: [PATCH 7/7] Avoid concurrent cmake file writing --- exports/taskfiles/utils/cmake.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/exports/taskfiles/utils/cmake.yaml b/exports/taskfiles/utils/cmake.yaml index 7afd22b..13709f3 100644 --- a/exports/taskfiles/utils/cmake.yaml +++ b/exports/taskfiles/utils/cmake.yaml @@ -206,6 +206,7 @@ tasks: label: "{{.TASK}}:{{.CMAKE_PACKAGE_NAME}}-{{.CMAKE_SETTINGS_DIR}}-{{.PACKAGE_INSTALL_PREFIX}}" requires: vars: ["CMAKE_PACKAGE_NAME", "CMAKE_SETTINGS_DIR", "PACKAGE_INSTALL_PREFIX"] + run: "when_changed" cmds: - "mkdir -p {{.CMAKE_SETTINGS_DIR}}" - >-