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 d0754b17b..2a1b49812 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,8 +7,6 @@ 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 @@ -31,15 +29,6 @@ SHELL = bash .DELETE_ON_ERROR: am__remove_distdir = -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 - BUILT_SOURCES = .version .version: $(shell test -e .git && awk '{print ".git/" $$2}' .git/HEAD) @@ -109,38 +98,6 @@ update_libtexpdf: gh-pages: git worktree add -f $@ $@ -.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 $<) - DEPDIR := .deps REGRESSIONSCRIPT := ./tests/regressions.pl LOCALTESTFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf @@ -370,6 +327,9 @@ include $(wildcard $(DEPFILES)) # Actual rules for downloading test fonts are in a separate file include Makefile-fonts +# All LuaRocks handling stuff consolidated +include Makefile-luarocks + CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL) Makefile-distfiles .PHONY: docker