11version : " 3"
22
33includes :
4+ misc : " misc.yaml"
45 remote : " remote.yaml"
56
67set : ["u", "pipefail"]
@@ -224,6 +225,13 @@ tasks:
224225 # 3. combining each dependency's settings file into a single settings file (CMAKE_SETTINGS_FILE)
225226 # for use inside a CMake project.
226227 #
228+ # This task runs once per unique label, since a project should never repeat the same dependency
229+ # installation workflow (i.e. `DEP_TASK`) within a single `task` invocation.
230+ #
231+ # Additionally, if multiple `DEP_TASK`s share the same `CMAKE_SETTINGS_DIR`, we use helper task
232+ # `misc:make-or-clear-dir` to ensure that the directory is only initialized once, avoiding race
233+ # conditions and ensuring that later tasks do not overwrite progress made by earlier ones.
234+ #
227235 # @param {string} CMAKE_SETTINGS_DIR The directory where CMake settings files should be stored.
228236 # @param {string} DEP_TASK The task to run that will install all dependencies. NOTE:
229237 # - The task name must be qualified from the root of the project.
@@ -241,9 +249,13 @@ tasks:
241249 {{default (printf "%s/all.cmake" .CMAKE_SETTINGS_DIR) .CMAKE_SETTINGS_FILE}}
242250 requires :
243251 vars : ["CMAKE_SETTINGS_DIR", "DEP_TASK"]
252+ run : " when_changed"
244253 cmds :
245- - " rm -rf {{.CMAKE_SETTINGS_DIR}}"
246- - " mkdir -p {{.CMAKE_SETTINGS_DIR}}"
254+ - task : " misc:make-or-clear-dir"
255+ vars :
256+ DIR_PATH : " {{.CMAKE_SETTINGS_DIR}}"
257+ - " mkdir -p '{{dir .CMAKE_SETTINGS_FILE}}'"
258+ - " rm -f '{{.CMAKE_SETTINGS_FILE}}'"
247259
248260 # NOTE: We prefix DEP_TASK with `::` assuming that this taskfile is included through the
249261 # `utils` taskfile, and that in turn is included in the user's taskfile.
0 commit comments