From 30e831c9602ea5d4d0603f5ad03baff481771b4b Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 19 Aug 2020 00:10:08 +0200 Subject: Put extensions in Lua module instead of sneaking them in environment Note that neither .cache/config.lua nor .cache/site-tree.json get updated when EXTENSIONS changes. This could be hacked as follows: config = EXTENSIONS="$(EXTENSIONS)" ifneq "$(shell test -f $(config_token) && cat $(config_token))" \ "$(shell ./generate-config-token.py $(config))" .PHONY: $(lua_config) $(site_tree) $(config_token) endif Plus a recipe for config_token, and some dependencies on it. --- repo/www/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'repo/www/Makefile') diff --git a/repo/www/Makefile b/repo/www/Makefile index f88672c..aa48971 100644 --- a/repo/www/Makefile +++ b/repo/www/Makefile @@ -23,6 +23,8 @@ cache = .cache title = $(cache)/title # Maps folders to their contents (files and subfolders). site_tree = $(cache)/site-tree.json +# Lua module to let filters know about the configuration. +lua_config = $(cache)/config.lua # Defines $(pages) and $(indices). dependencies = $(cache)/deps.mk @@ -32,6 +34,9 @@ $(title): $(top_readme) | $(cache) $(site_tree): $(page_folders) | $(cache) ./generate-tree.py -o $@ $(EXTENSIONS) +$(lua_config): | $(cache) + ./generate-lua-config.py EXTENSIONS="$(EXTENSIONS)" > $@ + $(dependencies): $(site_tree) | $(cache) ./generate-deps.py $< $@ $(OUT_DIR) @@ -49,10 +54,10 @@ $(html_folders) $(cache): $(pages) $(subindices): $(title) -$(pages) $(indices): $(html_template) +$(pages) $(indices): $(html_template) $(lua_filters) $(lua_config) $(pages): $(OUT_DIR)/%.html: - $(call v,PAGE,$*) EXTENSIONS="$(EXTENSIONS)" \ + $(call v,PAGE,$*) \ ./generate-page.py --site-title="$$(cat $(title))" --title="$*" \ $(foreach f,$(lua_filters),--lua-filter $(f)) \ --template=$(html_template) $< $@ @@ -66,7 +71,7 @@ $(subindices): index_options = --site-title="$$(cat $(title))" # ⚠ When tweaking this rule, check whether it still works for the # top-level index.html. $(indices): $(OUT_DIR)/%index.html: - $(call v,INDEX,$*) EXTENSIONS="$(EXTENSIONS)" \ + $(call v,INDEX,$*) \ ./generate-index.py $(index_options) --template=$(html_template) \ $(foreach f,$(lua_filters),--lua-filter $(f)) \ $(site_tree) "$(patsubst %/,%,$*)" $@ -- cgit v1.2.3