diff --git a/Makefile b/Makefile index 8f089db2..271dd4e8 100644 --- a/Makefile +++ b/Makefile @@ -894,8 +894,25 @@ $(board_build)/$(CB_OUTPUT_BASENAME)-gpg-injected.rom: $(board_build)/$(CB_OUTPU "$(board_build)/$(CB_OUTPUT_FILE_GPG_INJ)" "$(PUBKEY_ASC)" + #Dev cycles helpers: + +# Helper function to overwrite coreboot git repo's .canary file with a bogus commit (.canary checked for matching commit on build) +# TODO: Implement a cleaner solution to ensure files created by patches are properly deleted instead of requiring manual intervention. +define overwrite_canary_if_coreboot_git + @echo "Checking for coreboot directory: build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)" + if [ -d "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)" ] && \ + [ -d "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.git" ]; then \ + echo "INFO: Recreating .canary file for 'build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)' with placeholder."; \ + echo BOGUS_COMMIT_ID > "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.canary"; \ + echo "NOTE: If a patch fails to apply, some files might need to be deleted manually to resolve conflicts."; \ + else \ + echo "INFO: Coreboot directory or .git not found, skipping .canary overwrite."; \ + fi +endef + real.clean: + @echo "Cleaning build artifacts and install directories, leaving crossgcc intact." for dir in \ $(module_dirs) \ $(kernel_headers) \ @@ -905,15 +922,19 @@ real.clean: fi; \ done cd install && rm -rf -- * + $(call overwrite_canary_if_coreboot_git) + real.gitclean: @echo "Cleaning the repository using Git ignore file as a base..." @echo "This will wipe everything not in the Git tree, but keep downloaded coreboot forks (detected as Git repos)." git clean -fxd + $(call overwrite_canary_if_coreboot_git) real.gitclean_keep_packages: @echo "Cleaning the repository using Git ignore file as a base..." @echo "This will wipe everything not in the Git tree, but keep the 'packages' directory." git clean -fxd -e "packages" + $(call overwrite_canary_if_coreboot_git) real.remove_canary_files-extract_patch_rebuild_what_changed: @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: @echo "Only a minimal time is needed for rebuilding, which is also good for your SSD." @echo "*** USE THIS APPROACH FIRST ***" find ./build/ -type f -name ".canary" -print -delete - find ./install/*/* -print -exec rm -rf {} + + find ./install/*/* -print -exec rm -rf {} + 2>/dev/null || true + $(call overwrite_canary_if_coreboot_git) real.gitclean_keep_packages_and_build: @echo "Cleaning the repository using Git ignore file as a base..." @echo "This will wipe everything not in the Git tree, but keep the 'packages' and 'build' directories." git clean -fxd -e "packages" -e "build" + $(call overwrite_canary_if_coreboot_git)