From: Lady Date: Mon, 1 Jan 2024 20:49:15 +0000 (-0500) Subject: Re·order remakes to (again) fix restarts X-Git-Tag: 0.2.0~3 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/55fc968f72857e25fcafe6088c873f5032555c79?ds=sidebyside Re·order remakes to (again) fix restarts In cases where `$(BUILDDIR)/dependencies` exists but `$(BUILDDIR)/.update-types` (initially) does not, it is important to check for dependency updates *first*, prior to checking for parser updates. This is because when parsers are updated, the dependency file will be deleted, causing the dependency reload recipe to activate immediately (prior to a restart) if it hasn’t already been checked. Having correct behaviour depend on the ordering of these recipes isn’t ideal, but the alternative is checking whether `$(BUILDDIR)/.update-types` was created *in the course of processing the make·file* and disabling dependency creation until the next restart if it had been. This sounds unbearably complex and difficult to phrase in a readable manner. --- diff --git a/GNUmakefile b/GNUmakefile index 72712c8..6d68702 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -242,7 +242,7 @@ override sourcefile = $(foreach file,$1,$(if $(filter about:shushe?include=%,$(f # This file is created after a reload due to type changes, and is # removed after. Requiring it ensures that file classifications are # up‐to‐date immediately after the reload. -override typeupdates := $(if $(wildcard $(BUILDDIR)/.update-types),$(BUILDDIR)/.update-types,) +override typeupdates := $(wildcard $(BUILDDIR)/.update-types) # (callable) Get the location of the transformed X·M·L files for the # given source files. @@ -332,6 +332,21 @@ $(call compiled,$(recursivefiles)): $(BUILDDIR)/public/%: # Phony rules; always consider these out‐of‐date. .PHONY: all default clean gone info install list $(call compiled,$(recursivefiles)); +ifneq ($(wildcard $(BUILDDIR)/.update-types)$(wildcard $(BUILDDIR)/dependencies),) +# Reload this make·file if the dependency graph has changed. +# +# This graph is a dependency for some of the variables that this +# make·file uses, so it’s important to ensure that they are actually +# up‐to‐date prior to executing any later rules. +# +# This recipe only exists after types have been updated or when the +# dependency graph already exists. +$(THISDIR)/GNUmakefile:: $(BUILDDIR)/dependencies + $(silent)$(TOUCH) $(THISDIR)/GNUmakefile + $(silent)$(RM) -f $(BUILDDIR)/.update-types + @$(PRINTF) '%b\n' '\0033[1mDependency graph updated. Restarting…\0033[22m' +endif + ifeq ($(wildcard $(BUILDDIR)/.update-types),) # Reload this make·file if any of the magic files or parsers have # changed. @@ -343,25 +358,10 @@ ifeq ($(wildcard $(BUILDDIR)/.update-types),) # the restart have a more current time·stamp. $(THISDIR)/GNUmakefile:: $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt $(THISDIR)/lib/parser2types.xslt $(silent)$(TOUCH) $(THISDIR)/GNUmakefile - $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types) $(silent)$(RM) -f $(call quote,$(BUILDDIR)/dependencies) @$(PRINTF) '%b\n' '\0033[1mMagic file or parsers have updated. Restarting…\0033[22m' $(silent)$(SLEEP) 1 -endif - -ifneq ($(wildcard $(BUILDDIR)/.update-types)$(wildcard $(BUILDDIR)/dependencies),) -# Reload this make·file if the dependency graph has changed. -# -# This graph is a dependency for some of the variables that this -# make·file uses, so it’s important to ensure that they are actually -# up‐to‐date prior to executing any later rules. -# -# This recipe only exists after types have been updated or when the -# dependency graph already exists. -$(THISDIR)/GNUmakefile:: $(BUILDDIR)/dependencies - $(silent)$(TOUCH) $(THISDIR)/GNUmakefile - $(silent)$(RM) -f $(BUILDDIR)/.update-types - @$(PRINTF) '%b\n' '\0033[1mDependency graph updated. Restarting…\0033[22m' + $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types) endif # ─ ¶ Build Targets ─────────────────────────────────────────────────── @@ -386,12 +386,6 @@ $(BUILDDIR)/parser.xslt: $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2parse @$(ECHO) "Generating main parser…" $(silent)$(XSLTPROC) -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2parser.xslt) $(call quote,$<) -# Note updates to parsers or magic. -# -# This file is actually generated as part of the make·file restart -# process, so it doesn’t need any recipes. -$(BUILDDIR)/.update-types: $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt $(THISDIR)/lib/parser2types.xslt ; - # Parse the files. # # Even plain X·M·L files are parsed, because they may contain X·H·T·M·L