build: introduce .context marker for distclean after partial builds#3585
Draft
Zepp-Hanzj wants to merge 1 commit into
Draft
build: introduce .context marker for distclean after partial builds#3585Zepp-Hanzj wants to merge 1 commit into
Zepp-Hanzj wants to merge 1 commit into
Conversation
Directory.mk's distclean target only traverses subdirectories that have .built, .depend, or .kconfig markers. When a build fails between the context:: and depend:: phases (e.g. during configure), none of these markers exist, so distclean silently skips the directory — leaving behind unpacked sources, downloaded archives, and generated config files. Fix this by: 1. Adding a .context marker that apps touch at the end of their context:: target when it creates build artefacts. 2. Introducing DISTCLEANSUBDIRS in Directory.mk: a superset of CLEANSUBDIRS that also includes directories carrying .context. The clean:: target keeps using CLEANSUBDIRS (unchanged semantics) while distclean:: now uses DISTCLEANSUBDIRS. 3. Having Application.mk's distclean:: remove .context alongside .built, .depend, and Make.dep. 4. Updating interpreters/python/Makefile to touch .context after unpacking CPython — the original trigger for this fix (issue apache#2895). Fixes apache#2895 Signed-off-by: hanzhijian <hanzhijian@zepp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Directory.mk'sdistcleantarget only traverses subdirectories that have.built,.depend, or.kconfigmarkers. When a build fails between thecontext::anddepend::phases (e.g. during configure), none of these markers exist, sodistcleansilently skips the directory — leaving behind unpacked sources, downloaded archives, and generated config files.This PR fixes this by introducing a
.contextmarker and separating the scopes ofcleananddistclean.Changes
1.
Directory.mk—DISTCLEANSUBDIRSIntroduce a new variable
DISTCLEANSUBDIRS: a superset ofCLEANSUBDIRSthat also includes directories carrying.context:clean::keeps usingCLEANSUBDIRS— only clean compiled artifactsdistclean::now usesDISTCLEANSUBDIRS— also undocontext::work2.
Application.mk— clean.contexton distcleanAdd
$(call DELFILE, .context)to thedistclean::target alongside.built,.depend, andMake.dep.3.
interpreters/python/Makefile— touch.contextTouch
.contextat the end of thecontext::target, after unpacking CPython source. This ensuresdistcleancan find the directory even if the build fails during configure.4.
interpreters/python/.gitignoreAdd
.contextto the gitignore.How it works
.built.depend.contextCLEANSUBDIRSDISTCLEANSUBDIRSVerification
Simulated a partial build (context:: run, build fails at configure):
Python/,build/,install/,v3.13.0.zip,config.site,Setup.local.contextmarkerCLEANSUBDIRSis empty (no.built/.depend/.kconfig)DISTCLEANSUBDIRSincludespython/(has.context)Fixes
Fixes #2895