Makefile: When cloning a repo from Git, update submodules correctly

When cloning a repo from Git, actually change to the repo directory to
check out the submodules as well.  Without the -C <dir>, the submodule
checkout happened in the Heads repo itself, which has no submodules.

This is important for coreboot being built in CI.  Without this, the
coreboot submodules will be checked out automatically by the coreboot
build system during the build, meaning they will not be in the
prepped module cache.

A trade-off though is that at this point, we don't know what submodules
are actually needed - we will clone some that are not needed.  coreboot
knows to skip some submodules during the build if they are not needed.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2024-07-24 15:54:18 -04:00
parent 0b494fea09
commit a2876a26a1
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114

View File

@ -392,7 +392,7 @@ define define_module =
$(build)/$($1_base_dir)/.canary: FORCE
if [ ! -e "$$@" ]; then \
git clone $($1_repo) "$(build)/$($1_base_dir)"; \
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && git submodule update --init --checkout; \
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && git -C "$(build)/$($1_base_dir)" submodule update --init --checkout; \
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@"; \
elif [ "$$$$(cat "$$@")" != '$($1_repo)|$($1_commit_hash)' ]; then \
echo "Switching $1 to $($1_repo) at $($1_commit_hash)" && \