Skip to content

build: introduce .context marker for distclean after partial builds#3585

Draft
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/distclean-context-partial-build
Draft

build: introduce .context marker for distclean after partial builds#3585
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/distclean-context-partial-build

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

Summary

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.

This PR fixes this by introducing a .context marker and separating the scopes of clean and distclean.

Changes

1. Directory.mkDISTCLEANSUBDIRS

Introduce a new variable DISTCLEANSUBDIRS: a superset of CLEANSUBDIRS that also includes directories carrying .context:

DISTCLEANSUBDIRS := $(CLEANSUBDIRS)
DISTCLEANSUBDIRS += $(dir $(wildcard */.context))
DISTCLEANSUBDIRS := $(sort $(DISTCLEANSUBDIRS))
  • clean:: keeps using CLEANSUBDIRS — only clean compiled artifacts
  • distclean:: now uses DISTCLEANSUBDIRS — also undo context:: work

2. Application.mk — clean .context on distclean

Add $(call DELFILE, .context) to the distclean:: target alongside .built, .depend, and Make.dep.

3. interpreters/python/Makefile — touch .context

Touch .context at the end of the context:: target, after unpacking CPython source. This ensures distclean can find the directory even if the build fails during configure.

4. interpreters/python/.gitignore

Add .context to the gitignore.

How it works

Scenario .built .depend .context CLEANSUBDIRS DISTCLEANSUBDIRS distclean cleans?
Successful build
Failed at configure ✅ (new!)
Never built N/A

Verification

Simulated a partial build (context:: run, build fails at configure):

  1. Created Python/, build/, install/, v3.13.0.zip, config.site, Setup.local
  2. Created .context marker
  3. Confirmed CLEANSUBDIRS is empty (no .built/.depend/.kconfig)
  4. Confirmed DISTCLEANSUBDIRS includes python/ (has .context)
  5. Ran distclean — all artifacts cleaned correctly

Fixes

Fixes #2895

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Python interperter distclean isn't working

1 participant