]> Lady’s Gitweb - Shushe/commitdiff
Give magic file symlinks unique names 0.9.6
authorLady <redacted>
Thu, 11 Jul 2024 01:45:26 +0000 (21:45 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:45:58 +0000 (21:45 -0400)
Rather than deal with the potential for conflicts in the names of magic
files from different sources, give each file a unique name by taking
the `cksum` of its absolute path.

GNUmakefile

index 5237a2d813d967577395424b23592a7495a638fa..f5b738aa94f2faf62005e33b1ffa4f390f8f6acf 100644 (file)
@@ -343,6 +343,11 @@ override perenc = $(shell $(PRINTF) '%s\n' $(foreach unencoded,$1,$(call quote,$
 # ☡ This variable creates a subshell every time it is computed.
 override pathenc = $(subst %2F,/,$(call perenc,$1))
 
+# (callable) Create a unique name for the given file, based on its absolute path.
+#
+# ☡ This variable creates a subshell every time it is computed.
+namehash = $(shell $(PRINTF) '%s' $(call quote,$(abspath $1)) | $(CKSUM) | $(SED) 's/ .*//' | $(XARGS) -E '' $(PRINTF) '%X')-$(notdir $1)
+
 # (overridable) Collect all of the applicable includes from the includes directory.
 sourceincludes := $(if $(and $(INCLUDEDIR),$(wildcard $(INCLUDEDIR))),$(patsubst ./%,%,$(shell $(FIND) $(foreach dir,$(INCLUDEDIR),$(call quote,$(dir))) '(' $(FINDINCLUDERULES) ')' -a -type f -a -print)),)
 
@@ -373,7 +378,7 @@ override assetfiles := $(filter-out $(xmlfiles) $(plaintextfiles),$(sourcefiles)
 override typeoffile = $(foreach file,$1,$(or $(patsubst $(file)|%,%,$(filter $(file)|%,$(types))),$(error Unable to get type of file `$(file)´)))
 
 # Pair each source magic file with its location in the build directory.
-override magicpair := $(foreach magicfile,$(MAGIC),$(magicfile)|$(BUILDDIR)/magic/$(notdir $(magicfile)))
+override magicpair := $(foreach magicfile,$(MAGIC),$(magicfile)|$(BUILDDIR)/magic/$(call namehash,$(magicfile)))
 
 # (callable) Get the source file for the given magic files.
 override magicsource = $(foreach magicpath,$1,$(patsubst %|$(magicpath),%,$(firstword $(filter %|$(magicpath),$(magicpair)))))
This page took 0.076465 seconds and 4 git commands to generate.