Skip to content

Add git_submodules flag to control dependency submodule cloning - #314

Merged
micprog merged 3 commits into
masterfrom
submodule-flag
Jun 16, 2026
Merged

micprog merged 3 commits into
masterfrom
submodule-flag

Conversation

@fischeti

@fischeti fischeti commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds a git_submodules option to control whether Bender clones the Git submodules of dependencies.

  • Config field git_submodules (default true), mirroring the existing git_lfs option — OR-merged across config layers, validated with unwrap_or(true).
  • CLI flag --git-submodules <true|false> (env BENDER_GIT_SUBMODULES), modelled on --git-throttle. It overrides the configured value in either direction.
  • When disabled, the git submodule update --init --recursive step is skipped during checkout (along with its per-submodule progress bar).

Why

git submodule update --init --recursive currently runs unconditionally on every checkout that has a .gitmodules file, and it is frequently the slowest part of the initial dependency fetch. In top-level hardware projects, dependency submodules often hold software or tooling that is irrelevant to the build, so cloning them is wasted work. This gives users an escape hatch — persistently via config, or per-invocation via the flag (e.g. in CI).

The default stays true, so existing behavior is unchanged unless explicitly opted out.

Notes

  • The flag intentionally takes a value rather than being a presence-only switch (like --no-progress). This keeps the door open to later widening the accepted values — e.g. selecting specific dependencies — without a breaking change to the CLI surface. The config field stays a plain bool for now; no enum is introduced yet.
  • Per-dependency / selective submodule control was deliberately not implemented here. The cleaner long-term home for that granularity is producer-side (a dependency declaring which submodule paths it needs), since the consumer generally lacks that knowledge and it doesn't scale to transitive deps.
  • Docs updated: book/src/configuration.md (config field reference) and book/src/dependencies.md (Submodules section).

🤖 Generated with Claude Code

fischeti added a commit that referenced this pull request Jun 9, 2026
Co-Authored-By: Claude Opus 4.8 <[email protected]>

@micprog micprog 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.

I understand the frustration!

From separate conversations, we ideally add a configuration in the Bender.yml indicating which submodules are required, and which are not, on a per-dependency basis, possibly with additional target specification. In this instance, I like the approach to get at least something going. It would be great if we could have a command or option to force the checkout/update of all submodules in all dependencies, just in case we checked out without submodules and now need to get some/all. I think this is a good flag/subcommand for the checkout command, let me know what you think. To avoid breaking setups, I see an option to cleanly get all submodules as a prerequisite to this feature. Other than that, LGTM 👍

fischeti added a commit that referenced this pull request Jun 16, 2026
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@fischeti

Copy link
Copy Markdown
Contributor Author

I agree with the approach of specifying this on the side of the dependency, since the maintainer is more aware of which submodules are actually required. As discussed, the format would be something like:

git_submodules:
  - sw/deps/printf
  - target: test
    submodule: sw/deps/cva6-sdk
    recursive: false # default: true
    shallow: false # default: true?
 # not updated if no specified explicitely
 # - pd/deps/ihp-130-pdk 

With this functionality in place, it would make sense to reverse the default to not clone i.e. --git-submodule false but keep it as a global switch (to avoid completely breaking setups).

I would tackle this in a separate PR. In that sense, this PR is ready as it is and it also does not include any breaking changes since the default stays the same and can be released as a patch version. Then, the following modifications would be released as a breaking release.

Let me know what you think!

@fischeti
fischeti marked this pull request as ready for review June 16, 2026 08:45
fischeti and others added 2 commits June 16, 2026 11:03
Cloning dependency submodules with `git submodule update --init
--recursive` runs unconditionally on every checkout and is frequently
the slowest part of fetching dependencies. The submodules often hold
software or tooling that is irrelevant to the hardware build.

Add a `git_submodules` config field (default true), mirroring the
existing `git_lfs` option, plus a value-taking `--git-submodules
<true|false>` CLI flag (env `BENDER_GIT_SUBMODULES`) modelled on
`--git-throttle`. The flag overrides the configured value in either
direction. When disabled, the submodule update is skipped during
checkout.

The flag takes a value rather than being a presence-only switch so the
accepted values can later widen (e.g. to select specific dependencies)
without a breaking change to the CLI surface.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>

@micprog micprog 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.

I added a warning to help out in getting the submodule back in case the flag was inadvertently added, but now LGTM 👍

@fischeti

Copy link
Copy Markdown
Contributor Author

I added a warning to help out in getting the submodule back in case the flag was inadvertently added, but now LGTM 👍

LGTM!

@micprog
micprog merged commit 3d41edd into master Jun 16, 2026
18 checks passed
@micprog
micprog deleted the submodule-flag branch June 16, 2026 12:20
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.

2 participants