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/generate-lua-config.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 repo/www/generate-lua-config.py (limited to 'repo/www/generate-lua-config.py') diff --git a/repo/www/generate-lua-config.py b/repo/www/generate-lua-config.py new file mode 100755 index 0000000..0a00443 --- /dev/null +++ b/repo/www/generate-lua-config.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +from sys import argv + + +TEMPLATE = '''\ +local config = {{}} + +config.EXTENSIONS = {{ {EXTENSIONS} }} + +return config +''' + + +def _quote(s): + return f"'{s}'" + + +def main(arguments): + pairs = (arg.split('=') for arg in arguments) + + formatters = { + 'EXTENSIONS': lambda v: ', '.join(map(_quote, v.split())) + } + + parameters = { + key: formatters[key](value) for (key, value) in pairs + } + + print(TEMPLATE.format_map(parameters), end='') + + +if __name__ == '__main__': + main(argv[1:]) -- cgit v1.2.3