common.mk: Add file
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m4s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 7m20s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m14s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 7m2s
CI / Packaging test (push) Successful in 0s

This is the first in a series of attempts to clean up jw-pkg's makefile
fragments make/*.mk. It collects redundantly defined workspace and project
variables into one shared common.mk.

Variables needed in both the workspace directory and the project
directories are defined separately in the two contexts: Q in defs.mk and
projects-dir-minimal.mk, INTERACTIVE in topdir.mk and projects-dir.mk,
BROWSER and JWB_SCRIPT_DIR in defs.mk/platform.mk and projects-dir.mk, and
LIST_VCS_FILES and LIST_VCS_FILES_SH wrapping the same scm.sh ls-files call
under different names. PKG_MANAGER is defined in topdir.mk and
projects-dir.mk, and JW_PKG_PY_PROJECTS is a prefix only used to build two
other variables in projects-dir.mk.

This commit adds make/common.mk, included from defs.mk (and hence from
every project directory) and from projects-dir.mk (the workspace), and
collects the shared variables there:

- Q, INTERACTIVE, BROWSER, JWB_SCRIPT_DIR: one ?= definition each
- LIST_VCS_FILES: one definition; LIST_VCS_FILES_SH is dropped and the
  list-files target uses the shared name
- PKG_MANAGER moves to projects+project.mk, the fragment shared by the
  workspace and the topdir
- projects-dir-minimal.mk keeps its own Q, because the bootstrap recipes
  run before common.mk is parsed
- JW_PKG_PY_PROJECTS is inlined into JW_PKG_PY_BUILD and
  JW_PKG_PY_REQUIRED_OS_PKG

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.87.0
This commit is contained in:
Jan Lindemann 2026-09-21 08:54:07 +02:00
commit 4823463b88
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
8 changed files with 26 additions and 23 deletions

View file

@ -25,8 +25,9 @@ JWBDIR_NAME ?= jw-pkg
JWBDIR_SEARCH_PATH ?= $(DEV_PROJECTS_DIR) $(BUILD_TOOLS_PREFIX)/opt/$(FLAVOUR_PATH_PREFIX)
JWBDIR ?= $(firstword $(wildcard $(addsuffix /$(JWBDIR_NAME),$(JWBDIR_SEARCH_PATH))))
include $(JWBDIR)/make/common.mk
JW_PKG_BINDIR = $(JWBDIR)/bin
JWB_SCRIPT_DIR = $(firstword $(wildcard $(JWBDIR)/scripts $(JW_PKG_BINDIR)) jwb-script-dir-not-found)
JW_PKG_REMOTE_BINDIR = /opt/jw-pkg/bin
SHELL = /bin/bash -o pipefail +H
@ -110,12 +111,8 @@ ifneq ($(EXCLUDE_FROM_BUILD),)
JW_PKG_PY_EXTRA_BUILD_OPTS += --exclude "$(EXCLUDE_FROM_BUILD)"
endif
# non-interactive mode
INTERACTIVE ?= auto
# ------------ external programs II
BROWSER ?= xdg-open
EDITOR ?= xdg-open
ifeq ($(TIME),)
TIME := $(shell which time)
@ -123,11 +120,9 @@ ifeq ($(TIME),)
TIME += -p
endif
endif
JW_PKG_PY_PROJECTS = $(JW_PKG_PY) projects
PKG_RELATIONS_BUILD ?= requires,recommends
JW_PKG_PY_BUILD = $(JW_PKG_PY_PROJECTS) build --pkg-relations "$(PKG_RELATIONS_BUILD)" $(JW_PKG_PY_EXTRA_BUILD_OPTS)
JW_PKG_PY_REQUIRED_OS_PKG = $(JW_PKG_PY_PROJECTS) required-os-pkg --quote --skip-excluded --pkg-relations "$(PKG_RELATIONS_BUILD)"
PKG_MANAGER ?= $(TIME) $(JW_PKG_PY) --interactive=$(INTERACTIVE) pkg
JW_PKG_PY_REQUIRED_OS_PKG = $(JW_PKG_PY) projects required-os-pkg --quote --skip-excluded --pkg-relations "$(PKG_RELATIONS_BUILD)"
JW_PKG_PY_BUILD = $(JW_PKG_PY) projects build --pkg-relations "$(PKG_RELATIONS_BUILD)" $(JW_PKG_PY_EXTRA_BUILD_OPTS)
ifneq ($(origin PROJECTS_DIR_REMOTE_BASE),undefined)
PGIT_SH += --remote-base $(PROJECTS_DIR_REMOTE_BASE)
@ -147,7 +142,6 @@ endif
PURGE_SH = /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/purge-stale-projects.sh $(JW_PKG_BINDIR)/purge-stale-projects.sh) purge-not-found)
CREATE_PROJECT_SH ?= /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/jw-pkg-create-project.sh $(JW_PKG_BINDIR)/jw-pkg-create-project.sh) jw-pkg-create-project-not-found)
LIST_VCS_FILES_SH = /bin/bash $(firstword $(wildcard $(JWB_SCRIPT_DIR)/scm.sh $(JW_PKG_BINDIR)/scm.sh) scm-sh-not-found) ls-files
GIT_SRV_ADMIN_SH = $(GIT_SSH) $(JANWARE_USER)@devgit.janware.com $(JW_PKG_REMOTE_BINDIR)/git-srv-admin.sh
JANWARE_PACKAGE_FILTER = url =~ janware
@ -227,7 +221,7 @@ clean.text-files-cache:
rm -f $(TEXT_FILES_CACHE)
list-files:
$(Q)for p in $(DEP_PROJECTS); do \
$(LIST_VCS_FILES_SH) -znf $$p | sed -z "s/^/$$p\//" | \
$(LIST_VCS_FILES) -znf $$p | sed -z "s/^/$$p\//" | \
xargs -0 realpath -q ;\
done
$(TEXT_FILES_CACHE):