Skip to content

Conversation

Bill-hbrhbr
Copy link
Contributor

@Bill-hbrhbr Bill-hbrhbr commented Oct 5, 2025

Description

When multiple projects in the same repository (e.g., core and spider) share dependencies, they may each need to generate their own CMake settings files while installing shared libraries only once.

Currently, the install-deps-and-generate-settings task couples installation and CMake settings generation. This means:

  • We must re-run the full generate → build → install pipeline multiple times just to produce separate CMake settings files.
  • Shared dependencies risk race conditions, since multiple projects may reinstall or recreate the same CMAKE_SETTINGS_DIR concurrently.

This PR decouples CMake settings generation from the installation process:

  • Introduces a standalone task for generating settings files.
  • Leaves it to downstream users (e.g., clp, spider) to decide how to bundle installation and settings generation.
  • Allows libraries to be installed once while generating multiple project-specific settings files safely and efficiently.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Works with the example usage case here: y-scope/clp#1384

Summary by CodeRabbit

  • New Features
    • Added tasks to generate and aggregate CMake settings.
    • Introduced helpers to reset directories and files for clean builds.
  • Refactor
    • Reworked install workflows to simplify setup and reduce configuration surface.
    • Standardized build, generate, install, and source paths with consistent branding.
  • Chores
    • Normalized branding across comments and parameter descriptions.
    • Improved task run conditions to avoid unnecessary re-execution.
  • Documentation
    • Updated inline docs and examples to reflect branding and workflow changes.

Copy link
Contributor

coderabbitai bot commented Oct 5, 2025

Walkthrough

Updates Boost taskfile paths to capitalized “Boost” directories and removes CMAKE_SETTINGS_DIR usage. Introduces misc helpers to reset dirs/files. Adds CMake tasks to generate and aggregate settings, reworks install flows to delegate settings generation via install-deps-and-generate-settings and generate-cmake-settings, and standardizes run: when_changed on relevant tasks.

Changes

Cohort / File(s) Summary of Changes
Boost task updates
exports/taskfiles/utils/boost.yaml
Capitalizes directory names (Boost-*) and updates defaults/paths; removes CMAKE_SETTINGS_DIR handling and CMake settings write logic; sets run: when_changed on download/extract-related tasks; updates comments/param docs.
CMake install and settings flow
exports/taskfiles/utils/cmake.yaml
Adds public task generate-cmake-settings; reworks install and install-remote-tar to drop CMAKE_SETTINGS_DIR/CMAKE_PACKAGE_NAME from public interface; adds install-deps-and-generate-settings to reset settings dir/file and aggregate per-dep settings; integrates misc:reset-dir and misc:reset-file; updates wiring and notes.
Misc helpers
exports/taskfiles/utils/misc.yaml
Adds internal tasks reset-dir (DIR_PATH) and reset-file (FILE_PATH) to delete and recreate targets; no existing task modifications.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev
  participant CI as CI/Invoker
  participant CMake as utils/cmake:install-deps-and-generate-settings
  participant MiscD as utils/misc:reset-dir
  participant MiscF as utils/misc:reset-file
  participant Dep as DEP_TASK (per dependency)
  participant Gen as utils/cmake:generate-cmake-settings
  participant FS as Settings FS

  Dev->>CI: Run install-deps-and-generate-settings<br/>(CMAKE_SETTINGS_DIR, CMAKE_SETTINGS_FILE)
  CI->>CMake: Invoke with DEP_TASK, PACKAGE_INSTALL_PREFIX, etc.
  CMake->>MiscD: Reset CMAKE_SETTINGS_DIR
  MiscD-->>CMake: Dir ready
  CMake->>MiscF: Reset CMAKE_SETTINGS_FILE
  MiscF-->>CMake: File ready
  loop For each dependency
    CMake->>Dep: Run with CMAKE_SETTINGS_DIR + CMAKE_SETTINGS_FILE
    Dep->>Gen: generate-cmake-settings(CMAKE_PACKAGE_NAME, DIR, PREFIX)
    Gen->>FS: Append CMAKE_PACKAGE_NAME_ROOT entry
  end
Loading
sequenceDiagram
  autonumber
  participant Inv as Task Runner
  participant Boost as utils/boost tasks
  participant DL as download-and-extract-tar
  participant Build as build-and-install

  Inv->>Boost: download-and-install (no CMAKE_SETTINGS_DIR)
  Boost->>DL: download-and-extract-tar
  Note right of DL: run: when_changed<br/>tracks up-to-date by labels
  DL-->>Boost: Sources ready
  Boost->>Build: build-and-install (uses Boost-* dirs)
  Build-->>Inv: Installed to Boost-install
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change of decoupling CMake settings generation from library installation to support multi-project dependency builds, clearly conveying the intent and scope without unnecessary detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Bill-hbrhbr Bill-hbrhbr linked an issue Oct 7, 2025 that may be closed by this pull request
@Bill-hbrhbr Bill-hbrhbr changed the title fix: fix cmake settings fix: Split CMake settings generation from library install tasks to allow support for multi-project separate CMake settings. Oct 7, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title fix: Split CMake settings generation from library install tasks to allow support for multi-project separate CMake settings. fix(cmake): Split CMake settings generation from library install tasks to support multi-project dependency builds. Oct 7, 2025
@Bill-hbrhbr Bill-hbrhbr marked this pull request as ready for review October 7, 2025 11:12
@Bill-hbrhbr Bill-hbrhbr requested a review from a team as a code owner October 7, 2025 11:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
exports/taskfiles/utils/cmake.yaml (2)

35-44: Restore the conditional emission of --parallel

build now always passes --parallel "" when .JOBS is unset. CMake treats the empty string as an invalid jobs count and aborts. Please gate the flag so it is only emitted when a numeric value is provided.

-        --parallel "{{.JOBS}}"
+        {{- if .JOBS}}
+        --parallel "{{.JOBS}}"
+        {{- end}}

257-262: Skip the include loop when no package settings exist

If DEP_TASK produces no *.cmake files (for example, a dependency only installs artefacts), the glob remains literal and you end up appending include(".../*.cmake"), which later causes CMake to fail. Guard the loop with compgen (or enable nullglob) so you only emit includes for real files.

-      - |-
-        for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do
-          if [[ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]]; then
-            echo "include(\"$file\")" >> "{{.CMAKE_SETTINGS_FILE}}";
-          fi
-        done
+      - |-
+        if compgen -G "{{.CMAKE_SETTINGS_DIR}}/"'*.cmake' > /dev/null; then
+          for file in {{.CMAKE_SETTINGS_DIR}}/*.cmake; do
+            if [[ "$file" != "{{.CMAKE_SETTINGS_FILE}}" ]]; then
+              echo "include(\"$file\")" >> "{{.CMAKE_SETTINGS_FILE}}";
+            fi
+          done
+        fi
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1202b9 and 73d6e96.

📒 Files selected for processing (3)
  • exports/taskfiles/utils/boost.yaml (3 hunks)
  • exports/taskfiles/utils/cmake.yaml (7 hunks)
  • exports/taskfiles/utils/misc.yaml (1 hunks)

Comment on lines +45 to +65
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"
cmds:
- "rm -rf {{.DIR_PATH}}"
- "mkdir -p {{.DIR_PATH}}"

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 {{.FILE_PATH}}"
- "mkdir -p $(dirname -- {{.FILE_PATH}})"
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Quote the reset commands to avoid clobbering the wrong paths

Both reset-dir and reset-file call rm -rf/mkdir -p without quoting the expanded variables. If the caller passes a path containing spaces or glob tokens, the shell will split the argument and you could delete or recreate unintended locations. Please add the usual quoting around the templated paths and around the dirname call.

-      - "rm -rf {{.DIR_PATH}}"
-      - "mkdir -p {{.DIR_PATH}}"
+      - 'rm -rf "{{.DIR_PATH}}"'
+      - 'mkdir -p "{{.DIR_PATH}}"'
...
-      - "rm -rf {{.FILE_PATH}}"
-      - "mkdir -p $(dirname -- {{.FILE_PATH}})"
+      - 'rm -rf "{{.FILE_PATH}}"'
+      - 'mkdir -p "$(dirname -- "{{.FILE_PATH}}")"'

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In exports/taskfiles/utils/misc.yaml around lines 45 to 65 the rm -rf and mkdir
-p commands use unquoted templated paths which allows word-splitting and glob
expansion (dangerous for paths with spaces or glob chars); fix by quoting the
templated path variables in both commands (e.g. quote {{.DIR_PATH}} and
{{.FILE_PATH}}) and also quote the dirname expression used for the file case,
and include the standard "--" sentinel to dirname to safely handle names
beginning with "-" so the shell receives a single, quoted path argument.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bill-hbrhbr This makes sense to me. Could you fix this by applying what create-venv is doing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

ref: ".CMAKE_INSTALL_ARGS"
INSTALL_PREFIX: "{{.INSTALL_PREFIX}}"

# Create a settings file in CMAKE_SETTINGS_DIR, containing a `{{.CMAKE_PACKAGE_NAME}}_ROOT` CMake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Create a settings file in CMAKE_SETTINGS_DIR, containing a `{{.CMAKE_PACKAGE_NAME}}_ROOT` CMake
# Creates a settings file in `CMAKE_SETTINGS_DIR`, containing a `{{.CMAKE_PACKAGE_NAME}}_ROOT` CMake

Comment on lines -230 to -231
# - 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this is a little misleading. We should say that the task must take two arguments CMAKE_SETTINGS_DIRS and CMAKE_SETTINGS_FILE, and cannot have other required arguments.

# - 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From previous part of the docstring and the task's requires, it looks like CMAKE_SETTINGS_DIR is not optional.

Comment on lines +45 to +65
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"
cmds:
- "rm -rf {{.DIR_PATH}}"
- "mkdir -p {{.DIR_PATH}}"

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 {{.FILE_PATH}}"
- "mkdir -p $(dirname -- {{.FILE_PATH}})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bill-hbrhbr This makes sense to me. Could you fix this by applying what create-venv is doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better support for dependencies shared between multiple projects
2 participants