]> Lady’s Gitweb - Shushe/commitdiff
Don’t “compile” assets, just “build”
authorLady <redacted>
Mon, 1 Apr 2024 23:38:48 +0000 (19:38 -0400)
committerLady <redacted>
Tue, 2 Apr 2024 02:11:07 +0000 (22:11 -0400)
This reserves the `build/results/` directory for _just_ the results of
transformations, and delays the copying of asset files into the build
directory until the actual “build” step. (Likewise for recursive files,
altho these still just error).

`make all` now builds all installable files, including assets, which
were formerly excluded. A downstream script might expect assets to
appear in `build/public` after a `make all` and shouldn’t require a
`make install` to get them.

GNUmakefile

index 98a08cb4d67c8cd5c9eb4d0df44bb1a784f687e1..efa5c19708b56ffef9adcfd73fc0e3e81a46b552 100644 (file)
@@ -373,12 +373,15 @@ override sourcecompiledpair := $(foreach file,$(sourcefiles),$(file)|$(BUILDDIR)
 # (callable) Get the location of the transformed X·M·L files for the given source files.
 override compiled = $(foreach file,$1,$(patsubst $(file)|%,%,$(filter $(file)|%,$(sourcecompiledpair))))
 
-# (callable) Get the source files for the given compiled file.
+# (callable) Get the location of the source files for the given compiled file.
 override uncompiled = $(foreach file,$1,$(patsubst %|$(file),%,$(filter %|$(file),$(sourcecompiledpair))))
 
-# (callable) Get the location of the final built file for the given source files.
+# (callable) Get the location of the final built files for the given source files.
 override built = $(foreach file,$1,$(patsubst $(BUILDDIR)/results/%,$(BUILDDIR)/public/%,$(call compiled,$(file))))
 
+# (callable) Get the location of the source files for the given built files.
+override unbuilt = $(foreach file,$1,$(call uncompiled,$(patsubst $(BUILDDIR)/public/%,$(BUILDDIR)/results/%,$(file))))
+
 # (callable) Get the installed locations for the given source files.
 override installed = $(foreach file,$1,$(DESTDIR)/$(call destination,$(file)))
 endif
@@ -410,7 +413,7 @@ override extracttext = $(PRINTF) '%s' '<transform xmlns="http://www.w3.org/1999/
 # ─ ¶ Phony Targets ───────────────────────────────────────────────────
 
 # Compile all files, or error if any are recursive.
-all : $(call built,$(recursivefiles) $(compilablefiles)) ;
+all : $(call built,$(recursivefiles) $(installablefiles)) ;
 
 # Destroy buildfiles.
 clean :
@@ -435,8 +438,8 @@ uninstall :
        $(foreach file,$(installablefiles),$(if $(wildcard $(call installed,$(file))),$(silent)$(PRINTF) '%s\n' $(call quote,Removing </$(patsubst $(DESTDIR)/%,%,$(call installed,$(file)))>…)$(newline)$(silent)$(RM) -f $(call quote,$(call installed,$(file)))$(newline),))
 
 # Raise an error when attempting to build any files with recursive dependencies.
-$(call compiled,$(recursivefiles)) :
-       @$(PRINTF) '%b\n' $(call quote,\0033[93;41mError:\0033[39;49m `$(call uncompiled,$@)´ has recursive dependencies:\n$(subst |, ,$(subst $(space),$(newline),$(foreach recursive,$(call recursives,$(call uncompiled,$@)),•|$(recursive))))) && false
+$(call built,$(recursivefiles)) :
+       @$(PRINTF) '%b\n' $(call quote,\0033[93;41mError:\0033[39;49m `$(call unbuilt,$@)´ has recursive dependencies:\n$(subst |, ,$(subst $(space),$(newline),$(foreach recursive,$(call recursives,$(call unbuilt,$@)),•|$(recursive))))) && false
 
 # Add as a prerequisite to treat the target as tho it were phony.
 FORCE : ;
@@ -450,7 +453,7 @@ FORCE : ;
 .SUFFIXES : ;
 
 # Phony rules; always consider these out·of·date.
-.PHONY : FORCE all default clean gone info install list uninstall $(call compiled,$(recursivefiles)) ;
+.PHONY : FORCE all default clean gone info install list uninstall $(call built,$(recursivefiles)) ;
 
 ifneq ($(typeupdates)$(wildcard $(BUILDDIR)/dependencies)$(wildcard $(BUILDDIR)/destinations),)
 # Reload this make·file if the dependency graph or output destinations have changed.
@@ -555,23 +558,19 @@ $(call compiled,$(compilablefiles)) : $(BUILDDIR)/results/% : $$(call parsed,$$(
        @$(PRINTF) '%s\n' $(call quote,Compiling </$*>…)
        $(silent)$(call ensuredirectory,$(dir $@))
        $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME $$(TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME $$(TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call uncompiled,$@))) --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*) --stringparam CKSUM $$($(CKSUM) $(call quote,$(call uncompiled,$@)) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
-$(call compiled,$(filter $(assetfiles),$(sourcefiles))) : $(BUILDDIR)/results/% : $$(call uncompiled,$$@)
-       @$(PRINTF) '%s\n' $(call quote,Compiling </$*>…)
-       $(silent)$(call ensuredirectory,$(dir $@))
-       $(silent)$(CP) $(call quote,$<) $(call quote,$@)
 
 # Create the final files from the compiled results (or error in the case of recursive ones).
 $(call built,$(compilablefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
        @$(PRINTF) '%s\n' $(call quote,Building </$*>…)
        $(silent)$(call ensuredirectory,$(dir $@))
        $(silent)if $(call xpath,/*[local-name()="raw-text" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$<); then $(RM) -f $(call quote,$@); $(call extracttext,$<) > $(call quote,$@); elif $(call xpath,/*[local-name()="base64-binary" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$<); then $(RM) -f $(call quote,$@); $(call extracttext,$<) | $(TR) -d '\t\n\f\r ' | $(UUDECODE) -m -r > $(call quote,$@); else $(LN) -s -f $(call quote,$(subst $(space),,$(foreach component,$(subst /, ,$*),../))results/$*) $(call quote,$@); fi
-$(call built,$(filter $(assetfiles),$(sourcefiles)) $(recursivefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
+$(call built,$(filter $(assetfiles),$(sourcefiles))) : $(BUILDDIR)/public/% : $$(call unbuilt,$$@)
        @$(PRINTF) '%s\n' $(call quote,Building </$*>…)
        $(silent)$(call ensuredirectory,$(dir $@))
-       $(silent)$(LN) -s -f $(call quote,../results/$*) $(call quote,$@)
+       $(silent)$(CP) $(call quote,$<) $(call quote,$@)
 
 # Install compiled files (or error in the case of recursive ones).
-$(call installed,$(filter $(assetfiles),$(sourcefiles)) $(recursivefiles) $(compilablefiles)) : $(DESTDIR)/% : $(BUILDDIR)/public/%
+$(call installed,$(recursivefiles) $(installablefiles)) : $(DESTDIR)/% : $(BUILDDIR)/public/%
        @$(PRINTF) '%s\n' $(call quote,Installing </$*>…)
        $(silent)$(call ensuredirectory,$(dir $@))
        $(silent)$(CP) $(call quote,$<) $(call quote,$@)
This page took 0.026382 seconds and 4 git commands to generate.