Skip to content

chore(taskfiles)!: Split up cmake-config-and-build; Add cmake-clean.#20

Merged
davidlion merged 2 commits into
y-scope:mainfrom
davidlion:cpp-task-update
Feb 12, 2025
Merged

chore(taskfiles)!: Split up cmake-config-and-build; Add cmake-clean.#20
davidlion merged 2 commits into
y-scope:mainfrom
davidlion:cpp-task-update

Conversation

@davidlion

@davidlion davidlion commented Feb 12, 2025

Copy link
Copy Markdown
Member

Description

This PR breaks up cmake-config-and-build into cmake-generate and cmake-build. Additionally, it adds cmake-clean and improves the docstrings for each task.

The notable decisions in our design are:

  • We do not use sources or generates and defer decision making to cmake to ensure expected and reliable behaviour.
  • We leave it up to the user/caller to ensure the proper dependencies between tasks are met (e.g. calling generate before build).
    • Adding dependencies causes a task to require all the arguments of its dependent tasks to be run correctly (i.e. install becomes a superset of build and generate, build becomes a superset of generate). This can lead to unexpected behaviour as a change in any argument could lead to re-generating and re-building the project with different arguments.

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

Tested with various tasks in clp.

Summary by CodeRabbit

  • New Features

    • Introduced a new cmake-clean command to enhance cleaning operations.
    • Expanded command options with EXTRA_ARGS and TARGETS for more flexible build configurations.
  • Chores

    • Updated task definitions and clarified dependencies for improved workflow understanding.

@coderabbitai

coderabbitai Bot commented Feb 12, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update the CMake task definitions in the configuration file. The cmake-config-and-build task is replaced with cmake-build, which now requires a prior run of cmake-generate and accepts new parameters. Additionally, a new cmake-clean task is introduced, and modifications are made to the cmake-generate and cmake-install tasks to include an EXTRA_ARGS parameter. These revisions clarify the task dependencies and parameter expectations for correct workflow execution.

Changes

File Change Summary
taskfiles/.../utils-cmake.yaml • Renamed cmake-config-and-build to cmake-build and updated its signature with EXTRA_ARGS and TARGETS parameters.
• Added new cmake-clean task.
• Updated cmake-generate and cmake-install tasks to include EXTRA_ARGS and clarify dependency on prior cmake-generate execution.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant T as Task Runner

    U->>T: Execute cmake-generate
    U->>T: Execute cmake-build (requires prior cmake-generate)
    U->>T: Execute cmake-install (requires prior cmake-build)
    alt Performing Clean Operation
        U->>T: Execute cmake-clean (requires prior cmake-generate, leverages cmake-build)
    end
Loading

Possibly related PRs

Suggested reviewers

  • kirkrodrigues

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
taskfiles/utils-cmake.yaml (2)

18-18: Consider simplifying the task label.

The label includes all parameters which might show empty values when optional parameters aren't provided. Consider omitting optional parameters from the label or using conditional templating.

-    label: "{{.TASK}}:{{.BUILD_DIR}}-{{.TARGETS}}-{{.EXTRA_ARGS}}"
+    label: "{{.TASK}}:{{.BUILD_DIR}}{{if .TARGETS}}-{{.TARGETS}}{{end}}{{if .EXTRA_ARGS}}-{{.EXTRA_ARGS}}{{end}}"

71-73: Enhance prerequisite documentation.

While the documentation mentions the requirement for cmake-build, it could be more explicit about whether a successful build is required or if just running the build step is sufficient.

-  # Runs the CMake install step for the given build directory. The caller must have previously
-  # called `cmake-build` 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.
+  # Runs the CMake install step for the given build directory. The caller must have previously
+  # successfully completed the `cmake-build` task 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.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c29580c and 52873b3.

📒 Files selected for processing (1)
  • taskfiles/utils-cmake.yaml (1 hunks)
🔇 Additional comments (2)
taskfiles/utils-cmake.yaml (2)

17-17: Verify if this task should be internal.

Since this is a key task in the CMake workflow (as indicated in the PR objectives), consider whether marking it as internal: true might make it harder for users to discover and use directly.


47-47: Verify the ref syntax for default value.

The syntax ref: "default (list) .EXTRA_ARGS" seems unusual. Please verify if this is the correct way to reference default values in Task.

@kirkrodrigues kirkrodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor refactoring.

Comment thread taskfiles/utils-cmake.yaml Outdated
Comment thread taskfiles/utils-cmake.yaml Outdated
Comment thread taskfiles/utils-cmake.yaml Outdated
Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
taskfiles/utils-cmake.yaml (3)

18-18: Consider improving the label format to handle missing optional parameters.

The current label format {{.TASK}}:{{.BUILD_DIR}}-{{.TARGETS}}-{{.EXTRA_ARGS}} might produce awkward labels when TARGETS or EXTRA_ARGS are not provided (e.g., resulting in double hyphens).

Consider using conditional formatting:

-    label: "{{.TASK}}:{{.BUILD_DIR}}-{{.TARGETS}}-{{.EXTRA_ARGS}}"
+    label: >-
+      {{.TASK}}:{{.BUILD_DIR}}
+      {{- if .TARGETS}}-{{.TARGETS}}{{end}}
+      {{- if .EXTRA_ARGS}}-{{.EXTRA_ARGS}}{{end}}

47-47: Clarify the reference syntax for EXTRA_ARGS.

The syntax ref: "default (list) .EXTRA_ARGS" might be unclear to users unfamiliar with the task runner's reference system.

Consider adding a comment explaining the reference syntax or using a more explicit form:

-          ref: "default (list) .EXTRA_ARGS"
+          # Forward any EXTRA_ARGS provided to this task to cmake-build
+          ref: "default (list) .EXTRA_ARGS"

71-90: Consider adding install prefix validation.

While the implementation is correct, it might be helpful to verify that the install prefix is absolute and exists before proceeding with the installation.

Consider adding a validation step:

     cmds:
+      - test -d "{{.INSTALL_PREFIX}}" || mkdir -p "{{.INSTALL_PREFIX}}"
       - >-
         cmake
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52873b3 and b394ef8.

📒 Files selected for processing (1)
  • taskfiles/utils-cmake.yaml (1 hunks)
🔇 Additional comments (1)
taskfiles/utils-cmake.yaml (1)

50-69: Well-structured implementation with clear documentation.

The task effectively handles the new EXTRA_ARGS parameter while maintaining clear documentation about the purposeful omission of sources and generates.

@Bill-hbrhbr

Bill-hbrhbr commented Feb 12, 2025

Copy link
Copy Markdown
Contributor

Changes lgtm. My only concern is that, although not time-consuming, CMake build and install will dump a lot of useless info when source files have not been changed.
Maybe on a higher level we should still use sources and/or generates to guard whether the generate->build->install flow should be run or not (mostly for code that is fixed at a version, rather than those on a development branch).

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.

3 participants