feat(tools): add -j/--jobs option to idf.py (IDFGH-18013)#18871
Conversation
|
Hi @nebkat. Thank you for the contribution. LGTM in general. One request about where the option is declared.
It also breaks the environment variable case. The option ends up registered both at root level and on each action, so click resolves CI sets Could you move the option to {
'names': ['-j', '--jobs'],
'help': 'Number of parallel build jobs passed to the build tool (Ninja or Make).',
'envvar': 'IDF_PY_BUILD_JOBS',
'type': click.IntRange(min=1),
'default': None,
},The visible difference for users is that |
Add a global -j/--jobs option to idf.py that sets the number of parallel build jobs passed to the underlying build tool. Previously parallelism was only configurable via the IDF_PY_BUILD_JOBS environment variable, and only for the Ninja generator. The option applies to both Ninja and Make and defaults to IDF_PY_BUILD_JOBS when not given, so the environment variable keeps working as before. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit db6b310. Configure here.
| 'envvar': 'IDF_PY_BUILD_JOBS', | ||
| 'type': click.IntRange(min=1), | ||
| 'default': None, | ||
| }, |
There was a problem hiding this comment.
Post-subcommand jobs option rejected
Medium Severity
-j/--jobs is declared only in root options with default scope, so Click accepts it before a subcommand but not after. The change is described as a global option like -D that works as idf.py build -j 6, but that form fails with an unknown-option error because the flag is never attached to subcommands or given scope: 'global'/'shared'.
Reviewed by Cursor Bugbot for commit db6b310. Configure here.
fhrbata
left a comment
There was a problem hiding this comment.
LGTM, thank you for the contribution!
|
Hi @nebkat, thanks again, and for turning around the earlier review so quickly. The change itself looks good to me. There's just one small CI thing to sort out before we merge. The The clean fix: the # from your feat/idfpy-jobs branch, restore the file to upstream esp-idf master
git checkout upstream/master -- tools/idf_py_actions/global_options.py
git commit --amend --no-edit
git push --force-with-lease(Adjust Would you be able to do that? The reason I'm asking rather than just patching it on our side: we merge contributions through our internal repo and then sync back to GitHub. If we merge your commit unchanged, GitHub automatically marks this PR as Merged and it's recorded as your contribution. If we have to modify your commit ourselves, even a one-line revert, that automatic link breaks and we'd have to close this PR manually instead, so it would not show as Merged or count toward your contributions. I'd rather you keep the credit, hence the small ask. If you'd prefer not to, no problem at all, just let me know and I'll fix it on our side during the merge. In that case the PR would end up Closed rather than Merged, but the change will still land. Thanks! |
|
LGTM. |


Description
Add a global
-j/--jobsoption toidf.pythat sets the number of parallel build jobs passed to the underlying build tool (Ninja or Make).Previously, build parallelism could only be configured via the
IDF_PY_BUILD_JOBSenvironment variable, and that value was only honored for the Ninja generator — the Make generator always used a hardcoded-j <cpu_count + 2>.Usage:
Being a root-level option (like
-Gand--ccache), it must appear before the subcommand (idf.py -j 6 build), at most once.Testing
Behavior was verified by exercising the real modules directly:
click.IntRange(min=1).IDF_PY_BUILD_JOBSset,-jno longer conflicts with the env var (the option is now root-level only, not duplicated onto every subcommand).Checklist
Before submitting a Pull Request, please ensure the following:
Note
Low Risk
Documentation and idf.py build-wrapper changes only; behavior is additive and preserves existing env-based configuration for Ninja.
Overview
Adds a global
idf.py -j/--jobsoption (withIDF_PY_BUILD_JOBSas the default when the flag is omitted) to set how many parallel jobs are passed to Ninja or Make.run_target()now resolves job count in one place: CLI/env value first, otherwise the generator’sdefault_jobs(Make keepscpu_count + 2; Ninja stays unpinned when unset). Make no longer bakes-jinto its static generator command, avoiding duplicate-jflags when overridden.English and Chinese build-system docs describe
idf.py -j 6 buildand the env var.Reviewed by Cursor Bugbot for commit db6b310. Bugbot is set up for automated code reviews on this repo. Configure here.