Skip to content

Make bazel command and worker-thread count configurable - #12

Merged
helly25 merged 1 commit into
mainfrom
backport/215-configurable-bazel-and-threads
May 17, 2026
Merged

Make bazel command and worker-thread count configurable#12
helly25 merged 1 commit into
mainfrom
backport/215-configurable-bazel-and-threads

Conversation

@helly25

@helly25 helly25 commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds two macro parameters on refresh_compile_commands:

Parameter Default Purpose
bazel_command "bazel" Path or name of the bazel binary the generated refresh script invokes. Useful when bazel lives under a non-default name (e.g. bazelisk) or an absolute path.
max_threads unset → historical min(32, cpu_count + 4) Worker-pool size for the action-conversion executor.

Wired through _expand_template substitutions; refresh.template.py exposes _bazel() / _threads() helpers and uses them at the three subprocess.run([...'bazel'...]) call sites and at the executor configuration.

Upstream context

Backport of hedronvision#215 (sthornington), reworked slightly:

  • bazel_command is a macro/rule parameter rather than a --define BAZEL_COMMAND=... build var — keeps it explicit per-target and easier to discover.
  • max_threads uses an int attr with 0 sentinel rather than a nullable attr.

Supersedes hedronvision#191 (bazel binary only) per maintainer decision.

Skipped the unrelated print_args.cpp cosmetic rewrite that was bundled with the upstream PR.

Test plan

  • bazel run @hedron_compile_commands//:refresh_all with default args (regression check)
  • Macro target with bazel_command = "bazelisk", run from a non-bazel-on-PATH shell
  • Macro target with max_threads = 1, confirm single-threaded execution

Add two macro parameters on `refresh_compile_commands`:

- `bazel_command`: path or name of the bazel binary used by the generated
  refresh script (defaults to "bazel"). Useful when bazel lives under a
  non-default name (e.g. "bazelisk") or an absolute path.
- `max_threads`: max worker threads for the action conversion pool
  (defaults to the previous heuristic of min(32, cpu_count + 4)).

Plumbed through `_expand_template` substitutions; `refresh.template.py`
exposes `_bazel()` / `_threads()` helpers and uses them at the three
bazel-subprocess call sites and the executor configuration.

Backport of hedronvision#215
(sthornington). Supersedes hedronvision#191 (custom bazel binary only).
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