From 6aedd1c7a739f013064fe4c184454ee29b15c233 Mon Sep 17 00:00:00 2001 From: Joan Josep Ordinas Rosa Date: Thu, 22 Nov 2018 12:25:19 +0100 Subject: [PATCH] Fine grained dependencies --- Makefile | 10 +++---- bin/sake | 9 ++++-- docs/Sakefile | 18 ++++++++++-- docs/config.yaml | 1 - docs/phase3_layout.jq | 29 +++++++++++++++++++ share/{sake => }/milligram/BEM.m | 0 share/{sake => }/milligram/COLORNAMES.m | 0 share/{sake => }/milligram/Normalize.css | 0 share/{sake => }/milligram/base.css | 0 share/{sake => }/milligram/blockquote.css | 0 share/{sake => }/milligram/button.css | 0 share/{sake => }/milligram/code.css | 0 share/{sake => }/milligram/color.css | 0 share/{sake => }/milligram/divider.css | 0 share/{sake => }/milligram/form.css | 0 share/{sake => }/milligram/grid.css | 0 share/{sake => }/milligram/image.css | 0 share/{sake => }/milligram/link.css | 0 share/{sake => }/milligram/list.css | 0 share/{sake => }/milligram/spacing.css | 0 share/{sake => }/milligram/table.css | 0 share/{sake => }/milligram/typography.css | 0 share/{sake => }/milligram/utility.css | 0 .../make.d => sake.d}/configuration.make | 0 share/{sake/make.d => sake.d}/main.make | 25 ++-------------- share/{sake/make.d => sake.d}/phase1.jq | 0 share/{sake/make.d => sake.d}/phase1.make | 0 share/{sake/make.d => sake.d}/phase1_site.jq | 0 share/{sake/make.d => sake.d}/phase2.jq | 0 share/{sake/make.d => sake.d}/phase2.make | 0 share/{sake/make.d => sake.d}/phase2_page.jq | 0 share/{sake/make.d => sake.d}/phase3.jq | 20 +++++++++---- share/{sake/make.d => sake.d}/phase3.make | 4 +-- share/{sake/make.d => sake.d}/sitemap.jq | 0 share/{sake/make.d => sake.d}/sitemap.make | 0 share/{sake/make.d => sake.d}/styles.make | 9 +++--- share/{sake/make.d => sake.d}/tools.make | 0 37 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 docs/phase3_layout.jq rename share/{sake => }/milligram/BEM.m (100%) rename share/{sake => }/milligram/COLORNAMES.m (100%) rename share/{sake => }/milligram/Normalize.css (100%) rename share/{sake => }/milligram/base.css (100%) rename share/{sake => }/milligram/blockquote.css (100%) rename share/{sake => }/milligram/button.css (100%) rename share/{sake => }/milligram/code.css (100%) rename share/{sake => }/milligram/color.css (100%) rename share/{sake => }/milligram/divider.css (100%) rename share/{sake => }/milligram/form.css (100%) rename share/{sake => }/milligram/grid.css (100%) rename share/{sake => }/milligram/image.css (100%) rename share/{sake => }/milligram/link.css (100%) rename share/{sake => }/milligram/list.css (100%) rename share/{sake => }/milligram/spacing.css (100%) rename share/{sake => }/milligram/table.css (100%) rename share/{sake => }/milligram/typography.css (100%) rename share/{sake => }/milligram/utility.css (100%) rename share/{sake/make.d => sake.d}/configuration.make (100%) rename share/{sake/make.d => sake.d}/main.make (88%) rename share/{sake/make.d => sake.d}/phase1.jq (100%) rename share/{sake/make.d => sake.d}/phase1.make (100%) rename share/{sake/make.d => sake.d}/phase1_site.jq (100%) rename share/{sake/make.d => sake.d}/phase2.jq (100%) rename share/{sake/make.d => sake.d}/phase2.make (100%) rename share/{sake/make.d => sake.d}/phase2_page.jq (100%) rename share/{sake/make.d => sake.d}/phase3.jq (75%) rename share/{sake/make.d => sake.d}/phase3.make (95%) rename share/{sake/make.d => sake.d}/sitemap.jq (100%) rename share/{sake/make.d => sake.d}/sitemap.make (100%) rename share/{sake/make.d => sake.d}/styles.make (72%) rename share/{sake/make.d => sake.d}/tools.make (100%) diff --git a/Makefile b/Makefile index c446af8..ead62ba 100644 --- a/Makefile +++ b/Makefile @@ -106,15 +106,13 @@ setup: .PHONY: install uninstall -SAKE=$(datadir)/$(PROJECT)/sake/ - install: all - install --directory $(bindir) $(datadir) $(mandir)/man1 $(SAKE)/{make.d,milligram} + install --directory $(bindir) $(datadir) $(mandir)/man1 $(datadir)/$(PROJECT)/{sake.d,milligram} install --verbose --compare --mode 555 bin/* $(bindir) - install --verbose --compare --mode 644 share/*.* $(datadir)/$(PROJECT) + install --verbose --compare --mode 644 share/*.m $(datadir)/$(PROJECT) install --verbose --compare --mode 644 $(ManPage) $(mandir)/man1 - install --verbose --compare --mode 644 share/sake/make.d/*.* $(SAKE)/make.d - install --verbose --compare --mode 644 share/sake/milligram/*.* $(SAKE)/milligram + install --verbose --compare --mode 644 share/sake.d/*.* $(datadir)/$(PROJECT)/sake.d + install --verbose --compare --mode 644 share/milligram/*.* $(datadir)/$(PROJECT)/milligram sed -i -e "s#DATADIR='.*'#DATADIR='$(datadir)'#" $(bindir)/jqt sed -i -e "s#DATADIR='.*'#DATADIR='$(datadir)'#" $(bindir)/sake diff --git a/bin/sake b/bin/sake index 427a1c4..f1d82ae 100755 --- a/bin/sake +++ b/bin/sake @@ -12,8 +12,7 @@ shopt -s expand_aliases declare -r SELF=${0##*/} # Exported to use in makefiles and Sakefile -declare -xr DATADIR='/usr/local/share' -declare -xr SAKE="${DATADIR}/jqt/sake" +declare -xr JQTLIB='/usr/local/share/jqt' # GMake call declare -ri CORES=2 @@ -55,13 +54,17 @@ case $1 in | awk '/^[^ \t.%][-A-Za-z0-9_.]*:/ { print $1 }' \ | sort --unique \ | sed 's/:\+$//' \ - | pr --omit-pagination --indent=4 --width=80 --columns=5 + | pr --omit-pagination --width=80 --columns=6 ;; touch) if test -e config.yaml; then touch config.yaml; else touch config.json; fi shift _sake build "$@" ;; + clober) + shift + _sake clobber "$@" + ;; *) _sake "$@" ;; diff --git a/docs/Sakefile b/docs/Sakefile index 03aa2d6..befbb6e 100644 --- a/docs/Sakefile +++ b/docs/Sakefile @@ -20,16 +20,18 @@ #VERBOSE := 1 #TRACE := 1 #VNU := java -jar /usr/local/vnu/vnu.jar +#JQTFLAGS += ... ######################################################################## # Starting makefile ######################################################################## -include $(SAKE)/make.d/main.make +include $(JQTLIB)/sake.d/main.make ######################################################################## # Last phase, after metadata configuration. ######################################################################## + ifdef __build # Add some Pandoc options @@ -39,10 +41,22 @@ JQTFLAGS += -5 --toc-depth=4 # experimental ######################################################################## +# TODO: new, help, man page, SITE section on web, taxonomies (flags, series...) + +# Remove? +#$(PagesHTML): $(Root)/%.html : $(Meta)/pages/%.json +#$(PagesHTML): $(Root)/blog/%.html : $(Meta)/pages/blog/%.json + + +# TODO: show content pending to render? +#newer: $(Meta)/lastbuild + + +# TODO: move to phase3 depend: grep -r '<%include\s\+[^>]\+>' blocks/ layouts/\ | sed -e 's/:.*<%include\s\+/\t/;s/>.*$$//' \ - | sort + | jq -nrR -f ./phase3_layout.jq --arg Layouts $(Layouts) endif # __build diff --git a/docs/config.yaml b/docs/config.yaml index f1a4271..b354ac4 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -55,7 +55,6 @@ defaults: Datasets: - snippets.md Dependencies: - - layouts/default.html - content/macros.m - content/LINKS.txt # Flags: diff --git a/docs/phase3_layout.jq b/docs/phase3_layout.jq new file mode 100644 index 0000000..be7ed44 --- /dev/null +++ b/docs/phase3_layout.jq @@ -0,0 +1,29 @@ +######################################################################## +# phase3_layout.jq -- Define contents for `$(Meta)/phase3_layout.json`. +# +# jq -nRr -f phase3_layout.jq +# < ... +# > $(Meta)/phase3_layout.json + +def makedepend: + def branch($root; $tree): + def _branch: + if in($tree) + then . , ($tree[.][] | _branch) + else . + end + ; + [$root | _branch][1:] | sort + ; + reduce inputs as $line ({}; ($line/"\t") as [$key,$value] | .[$key]+=[$value]) + | . as $tree + | reduce keys_unsorted[] as $r ({}; .[$r]=branch($r; $tree)) + | . as $dependents + | $tree | keys[] + | select(startswith($Layouts+"/")) + | "\(.): \($dependents[.] | join(" "))" +; + +makedepend + +# vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq diff --git a/share/sake/milligram/BEM.m b/share/milligram/BEM.m similarity index 100% rename from share/sake/milligram/BEM.m rename to share/milligram/BEM.m diff --git a/share/sake/milligram/COLORNAMES.m b/share/milligram/COLORNAMES.m similarity index 100% rename from share/sake/milligram/COLORNAMES.m rename to share/milligram/COLORNAMES.m diff --git a/share/sake/milligram/Normalize.css b/share/milligram/Normalize.css similarity index 100% rename from share/sake/milligram/Normalize.css rename to share/milligram/Normalize.css diff --git a/share/sake/milligram/base.css b/share/milligram/base.css similarity index 100% rename from share/sake/milligram/base.css rename to share/milligram/base.css diff --git a/share/sake/milligram/blockquote.css b/share/milligram/blockquote.css similarity index 100% rename from share/sake/milligram/blockquote.css rename to share/milligram/blockquote.css diff --git a/share/sake/milligram/button.css b/share/milligram/button.css similarity index 100% rename from share/sake/milligram/button.css rename to share/milligram/button.css diff --git a/share/sake/milligram/code.css b/share/milligram/code.css similarity index 100% rename from share/sake/milligram/code.css rename to share/milligram/code.css diff --git a/share/sake/milligram/color.css b/share/milligram/color.css similarity index 100% rename from share/sake/milligram/color.css rename to share/milligram/color.css diff --git a/share/sake/milligram/divider.css b/share/milligram/divider.css similarity index 100% rename from share/sake/milligram/divider.css rename to share/milligram/divider.css diff --git a/share/sake/milligram/form.css b/share/milligram/form.css similarity index 100% rename from share/sake/milligram/form.css rename to share/milligram/form.css diff --git a/share/sake/milligram/grid.css b/share/milligram/grid.css similarity index 100% rename from share/sake/milligram/grid.css rename to share/milligram/grid.css diff --git a/share/sake/milligram/image.css b/share/milligram/image.css similarity index 100% rename from share/sake/milligram/image.css rename to share/milligram/image.css diff --git a/share/sake/milligram/link.css b/share/milligram/link.css similarity index 100% rename from share/sake/milligram/link.css rename to share/milligram/link.css diff --git a/share/sake/milligram/list.css b/share/milligram/list.css similarity index 100% rename from share/sake/milligram/list.css rename to share/milligram/list.css diff --git a/share/sake/milligram/spacing.css b/share/milligram/spacing.css similarity index 100% rename from share/sake/milligram/spacing.css rename to share/milligram/spacing.css diff --git a/share/sake/milligram/table.css b/share/milligram/table.css similarity index 100% rename from share/sake/milligram/table.css rename to share/milligram/table.css diff --git a/share/sake/milligram/typography.css b/share/milligram/typography.css similarity index 100% rename from share/sake/milligram/typography.css rename to share/milligram/typography.css diff --git a/share/sake/milligram/utility.css b/share/milligram/utility.css similarity index 100% rename from share/sake/milligram/utility.css rename to share/milligram/utility.css diff --git a/share/sake/make.d/configuration.make b/share/sake.d/configuration.make similarity index 100% rename from share/sake/make.d/configuration.make rename to share/sake.d/configuration.make diff --git a/share/sake/make.d/main.make b/share/sake.d/main.make similarity index 88% rename from share/sake/make.d/main.make rename to share/sake.d/main.make index d31498c..abfef02 100644 --- a/share/sake/make.d/main.make +++ b/share/sake.d/main.make @@ -2,8 +2,7 @@ # main.make -- Main makefile. # # Imported variables: -# SAKE -# DATADIR +# JQTDIR # # Variables: # Meta @@ -51,20 +50,9 @@ endif # Check command line sanity. ######################################################################## -# TODO: check only one target is present? - -# Target 'clean' must be alone. -ifeq (clean,$(filter clean,$(MAKECMDGOALS))) +# Check only one target is present. ifneq (1,$(words $(MAKECMDGOALS))) -$(error Target "clean" must be alone) -endif -endif - -# Target 'clobber' must be alone. -ifeq (clobber,$(filter clobber,$(MAKECMDGOALS))) -ifneq (1,$(words $(MAKECMDGOALS))) -$(error Target "clobber" must be alone) -endif +$(error Only one target accepted) endif # Do not build to clobber immediately. @@ -74,13 +62,6 @@ $(error Nothing to clobber) endif endif -## Do not build to clean immediately. -#ifeq (clean,$(filter clean,$(MAKECMDGOALS))) -#ifeq (,$(wildcard $(Meta))) -#$(error Nothing to clean) -#endif -#endif - ######################################################################## # Include all makefile phases. ######################################################################## diff --git a/share/sake/make.d/phase1.jq b/share/sake.d/phase1.jq similarity index 100% rename from share/sake/make.d/phase1.jq rename to share/sake.d/phase1.jq diff --git a/share/sake/make.d/phase1.make b/share/sake.d/phase1.make similarity index 100% rename from share/sake/make.d/phase1.make rename to share/sake.d/phase1.make diff --git a/share/sake/make.d/phase1_site.jq b/share/sake.d/phase1_site.jq similarity index 100% rename from share/sake/make.d/phase1_site.jq rename to share/sake.d/phase1_site.jq diff --git a/share/sake/make.d/phase2.jq b/share/sake.d/phase2.jq similarity index 100% rename from share/sake/make.d/phase2.jq rename to share/sake.d/phase2.jq diff --git a/share/sake/make.d/phase2.make b/share/sake.d/phase2.make similarity index 100% rename from share/sake/make.d/phase2.make rename to share/sake.d/phase2.make diff --git a/share/sake/make.d/phase2_page.jq b/share/sake.d/phase2_page.jq similarity index 100% rename from share/sake/make.d/phase2_page.jq rename to share/sake.d/phase2_page.jq diff --git a/share/sake/make.d/phase3.jq b/share/sake.d/phase3.jq similarity index 75% rename from share/sake/make.d/phase3.jq rename to share/sake.d/phase3.jq index 6fb2f3f..cc9fc60 100644 --- a/share/sake/make.d/phase3.jq +++ b/share/sake.d/phase3.jq @@ -18,13 +18,13 @@ def dependencies: else "" end + if .Datasets - then " " + ([.Datasets[] | basename | "\($Meta)/\(.).json"] | join(" ")) + then " " + ([.Datasets[] | basename | "$(Meta)/\(.).json"] | join(" ")) else "" end ; def dataset: if .Datasets - then " " + ([.Datasets[] | basename | "-m\(.):\($Meta)/\(.).json"] | join(" ")) + then " " + ([.Datasets[] | basename | "-m\(.):$(Meta)/\(.).json"] | join(" ")) else "" end ; @@ -35,11 +35,11 @@ def flags: ; def page: - " -mpage:\($Meta)/pages/\(.Id).json" + " -mpage:$(Meta)/pages/\(.Id).json" ; def layout: - " \($Layouts)/\(.Layout).html" + " $(Layouts)/\(.Layout).html" ; # _site/jqt/index.html: content/index.md layouts/page.html content/macros.m content/LINKS.txt content/EXAMPLE.txt @@ -50,17 +50,27 @@ def layout: # $(info ==> $@) # @$(JQT) -d $< -mpage:.meta/pages/blog/2017-04-13-hello.json layouts/page.html | $(DETAILS) > $@ def page_rule: + .[] | $Root+"/"+.URL+": " + .Source + layout + dependencies, "\t$(info ==> $@)", "\t@$(JQT) -d $<" + dataset + flags + page + layout + " | $(DETAILS) > $@" ; +# %.html: _site/%.html ; +# blog/%.html: _site/blog/%.html ; +def page_target: + map(.Path) + | unique[] + | "\(.)%.html: $(Root)/\(.)%.html ;" +; + # # Output makefile # "__phase_3 := 1\n", -(.[] | page_rule), # for each page +page_target, # for each path +page_rule, # for each page "\n# \u0076im:syntax=make" # vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq diff --git a/share/sake/make.d/phase3.make b/share/sake.d/phase3.make similarity index 95% rename from share/sake/make.d/phase3.make rename to share/sake.d/phase3.make index dbe6b70..7922028 100644 --- a/share/sake/make.d/phase3.make +++ b/share/sake.d/phase3.make @@ -56,8 +56,7 @@ endef # Extra prerequisites for HTML pages. # -$(PagesHTML): $(Root)/%.html : $(Meta)/pages/%.json -$(PagesHTML): $(Meta)/phase3.make $(Blocks)/*/markup.html $(Blocks)/*/*/markup.html \ +$(PagesHTML): $(Meta)/phase3.make \ | $$(dir $$@) # Content example for `$(Meta)/phase3.make`: @@ -84,6 +83,7 @@ $(PagesHTML): $(Meta)/phase3.make $(Blocks)/*/markup.html $(Blocks)/*/*/markup.h build:: $(PagesHTML) @cp --verbose --recursive --update $(Assets)/* $(Root) \ | sed "s/^.*-> ./==> /;s/.$$//" + date -Iseconds > $(Meta)/lastbuild # Delete secondary files. clobber:: ; @rm -rf *~ *.bak *.log diff --git a/share/sake/make.d/sitemap.jq b/share/sake.d/sitemap.jq similarity index 100% rename from share/sake/make.d/sitemap.jq rename to share/sake.d/sitemap.jq diff --git a/share/sake/make.d/sitemap.make b/share/sake.d/sitemap.make similarity index 100% rename from share/sake/make.d/sitemap.make rename to share/sake.d/sitemap.make diff --git a/share/sake/make.d/styles.make b/share/sake.d/styles.make similarity index 72% rename from share/sake/make.d/styles.make rename to share/sake.d/styles.make index 599f30c..4828ed1 100644 --- a/share/sake/make.d/styles.make +++ b/share/sake.d/styles.make @@ -4,13 +4,12 @@ # Exported rules for: # $(Root)/styles.css -# DATADIR defined in `sake` script. -_sake := $(DATADIR)/jqt/sake +# JQTLIB defined in `sake` script. # Secondary prerequisites. $(Root)/styles.css: \ - $(_sake)/milligram/*.css \ - $(_sake)/milligram/*.m \ + $(JQTLIB)/milligram/*.css \ + $(JQTLIB)/milligram/*.m \ $(Styles)/*.css \ $(Blocks)/*/style.css \ $(Blocks)/*/*/style.css \ @@ -18,7 +17,7 @@ $(Root)/styles.css: \ $(Root)/styles.css: $(Styles)/main.css $(THIS) \ | $(Root) $(info ==> $@) - jqt -P CSS-min -I$(_sake) -I$(Styles) < $< > $@ + jqt -P CSS-min -I$(JQTLIB) -I$(Styles) < $< > $@ build:: $(Root)/styles.css diff --git a/share/sake/make.d/tools.make b/share/sake.d/tools.make similarity index 100% rename from share/sake/make.d/tools.make rename to share/sake.d/tools.make