diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce716870a..f57fe1073 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,12 @@ jobs: .fonts .sources key: fonts-${{ hashFiles('Makefile-fonts') }} + - name: Cache Lua Rocks + uses: actions/cache@v2 + with: + path: | + lua_modules_dist + key: luarocks-${{ hashFiles('Makefile-luarocks', 'sile-dev-1.rockspec') }} - name: Fetch Tags run: git fetch --prune --tags - name: Install System Dependencies diff --git a/Makefile-luarocks b/Makefile-luarocks new file mode 100644 index 000000000..9af2eaa1d --- /dev/null +++ b/Makefile-luarocks @@ -0,0 +1,44 @@ +SUPPORTED_LUAS = 5.3 5.2 5.1 + +LUAROCKS := luarocks --tree lua_modules --lua-version $(LUA_VERSION) + +if !SYSTEM_LUAROCKS +nobase_nodist_pkgdata_DATA = $(LUAMODULES) +LUAMODLOCK := sile-dev-1.rockslock +LUAMODSPEC := sile-dev-1.rockspec +genrockslock := $(LUAROCKS) $(LUAROCKSARGS) list --porcelain | awk '{print $$1 " " $$2}' +rocksmatch := cmp -s $(LUAMODLOCK) <($(genrockslock)) +endif + +.PHONY: installrocks disallow-dist-with-system-luarocks +if !SYSTEM_LUAROCKS +installrocks: $(LUAMODLOCK) $(shell $(rocksmatch) || echo lua_modules) + +lua_modules: $(LUAMODSPEC) $(shell $(rocksmatch) || echo force) + if test -e .git; then + $(LUAROCKS) $(LUAROCKSARGS) install --only-deps $< + else + rm -rf lua_modules + cp -a lua_modules_dist lua_modules + $(foreach LUA,$(filter-out $(LUA_VERSION),$(SUPPORTED_LUAS)), + find lua_modules -maxdepth 3 -type d -name "*$(LUA)" -execdir rm -rf {} \;) + fi + +$(LUAMODLOCK): lua_modules $(LUAMODSPEC) + $(genrockslock) > $@ + +sile: installrocks + +disallow-dist-with-system-luarocks: ; +else +disallow-dist-with-system-luarocks: + $(error In order to make dist you must configure --without-system-luarocks) + exit 1 +endif + +.PHONY: lua_modules_dist +lua_modules_dist: LUAROCKS = luarocks --tree lua_modules_dist +lua_modules_dist: $(LUAMODSPEC) force disallow-dist-with-system-luarocks + $(foreach LUA,$(SUPPORTED_LUAS), + $(LUAROCKS) $(LUAROCKSARGS) --lua-version $(LUA) install --only-deps $<) + diff --git a/Makefile.am b/Makefile.am index 862eef53a..2a1b49812 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,16 +7,20 @@ else SUBDIRS = libtexpdf src endif -SUPPORTED_LUAS = 5.3 5.2 5.1 - MANUAL = documentation/sile.pdf +Makefile-distfiles: build-aux/list-dist-files.sh .version + $< 2>/dev/null > $@ + +include Makefile-distfiles + dist_man_MANS = sile.1 dist_doc_DATA = README.md CHANGELOG.md bin_SCRIPTS = sile -nobase_dist_pkgdata_DATA = $(filter %.lua %.sil,$(shell find core classes languages packages lua-libraries -type f -print)) -EXTRA_DIST = LICENSE spec tests examples documentation sile-dev-1.rockspec build-aux/git-version-gen .version fontconfig.conf -EXTRA_DIST += $(extra_dist) $(MANUAL) $(EXAMPLES) +EXTRA_DIST = LICENSE spec tests examples documentation sile-dev-1.rockspec fontconfig.conf +EXTRA_DIST += .version Makefile-distfiles +EXTRA_DIST += build-aux/git-version-gen build-aux/list-dist-files.sh +EXTRA_DIST += $(LUAMODULESDIST) $(MANUAL) $(EXAMPLES) SHELL = bash .ONESHELL: @@ -25,39 +29,36 @@ SHELL = bash .DELETE_ON_ERROR: am__remove_distdir = -extra_dist = $(shell find lua_modules_dist -type f -print 2>/dev/null ||:) -if !SYSTEM_LUAROCKS -nobase_nodist_pkgdata_DATA = $(shell find lua_modules -type f -print 2>/dev/null ||:) -LUAROCKS := luarocks --tree lua_modules --lua-version $(LUA_VERSION) -LUAMODLOCK := sile-dev-1.rockslock -LUAMODSPEC := sile-dev-1.rockspec -genrockslock := $(LUAROCKS) $(LUAROCKSARGS) list --porcelain | awk '{print $$1 " " $$2}' -rocksmatch := cmp -s $(LUAMODLOCK) <($(genrockslock)) -else -LUAROCKS := luarocks --tree lua_modules_dist --lua-version $(LUA_VERSION) -endif - BUILT_SOURCES = .version .version: $(shell test -e .git && awk '{print ".git/" $$2}' .git/HEAD) - mv $@{,-prev} || touch $@-prev + mv $@{,-prev} 2>/dev/null || touch $@-prev ( test -e .git && ./build-aux/git-version-gen .tarball-version || echo $(VERSION) ) > $@ cmp -s $@{,-prev} || autoreconf configure.ac --force -W none sed -i -e '/rm -f/s/ core / /' configure aclocal.m4 ||: -dist-hook: lua_modules_dist $(MANUAL) $(EXAMPLES) +dist-hook: lua_modules_dist | $(MANUAL) $(EXAMPLES) echo $(VERSION) > $(distdir)/.tarball-version + cp -fa $< $(distdir)/ sed -i -e '/rm -f/s/ core / /' configure aclocal.m4 ||: +_DATA_HOOK_DEPS = if MANUAL -install-data-hook: $(MANUAL) - rm -f "$(DESTDIR)/$(datarootdir)/$<" - install -Dm644 -t "$(DESTDIR)$(docdir)" $< +_DATA_HOOK_DEPS += $(MANUAL) +endif + +if EXAMPLES +_DATA_HOOK_DEPS += $(EXAMPLES) endif +install-data-hook: $(_DATA_HOOK_DEPS) + : +if MANUAL + rm -f "$(DESTDIR)/$(datarootdir)/$<" + install -Dm644 -t "$(DESTDIR)$(docdir)" $(MANUAL) +endif if EXAMPLES -install-data-hook: $(EXAMPLES) - install -Dm644 -t "$(DESTDIR)$(docdir)/examples" $^ + install -Dm644 -t "$(DESTDIR)$(docdir)/examples" $(EXAMPLES) endif # Whether to force tests to run from scratch @@ -97,39 +98,13 @@ update_libtexpdf: gh-pages: git worktree add -f $@ $@ -.PHONY: installrocks -if !SYSTEM_LUAROCKS -installrocks: $(LUAMODLOCK) $(shell $(rocksmatch) || echo lua_modules) - -lua_modules: $(LUAMODSPEC) $(shell $(rocksmatch) || echo force) - if test -e .git; then - $(LUAROCKS) $(LUAROCKSARGS) install --only-deps $< - else - rm -rf lua_modules - cp -a lua_modules_dist lua_modules - $(foreach LUA,$(filter-out $(LUA_VERSION),$(SUPPORTED_LUAS)), - find lua_modules -maxdepth 3 -type d -name "*$(LUA)" -execdir rm -rf {} \;) - fi - -$(LUAMODLOCK): lua_modules $(LUAMODSPEC) - $(genrockslock) > $@ - -sile: installrocks -endif - -.PHONY: lua_modules_dist -lua_modules_dist: $(LUAMODSPEC) force - $(foreach LUA,$(SUPPORTED_LUAS), - $(LUAROCKS) $(LUAROCKSARGS) --lua-version $(LUA) install --only-deps $<) - DEPDIR := .deps REGRESSIONSCRIPT := ./tests/regressions.pl LOCALTESTFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf SILEFLAGS ?= -m $(DEPDIR)/$(basename $@).d -d versions -f fontconfig -TESTSRCS ?= $(wildcard tests/*.sil tests/*.xml) TESTPDFS = $(addsuffix .pdf,$(basename $(TESTSRCS))) -EXPECTEDS ?= $(filter $(addsuffix .expected,$(basename $(TESTSRCS))),$(wildcard tests/*.expected)) +EXPECTEDS ?= $(filter $(addsuffix .expected,$(basename $(TESTSRCS))),$(TESTEXPECTS)) ACTUALS = $(addsuffix .actual,$(basename $(EXPECTEDS))) check: selfcheck @@ -156,7 +131,8 @@ luarocks-lint: $(LUAMODSPEC) luacheck: luacheck -j$(shell nproc) -q . -busted: $(wildcard spec/*_spec.lua) +.PHONY: busted +busted: | $(_INSTALL) all set -f; IFS=';' if SYSTEM_LUAROCKS packagecpath=(./{,core/}?.$(SHARED_LIB_EXT)) @@ -170,8 +146,7 @@ endif .PHONY: docs docs: $(MANUAL) -EXAMPLESSRCS = $(basename $(wildcard examples/*.sil) examples/docbook/article-template.xml) -EXAMPLES = $(addsuffix .pdf,$(EXAMPLESSRCS)) +EXAMPLES = $(addsuffix .pdf,$(basename $(EXAMPLESSRCS))) .PHONY: examples examples: $(EXAMPLES) @@ -197,11 +172,10 @@ if !SYSTEM_LUAROCKS _INSTALL = installrocks endif _FORCED = $(and $(SILE_COVERAGE)$(CLEAN),force) -_MAKE_DEPS = $(wildcard $(DEPDIR)/$*.d) _TEST_DEPS = $(and $(filter tests/%,$@),$(addprefix .fonts/,$(TESTFONTFILES))) _DOCS_DEPS = $(and $(filter docs/%,$@),$(addprefix .fonts/,$(DOCSFONTFILES))) _EXAM_DEPS = $(and $(filter examples/%,$@),$(addprefix .fonts/,$(EXAMFONTFILES))) -patterndeps = $(_FORCED) $(_TEST_DEPS) $(_EXAM_DEPS) $(_DOCS_DEPS) | $(DEPDIRS) $(_MAKE_DEPS) $(_INSTALL) all +patterndeps = $(_FORCED) $(_TEST_DEPS) $(_EXAM_DEPS) $(_DOCS_DEPS) | $(DEPDIRS) $(_INSTALL) all %.pdf: %.sil $$(patterndeps) $(runsile) @@ -353,7 +327,10 @@ include $(wildcard $(DEPFILES)) # Actual rules for downloading test fonts are in a separate file include Makefile-fonts -CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL) +# All LuaRocks handling stuff consolidated +include Makefile-luarocks + +CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL) Makefile-distfiles .PHONY: docker docker: Dockerfile build-aux/docker-entrypoint.sh diff --git a/bootstrap.sh b/bootstrap.sh index 86a9e1663..f760294cc 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -10,6 +10,8 @@ if [ ! -f "libtexpdf/configure.ac" ] && [ -e ".git" ]; then git submodule update --init --recursive --remote fi +touch -d @0 Makefile-distfiles + autoreconf --install -W none # See discussion in https://github.com/sile-typesetter/sile/issues/82 and diff --git a/build-aux/list-dist-files.sh b/build-aux/list-dist-files.sh new file mode 100755 index 000000000..d878e1877 --- /dev/null +++ b/build-aux/list-dist-files.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +echo -n "nobase_dist_pkgdata_DATA =" +find core classes languages packages lua-libraries -type f -name '*.lua' -printf ' %p' +find classes -type f -name '*.sil' -printf ' %p' + +echo -ne "\nLUAMODULES =" +find lua_modules -type f -not -name '*~' -printf ' %p' ||: + +echo -ne "\nLUAMODULESDIST =" +find lua_modules_dist -type f -not -name '*~' -printf ' %p' ||: + +echo -ne "\nTESTSRCS ?=" +find tests -maxdepth 1 -type f -name '*.sil' -printf ' %p' +find tests -maxdepth 1 -type f -name '*.xml' -printf ' %p' + +echo -ne "\nTESTEXPECTS ?=" +find tests -maxdepth 1 -type f -name '*.expected' -printf ' %p' + +echo -ne "\nEXAMPLESSRCS =" +find examples -maxdepth 1 -type f -name '*.sil' -printf ' %p' +find examples/docbook -maxdepth 1 -type f -name '*.xml' -printf ' %p'