From 881753ce3e5a11c23749159fd168bded11b9a54a Mon Sep 17 00:00:00 2001 From: Thomas Hallgren Date: Mon, 22 Oct 2018 23:38:56 +0200 Subject: [PATCH] doc/Makefile: incremental and parallel rebuild of the synopsis Enough dependencies have been added so that * If nothing has changed, MkSynopsis.hs will not be run, so synopisis.html will not be needlessly regenerated. * You can use 'make -j' to build examples for different languages in parallel. Hopefully 'make synopsis' produces the exact same result as before, but if it turns out that some dependencies are missing and something is not rebuilt despite of changes, 'make clean' can be used to force a full rebuild. --- doc/Makefile | 77 +++++++++++++++++++++-------------------------- doc/MkExxTable.hs | 4 +-- doc/MkSynopsis.hs | 6 ++-- 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 4fee45382..e7f51b357 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,56 +1,49 @@ -.PHONY: abstract synopsis +.PHONY: abstract synopsis index status -all: exx synopsis +all: synopsis GF_alltenses=$(GF_LIB_PATH)/alltenses +GF=gf +GFDOC=gfdoc index: txt2tags -thtml index.txt status: txt2tags -thtml status.txt -synopsis: - runghc MkSynopsis.hs + +synopsis: synopsis.html + +S=../src + +# List of languages extracted from MkSynopsis.hs +LANGS=Afr Bul Cat Chi Dan Dut Eng Est Eus Fin Fre Ger Gre Hin Ice Ita Jpn Lav Mlt Mon Nep Nor Nno Pes Pnb Pol Ron Rus Snd Spa Swe Tha Urd + +# This list was constructed by observing what files MkSynopsis.hs reads +SRC_FILES=$S/abstract/Common.gf $S/abstract/Cat.gf $S/api/Constructors.gf $S/abstract/Structural.gf $(patsubst %,$S/*/Paradigms%.gf,$(LANGS)) + +EXAMPLES_OUT=$(patsubst %,api-examples-%.txt,$(LANGS)) + +synopsis.html: $(EXAMPLES_OUT) $(SRC_FILES) + runghc MkSynopsis.hs >out categories-imagemap.html: categories.dot dot -Tcmapx $^ > $@ abstract: - gfdoc -txthtml ../src/abstract/*.gf - mv ../src/abstract/*.html abstract + $(GFDOC) -txthtml $S/abstract/*.gf + mv $S/abstract/*.html abstract -exx-script: - runghc MkExx.hs api-examples.gfs -exx: exx-script - gf -retain -s $(GF_alltenses)/TryAfr.gfo api-examples-Afr.txt - gf -retain -s $(GF_alltenses)/TryBul.gfo api-examples-Bul.txt - gf -retain -s $(GF_alltenses)/TryCat.gfo api-examples-Cat.txt - gf -retain -s $(GF_alltenses)/TryChi.gfo api-examples-Chi.txt - gf -retain -s $(GF_alltenses)/TryDan.gfo api-examples-Dan.txt - gf -retain -s $(GF_alltenses)/TryDut.gfo api-examples-Dut.txt - gf -retain -s $(GF_alltenses)/TryEng.gfo api-examples-Eng.txt - gf -retain -s $(GF_alltenses)/TryEst.gfo api-examples-Est.txt - gf -retain -s $(GF_alltenses)/TryEus.gfo api-examples-Eus.txt - gf -retain -s $(GF_alltenses)/TryFin.gfo api-examples-Fin.txt - gf -retain -s $(GF_alltenses)/TryFre.gfo api-examples-Fre.txt - gf -retain -s $(GF_alltenses)/TryGer.gfo api-examples-Ger.txt - gf -retain -s $(GF_alltenses)/TryGre.gfo api-examples-Gre.txt - gf -retain -s $(GF_alltenses)/TryHin.gfo api-examples-Hin.txt - gf -retain -s $(GF_alltenses)/TryIce.gfo api-examples-Ice.txt - gf -retain -s $(GF_alltenses)/TryIta.gfo api-examples-Ita.txt - gf -retain -s $(GF_alltenses)/TryJpn.gfo api-examples-Jpn.txt - gf -retain -s $(GF_alltenses)/TryLav.gfo api-examples-Lav.txt - gf -retain -s $(GF_alltenses)/TryMlt.gfo api-examples-Mlt.txt - gf -retain -s $(GF_alltenses)/TryMon.gfo api-examples-Mon.txt - gf -retain -s $(GF_alltenses)/TryNep.gfo api-examples-Nep.txt - gf -retain -s $(GF_alltenses)/TryNor.gfo api-examples-Nor.txt - gf -retain -s $(GF_alltenses)/TryNno.gfo api-examples-Nno.txt - gf -retain -s $(GF_alltenses)/TryPes.gfo api-examples-Pes.txt - gf -retain -s $(GF_alltenses)/TryPnb.gfo api-examples-Pnb.txt - gf -retain -s $(GF_alltenses)/TryPol.gfo api-examples-Pol.txt - gf -retain -s $(GF_alltenses)/TryRon.gfo api-examples-Ron.txt - gf -retain -s $(GF_alltenses)/TryRus.gfo api-examples-Rus.txt - gf -retain -s $(GF_alltenses)/TrySnd.gfo api-examples-Snd.txt - gf -retain -s $(GF_alltenses)/TrySpa.gfo api-examples-Spa.txt - gf -retain -s $(GF_alltenses)/TrySwe.gfo api-examples-Swe.txt - gf -retain -s $(GF_alltenses)/TryTha.gfo api-examples-Tha.txt - gf -retain -s $(GF_alltenses)/TryUrd.gfo api-examples-Urd.txt + +api-examples.gfs: api-examples.txt + runghc MkExx.hs < $< > $@ + + +# Since .gfo files aren't self-contained, the dependencies given here are +# incomplete. But I am thinking that the Try%.gfo file will always be newer +# than any other files it depends on, so the rule will trigger when +# needed anyway. //TH 2018-10-22 +api-examples-%.txt: $(GF_alltenses)/Try%.gfo api-examples.gfs + GF_LIB_PATH=$(GF_LIB_PATH) $(GF) -retain -s $< $@ + +clean: + rm -rf out synopsis.txt api-examples.gfs $(EXAMPLES_OUT) diff --git a/doc/MkExxTable.hs b/doc/MkExxTable.hs index a7b8a47ca..7fff127af 100644 --- a/doc/MkExxTable.hs +++ b/doc/MkExxTable.hs @@ -1,7 +1,7 @@ module MkExxTable (getApiExx, ApiExx, prApiEx, mkEx) where -import System.Cmd -import System.Environment +--import System.Cmd +import System.Environment(getArgs) import qualified Data.Map as M import Data.Char diff --git a/doc/MkSynopsis.hs b/doc/MkSynopsis.hs index 709de13d9..859ac0678 100644 --- a/doc/MkSynopsis.hs +++ b/doc/MkSynopsis.hs @@ -1,6 +1,6 @@ import MkExxTable -import System.Cmd -import System.Environment +import System.Process(system) +import System.Environment(getArgs) import Data.Char import Data.List import qualified Data.ByteString.Char8 as BS @@ -16,7 +16,7 @@ synopsis = "synopsis.txt" -- the language in which revealed examples are shown revealedLang = "Eng" --- all languages shown +-- all languages shown (a copy of this list appears in Makefile) apiExxFiles = ["api-examples-" ++ lang ++ ".txt" | lang <- words -- "Eng Chi" "Afr Bul Cat Chi Dan Dut Eng Est Eus Fin Fre Ger Gre Hin Ice Ita Jpn Lav Mlt Mon Nep Nor Nno Pes Pnb Pol Ron Rus Snd Spa Swe Tha Urd"