Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waf add submodulesclean #25196

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ list some basic and more used commands as example.
Cleaning the build is very often not necessary and discouraged. We do
incremental builds reducing the build time by orders of magnitude.

If submodules are failing to be synchronized, `submodulesync` may be used
to resync the submodules. This is usually necessary when shifting development
between stable releases or a stable release and the master branch.

In some some cases `submodule_force_clean` may be necessary. This removes all submodules and then performs a `submodulesync`. (Note whitelisted modules like esp_idf is not removed.)

* **Upload or install**

Expand Down
2 changes: 2 additions & 0 deletions Tools/completion/bash/_waf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ _waf()
opts+=" configure"
opts+=" clean"
opts+=" distclean"
opts+=" submodule_force_clean"
opts+=" submodulesync"

# Prevent word reuse TODO: add -vvv case
lim=$((COMP_CWORD - 1))
Expand Down
4 changes: 3 additions & 1 deletion Tools/completion/zsh/_waf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ _waf_cmds() {
'build:executes the build' \
'configure:configures the project' \
'clean:cleans the project' \
'distclean:removes build folders and data'
'distclean:removes build folders and data' \
'submodule_force_clean:removes all submodules, then checkouts all current submodules and synchronizes them' \
'submodulesync:checkouts all current submodules and synchronizes them'
)
_describe -t commands 'command' commands "$@" && ret=0
}
Expand Down
23 changes: 23 additions & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@ def _set_build_context_variant(board):
continue
c.variant = board

# Remove all submodules and then sync
@conf
def submodule_force_clean(ctx):
whitelist = {
'COLCON_IGNORE',
'esp_idf',
}

# Get all items in the modules folder
module_list = os.scandir('modules')

# Delete all directories except those in the whitelist
for module in module_list:
if (module.is_dir()) and (module.name not in whitelist):
shutil.rmtree(module)

submodulesync(ctx)

# run Tools/gittools/submodule-sync.sh to sync submodules
@conf
def submodulesync(ctx):
subprocess.call(['Tools/gittools/submodule-sync.sh'])

def init(ctx):
# Generate Task List, so that VS Code extension can keep track
# of changes to possible build targets
Expand Down