make/[Makefile|*.mk): Improve variable caching

This commit aims at improving speed by using better caching.

- Makefile, cache.mk: Split .cache.mk up

To allow caching of runtime path variables which are project-specific, split .cache.mk up in .cache-project.mk and .cache-projects.mk

- ldlibpath.mk: Cache ldlibpath, exepath and pythonpath

Place the output of $(call proj_query ldlibpath), $(call proj_query, exepath) and $(call proj_query pythonpath) in JW_PKG_LD_LIBRARY_PATH, JW_PKG_EXE_PATH, and JW_PKG_PYTHON_PATH respectively, and cache the variables in make/.project-cache.mk.

- cache.mk: Use = instead of :=

Recursively expanded variables are nearly as fast as := variables if the assigned value is a fixed string. And sometimes it's not, rightly so, because variables get assigned below, as with JW_PKG_XXX for instance.

- cache.mk: Use $(TOPDIR) as variable values

Replace absolute references to project's topdir by $(TOPDIR) with sed. As soon as the project queries produce absolute paths, they will be transformed into relative paths which allow the code base to be moved to a different location and still remain functional without a rebuild.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-22 14:12:58 +01:00
commit f05e1ee0e3
8 changed files with 64 additions and 40 deletions

View file

@ -4,6 +4,7 @@
# $Id$
include $(JWBDIR)/make/defs.mk
include $(JWBDIR)/make/ldlibpath.mk
include $(JWBDIR)/make/defs-dirs.mk
include $(JWBDIR)/make/dev-utils.mk
@ -11,7 +12,8 @@ CACHED_FILES ?= $(VERSION_FILE) $(wildcard $(TOPDIR)/make/project
CACHED_VARS ?= PROJECT PREREQ VERSION HEX_VERSION FULL_NAME \
WHICH PYTHON ECHO TEST BROWSER SED RM PWD ID CUT TR \
AWK GETENT XARGS FIND PRINTF HOST_TUPLE OS_NAME_VERSION \
OS_NAME CAT BIN_INSTALL SUDO
OS_NAME CAT BIN_INSTALL SUDO \
JW_PKG_LD_LIBRARY_PATH JW_PKG_EXE_PATH JW_PKG_PYTHON_PATH
include $(JWBDIR)/make/cache.mk