From 51c42f7dda6e9d48f120ab15f277bed95c60f5d0 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 3 Sep 2026 13:19:54 +0200 Subject: [PATCH 1/5] defs-dirs.mk: Filter out non-existing ordered subdirs SUBDIRS combines $(ORDERED_SUBDIRS) with the subdirectories found on disk. An $(ORDERED_SUBDIRS) entry that does not exist in the tree is still passed to the recursive make loop, which then errors out over the missing directory. Filter the ordered subdirectories through the wildcard of their Makefile paths, keeping only the ones that are actually there. Signed-off-by: Jan Lindemann --- make/defs-dirs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/defs-dirs.mk b/make/defs-dirs.mk index 45682b6d..3e1bc613 100644 --- a/make/defs-dirs.mk +++ b/make/defs-dirs.mk @@ -5,6 +5,6 @@ SUBDIRS_TO_ITERATE = $(filter-out $(IGNORE_SUBDIRS),$(SUBDIRS)) EXTRA_SUBDIR_TARGETS ?= ALLOWED_SUBDIR_TARGETS ?= all install clean distclean test link-in $(EXTRA_SUBDIR_TARGETS) -SUBDIRS ?= $(ORDERED_SUBDIRS) $(filter-out $(ORDERED_SUBDIRS),$(FIND_SUBDIRS)) +SUBDIRS ?= $(dir $(wildcard $(addsuffix /Makefile,$(ORDERED_SUBDIRS)))) $(filter-out $(ORDERED_SUBDIRS),$(FIND_SUBDIRS)) #SUBDIRS ?= $(filter-out $(ORDERED_SUBDIRS),$(FIND_SUBDIRS)) #SUBDIRS ?= $(FIND_SUBDIRS) -- 2.55.0 From 9636f1064da2340acecb52a5cfe2c21a5a3067e7 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 24 Aug 2026 14:13:48 +0200 Subject: [PATCH 2/5] projects-dir.mk: Renovate build-order targets Renovate the build-order and build-order-% targets as follows: - Add BUILD_ORDER_DEP_FLAVOURS and default to all currently supported build flavours: run,build,test,release. This adds convenience for packages declaring differentiated types of dependencies, not only the default build dependency, but still want any project it uses somehow be be built before them. - Don't print the recipe's command when running "make build-order", it gets in the way if the caller wants to parse the result, so spare him filtering it. - Only log messages with priority warning or higher. Messages go to stderr anyway to keep them from throwing wrenches into consuming parsers, but they are likely confusingly visible without context if they leak to the calling program's console. Signed-off-by: Jan Lindemann --- make/projects-dir.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/make/projects-dir.mk b/make/projects-dir.mk index 09c9e746..f771ff32 100644 --- a/make/projects-dir.mk +++ b/make/projects-dir.mk @@ -53,6 +53,8 @@ else PROJECTS ?= $(shell ls -d */GNUmakefile */Makefile 2>/dev/null | sed 's%/[^/]*%%' | sort -u) endif +BUILD_ORDER_DEP_FLAVOURS ?= run,build,test,release + ifeq ($(JW_PKG_VERBOSE),true) SSH_WRAPPER_TRACE ?= -x endif @@ -182,7 +184,7 @@ help doc-project doc-module: status: $(SSH_WRAPPER_SH) build-order-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) - $(JW_PKG_PY_BUILD) --build-order $* $(TARGET_PROJECTS) | sed 's/ */\n/g' + @JW_DEFAULT_LOG_LEVEL=WARNING $(JW_PKG_PY_BUILD) --build-order --dep-flavours="$(BUILD_ORDER_DEP_FLAVOURS)" $* $(TARGET_PROJECTS) | sed 's/ */\n/g' build-order: build-order-all -- 2.55.0 From f3f0ef10ca908fbc8ce387218e2ba65de63657ff Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 24 Aug 2026 14:35:42 +0200 Subject: [PATCH 3/5] pgit.sh: Allow running under any projects-dir.mk There's a random string "some-random-string-to-id-this-makefile" in projects-dir-minimial.mk intended to check if the Makefile in the projects-directory is actually the final link target. It's re-used in pgit.sh to find the projects toplevel directory, but since it doesn't need to be an actual projects-dir-minimal.mk copy, another case should also be taken into consideration: Check if projects-dir.mk is included. Signed-off-by: Jan Lindemann --- scripts/pgit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pgit.sh b/scripts/pgit.sh index b7700ecb..aa2163ba 100644 --- a/scripts/pgit.sh +++ b/scripts/pgit.sh @@ -78,7 +78,7 @@ set_global_variables() # If we're in a toplevel directory, suppose projects_dir == project_dirs, # i.e. we only want to target this Git repo if [ ! -d .git ]; then - while [ ! -r Makefile ] || ! grep -q some-random-string-to-id-this-makefile Makefile; do + while [ ! -r Makefile ] || ! grep -q 'include $(JWBDIR)/make/projects-dir\.mk\|some-random-string-to-id-this-makefile' Makefile; do [ "$projects_dir" = / ] && fatal "Failed to find projects directory" projects_dir=`dirname $projects_dir` done -- 2.55.0 From 29abf14a67339e455729180cdf86067180f6c395 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 1 Sep 2026 11:07:21 +0200 Subject: [PATCH 4/5] py-ns-dir.mk: Support __init__.py generation For in-tree tests, the jw package is split across several projects, and each directory containing a py-ns-dir.mk contributes its subtree. So far, it's up to that directory how the contribution is handled. Usually an __init__.py with pkgutil.extend_path() is present in version control to glue these parts together. This commit makes py-ns-dir.mk handle the contribution method centrally by default unless PY_UPDATE_INIT_PY is set to false. As of this commit, this is the case by default, i.e. PY_UPDATE_INIT_PY is set to false in py-ns-dir.mk, maintaining the current behaviour. Downstream projects or modules can decide to have __init__.py centrally maintained. For this, they need to remove __init__.py from version control and set PY_UPDATE_INIT_PY to true in the respective Makefile. PY_UPDATE_INIT_PY = false is also set explicitly in src/python/jw/Makefile, because that file should never be generated. Bootstrapping the entire workspace hinges on it. Pending better testing, most notably of consistent in-tree testing functionality, PY_UPDATE_INIT_PY = true might become a global default in the future. Signed-off-by: Jan Lindemann --- make/py-ns-dir.mk | 23 +++++++++++++++++++++-- src/python/jw/Makefile | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/make/py-ns-dir.mk b/make/py-ns-dir.mk index 1c69d559..3529e721 100644 --- a/make/py-ns-dir.mk +++ b/make/py-ns-dir.mk @@ -1,7 +1,26 @@ +define INIT_PY +from pkgutil import extend_path + +__path__ = extend_path(__path__, __name__) +endef + +# The __init__.py machinery duplicates (but is independent from) py-mod.mk +PY_UPDATE_INIT_PY ?= true +PY_INSTALL_INIT_PY ?= false + +ifneq ($(PY_UPDATE_INIT_PY),false) + PY_GENERATED_PY += __init__.py +endif + include $(JWBDIR)/make/dirs.mk -all: +all: $(PY_GENERATED_PY) clean: py.clean py.clean: - rm -rf __pycache__ + rm -rf __pycache__ $(PY_GENERATED_PY) + +__init__.py: + @echo "Creating default namespace stub $@.tmp" + $(file >$@.tmp,$(INIT_PY)) + mv $@.tmp $@ diff --git a/src/python/jw/Makefile b/src/python/jw/Makefile index d99ad1c0..78727dfe 100644 --- a/src/python/jw/Makefile +++ b/src/python/jw/Makefile @@ -1,4 +1,6 @@ TOPDIR = ../../.. +PY_UPDATE_INIT_PY = false + include $(TOPDIR)/make/proj.mk include $(JWBDIR)/make/py-ns-dir.mk -- 2.55.0 From 23d3c596f6ad8c3958388a89ca6a92e5c0c7ef31 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 31 Aug 2026 11:19:04 +0200 Subject: [PATCH 5/5] py-mod.mk: Add TypeAlias to PY_SED_EXTRACT_EXPORT_DEF Automatically include symbols of the form MySymbol: TypeAlias = Something # export in generated __init__.py. Signed-off-by: Jan Lindemann --- make/py-mod.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/py-mod.mk b/make/py-mod.mk index a660e750..b693945b 100644 --- a/make/py-mod.mk +++ b/make/py-mod.mk @@ -5,7 +5,7 @@ include $(JWBDIR)/make/dev-utils.mk include $(JWBDIR)/make/test-guard.mk PY_INIT_TMPL = $(wildcard __init__.py.tmpl) -PY_SED_EXTRACT_EXPORT_DEF := /\(\(class\|def\)\s\+[a-zA-Z_].*\|^ *\S\+\s*=.*\|^\s\+\"\S\+\",\)\s*\#\s*export/!d; +PY_SED_EXTRACT_EXPORT_DEF := /\(\(class\|def\)\s\+[a-zA-Z_].*\|^ *\S\+\(:\s*TypeAlias\)*\s*=.*\|^\s\+\"\S\+\",\)\s*\#\s*export/!d; PY_SED_EXTRACT_EXPORT_DEF := $(PY_SED_EXTRACT_EXPORT_DEF) /^\s*\#/ d; s/\(async\)*\s*\(class\|def\)\s*//; PY_SED_EXTRACT_EXPORT_DEF := $(PY_SED_EXTRACT_EXPORT_DEF) s/[(:=].*//; s/^\s\+\"\(\S\+\)\",.*/\1/ PY_SED_EXTRACT_EXPORT ?= $(PY_SED_EXTRACT_EXPORT_DEF) -- 2.55.0