make: Miscellaneous versatility improvements #83

Merged
Jan Lindemann merged 5 commits from jan/feature/20260905-make-miscellaneous-versatility-improvements into master 2026-09-05 13:49:10 +02:00 AGit
6 changed files with 29 additions and 6 deletions

View file

@ -5,6 +5,6 @@ SUBDIRS_TO_ITERATE = $(filter-out $(IGNORE_SUBDIRS),$(SUBDIRS))
EXTRA_SUBDIR_TARGETS ?= EXTRA_SUBDIR_TARGETS ?=
ALLOWED_SUBDIR_TARGETS ?= all install clean distclean test link-in $(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 ?= $(filter-out $(ORDERED_SUBDIRS),$(FIND_SUBDIRS))
#SUBDIRS ?= $(FIND_SUBDIRS) #SUBDIRS ?= $(FIND_SUBDIRS)

View file

@ -53,6 +53,8 @@ else
PROJECTS ?= $(shell ls -d */GNUmakefile */Makefile 2>/dev/null | sed 's%/[^/]*%%' | sort -u) PROJECTS ?= $(shell ls -d */GNUmakefile */Makefile 2>/dev/null | sed 's%/[^/]*%%' | sort -u)
endif endif
BUILD_ORDER_DEP_FLAVOURS ?= run,build,test,release
ifeq ($(JW_PKG_VERBOSE),true) ifeq ($(JW_PKG_VERBOSE),true)
SSH_WRAPPER_TRACE ?= -x SSH_WRAPPER_TRACE ?= -x
endif endif
@ -182,7 +184,7 @@ help doc-project doc-module:
status: $(SSH_WRAPPER_SH) status: $(SSH_WRAPPER_SH)
build-order-%: $(filter-out $(UNAVAILABLE_TARGETS),pull.done) 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 build-order: build-order-all

View file

@ -5,7 +5,7 @@ include $(JWBDIR)/make/dev-utils.mk
include $(JWBDIR)/make/test-guard.mk include $(JWBDIR)/make/test-guard.mk
PY_INIT_TMPL = $(wildcard __init__.py.tmpl) 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*\#/ 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_DEF := $(PY_SED_EXTRACT_EXPORT_DEF) s/[(:=].*//; s/^\s\+\"\(\S\+\)\",.*/\1/
PY_SED_EXTRACT_EXPORT ?= $(PY_SED_EXTRACT_EXPORT_DEF) PY_SED_EXTRACT_EXPORT ?= $(PY_SED_EXTRACT_EXPORT_DEF)

View file

@ -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 include $(JWBDIR)/make/dirs.mk
all: all: $(PY_GENERATED_PY)
clean: py.clean clean: 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 $@

View file

@ -78,7 +78,7 @@ set_global_variables()
# If we're in a toplevel directory, suppose projects_dir == project_dirs, # If we're in a toplevel directory, suppose projects_dir == project_dirs,
# i.e. we only want to target this Git repo # i.e. we only want to target this Git repo
if [ ! -d .git ]; then 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" = / ] && fatal "Failed to find projects directory"
projects_dir=`dirname $projects_dir` projects_dir=`dirname $projects_dir`
done done

View file

@ -1,4 +1,6 @@
TOPDIR = ../../.. TOPDIR = ../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-ns-dir.mk include $(JWBDIR)/make/py-ns-dir.mk