mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
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>
39 lines
1.1 KiB
Makefile
39 lines
1.1 KiB
Makefile
# ----- define these variables
|
|
# CACHED_FILES = $(TOPDIR)/VERSION
|
|
# CACHED_VARS = VERSION
|
|
.PHONY: cache clean-cache clean-cache-projects
|
|
|
|
CACHE_PROJECT_MK ?= .cache-project.mk
|
|
CACHE_PROJECTS_MK ?= .cache-projects.mk
|
|
CACHE_FILES_MK = $(CACHE_PROJECT_MK) $(CACHE_PROJECTS_MK)
|
|
CACHED_VARS_ONLY_PROJECT ?= \
|
|
PROJECT \
|
|
PREREQ \
|
|
VERSION \
|
|
HEX_VERSION \
|
|
FULL_NAME \
|
|
JW_PKG_LD_LIBRARY_PATH \
|
|
JW_PKG_EXE_PATH \
|
|
JW_PKG_PYTHON_PATH
|
|
all: cache
|
|
clean: clean-cache
|
|
clean-cache:
|
|
rm -f $(CACHE_PROJECT_MK)
|
|
|
|
cache: $(CACHE_PROJECT_MK)
|
|
$(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk
|
|
@echo $(foreach v,$(CACHED_VARS),$v = $(value $(v))EOL) | \
|
|
$(SED) 's/EOL */\n/g;' | \
|
|
$(SED) 's|$(realpath $(TOPDIR))|$$(TOPDIR)|g' | \
|
|
$(SED) 's|$(realpath $(PROJECTS_DIR))|$$(PROJECTS_DIR)|g' | \
|
|
$(GREP) . | \
|
|
tee $@.tmp
|
|
mv $@.tmp $@
|
|
|
|
# -- Only used in jw-pkg
|
|
cache-projects: $(CACHE_PROJECTS_MK)
|
|
clean-cache-projects:
|
|
rm -f $(CACHE_PROJECTS_MK)
|
|
$(CACHE_PROJECTS_MK): $(CACHE_PROJECT_MK)
|
|
sed '/\($(subst $(space),\|,$(CACHED_VARS_ONLY_PROJECT))\)\s*[:?]\?=/ d' $< > $@.tmp
|
|
mv $@.tmp $@
|