Skip to content

feat: support conditional flags#952

Merged
thesayyn merged 1 commit intomainfrom
conditional_flags
Feb 28, 2026
Merged

feat: support conditional flags#952
thesayyn merged 1 commit intomainfrom
conditional_flags

Conversation

@thesayyn
Copy link
Member

  • Plain strings are always included (backward-compatible)
  • (flag, constraint) tuples are included only when the running Bazel version satisfies the semver constraint
  • Pre-release versions are normalised (8.0.0-rc1 → 8.0.0) so >=8 matches RC builds
  • Invalid constraint strings are a hard error at invocation time

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

ctx.bazel.build() and ctx.bazel.test() now accept (flag, constraint) tuples alongside plain strings in flags and startup_flags.

  ctx.bazel.build(
      "//...",
      flags = [
          "--always_present",
          ("--notmp_sandbox", ">=8"),
          ("--some_legacy_flag", "<7"),
      ],
  )

Test plan

  • New test cases added

@thesayyn
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0904eedbc4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@thesayyn thesayyn merged commit 4630021 into main Feb 28, 2026
2 checks passed
@thesayyn thesayyn deleted the conditional_flags branch February 28, 2026 01:36
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.

1 participant