Skip to content

Commit 4035abb

Browse files
committed
Makefile: Add a overwrite_canary_if_coreboot_git function, and have all dev cycle helpers call it
Signed-off-by: Thierry Laurion <[email protected]>
1 parent 8e38d81 commit 4035abb

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,25 @@ $(board_build)/$(CB_OUTPUT_BASENAME)-gpg-injected.rom: $(board_build)/$(CB_OUTPU
894894
"$(board_build)/$(CB_OUTPUT_FILE_GPG_INJ)" "$(PUBKEY_ASC)"
895895

896896

897+
897898
#Dev cycles helpers:
899+
900+
# Helper function to overwrite coreboot git repo's .canary file with a bogus commit (.canary checked for matching commit on build)
901+
# TODO: Implement a cleaner solution to ensure files created by patches are properly deleted instead of requiring manual intervention.
902+
define overwrite_canary_if_coreboot_git
903+
@echo "Checking for coreboot directory: build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)"
904+
if [ -d "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)" ] && \
905+
[ -d "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.git" ]; then \
906+
echo "INFO: Recreating .canary file for 'build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)' with placeholder."; \
907+
echo BOGUS_COMMIT_ID > "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.canary"; \
908+
echo "NOTE: If a patch fails to apply, some files might need to be deleted manually to resolve conflicts."; \
909+
else \
910+
echo "INFO: Coreboot directory or .git not found, skipping .canary overwrite."; \
911+
fi
912+
endef
913+
898914
real.clean:
915+
@echo "Cleaning build artifacts and install directories, leaving crossgcc intact."
899916
for dir in \
900917
$(module_dirs) \
901918
$(kernel_headers) \
@@ -905,15 +922,19 @@ real.clean:
905922
fi; \
906923
done
907924
cd install && rm -rf -- *
925+
$(call overwrite_canary_if_coreboot_git)
926+
908927
real.gitclean:
909928
@echo "Cleaning the repository using Git ignore file as a base..."
910929
@echo "This will wipe everything not in the Git tree, but keep downloaded coreboot forks (detected as Git repos)."
911930
git clean -fxd
931+
$(call overwrite_canary_if_coreboot_git)
912932

913933
real.gitclean_keep_packages:
914934
@echo "Cleaning the repository using Git ignore file as a base..."
915935
@echo "This will wipe everything not in the Git tree, but keep the 'packages' directory."
916936
git clean -fxd -e "packages"
937+
$(call overwrite_canary_if_coreboot_git)
917938

918939
real.remove_canary_files-extract_patch_rebuild_what_changed:
919940
@echo "Removing 'canary' files to force Heads to restart building board configurations..."
@@ -925,9 +946,11 @@ real.remove_canary_files-extract_patch_rebuild_what_changed:
925946
@echo "Only a minimal time is needed for rebuilding, which is also good for your SSD."
926947
@echo "*** USE THIS APPROACH FIRST ***"
927948
find ./build/ -type f -name ".canary" -print -delete
928-
find ./install/*/* -print -exec rm -rf {} +
949+
find ./install/*/* -print -exec rm -rf {} + 2>/dev/null || true
950+
$(call overwrite_canary_if_coreboot_git)
929951

930952
real.gitclean_keep_packages_and_build:
931953
@echo "Cleaning the repository using Git ignore file as a base..."
932954
@echo "This will wipe everything not in the Git tree, but keep the 'packages' and 'build' directories."
933955
git clean -fxd -e "packages" -e "build"
956+
$(call overwrite_canary_if_coreboot_git)

0 commit comments

Comments
 (0)