This commit is contained in:
Jeremy Siek 2020-07-15 17:06:50 -04:00
commit f1ef20e35c
2 changed files with 32 additions and 28 deletions

View file

@ -1,6 +1,6 @@
SHELL := /usr/bin/env bash SHELL := /usr/bin/env bash
AGDA_FILES := $(shell find . -type f -and \( -path '*/src/*' -or -path '*/courses/*' \) -and -name '*.lagda.md') AGDA_FILES := $(shell find . -type f -and \( -path './src/*' -or -path './courses/*' \) -and -name '*.lagda.md')
AGDAI_FILES := $(shell find . -type f -and \( -path '*/src/*' -or -path '*/courses/*' \) -and -name '*.agdai') AGDAI_FILES := $(shell find . -type f -and \( -path './src/*' -or -path './courses/*' \) -and -name '*.agdai')
MARKDOWN_FILES := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(AGDA_FILES)))) MARKDOWN_FILES := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(AGDA_FILES))))
PLFA_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) PLFA_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PANDOC := pandoc PANDOC := pandoc
@ -21,6 +21,12 @@ else
AGDA_STDLIB_URL := https://agda.github.io/agda-stdlib/v$(AGDA_STDLIB_VERSION)/ AGDA_STDLIB_URL := https://agda.github.io/agda-stdlib/v$(AGDA_STDLIB_VERSION)/
endif endif
ifeq ($(shell sed --version >/dev/null 2>&1; echo $$?),1)
SEDI := sed -i ""
else
SEDI := sed -i
endif
# Build PLFA web version and test links # Build PLFA web version and test links
default: test default: test
@ -52,11 +58,14 @@ build-incremental: $(MARKDOWN_FILES)
# Download PLFA web releases # Download PLFA web releases
build-history: latest/ $(RELEASES) build-history: latest/ $(RELEASES)
latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION))) | .versions/ latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION)))
cd $< && $(JEKYLL) clean && $(JEKYLL) build --destination '../../latest' --baseurl '/latest' cd $< \
&& $(JEKYLL) clean \
&& $(JEKYLL) build --destination '../../latest' --baseurl '/latest'
# Download PLFA web release and build it under the relevant folder # Download PLFA web release and build it under the relevant folder
define build_release define build_release
version := $(1)
out := $(addsuffix /,$(1)) out := $(addsuffix /,$(1))
url := $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1))) url := $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
tmp_zip := $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1))) tmp_zip := $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
@ -66,12 +75,15 @@ baseurl := $(addprefix /,$(1))
$$(tmp_zip): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1))) $$(tmp_zip): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
$$(tmp_zip): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1))) $$(tmp_zip): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
$$(tmp_zip): $$(tmp_zip):
@mkdir -p .versions/
wget -c $$(url) -O $$(tmp_zip) wget -c $$(url) -O $$(tmp_zip)
$$(tmp_dir): version = $(1)
$$(tmp_dir): tmp_dir = $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(1))) $$(tmp_dir): tmp_dir = $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(1)))
$$(tmp_dir): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1))) $$(tmp_dir): tmp_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
$$(tmp_dir): $$(tmp_zip) | .versions/ $$(tmp_dir): $$(tmp_zip)
unzip -qq $$(tmp_zip) -d .versions/ yes | unzip -qq $$(tmp_zip) -d .versions/
$(SEDI) "s/branch: dev/branch: dev-$$(version)/" $$(addsuffix _config.yml,$$(tmp_dir))
$$(out): out = $(addsuffix /,$(1)) $$(out): out = $(addsuffix /,$(1))
$$(out): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1))) $$(out): url = $(addprefix https://github.com/plfa/plfa.github.io/archive/web-,$(addsuffix .zip,$(1)))
@ -87,18 +99,15 @@ endef
# Incorporate previous releases of PLFA web version # Incorporate previous releases of PLFA web version
$(foreach release_version,$(RELEASE_VERSIONS),$(eval $(call build_release,$(release_version)))) $(foreach release_version,$(RELEASE_VERSIONS),$(eval $(call build_release,$(release_version))))
.versions/:
mkdir -p .versions/
# Convert literal Agda to Markdown using highlight.sh # Convert literal Agda to Markdown using highlight.sh
define AGDA_template define AGDA_template
in := $(1) in := $(1)
out := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1)))) out := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
$$(out) : in = $(1) $$(out) : in = $(1)
$$(out) : out = $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1)))) $$(out) : out = $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
$$(out) : $$(in) | out/ $$(out) : $$(in)
@echo "Processing $$(subst ./,,$$(in))" @echo "Processing $$(subst ./,,$$(in))"
@mkdir -p out/
ifeq (,$$(findstring courses/,$$(in))) ifeq (,$$(findstring courses/,$$(in)))
./highlight.sh $$(subst ./,,$$(in)) --include-path=src/ ./highlight.sh $$(subst ./,,$$(in)) --include-path=src/
else else
@ -126,9 +135,6 @@ test-stable-offline: $(MARKDOWN_FILES)
$(JEKYLL) build --destination '_site/stable' --baseurl '/stable' $(JEKYLL) build --destination '_site/stable' --baseurl '/stable'
$(HTMLPROOFER) '_site' --disable-external $(HTMLPROOFER) '_site' --disable-external
out/:
mkdir -p out/
.phony: test test-offline test-stable-offline .phony: test test-offline test-stable-offline
@ -139,7 +145,8 @@ epub: out/epub/plfa.epub
epubcheck: out/epub/plfa.epub epubcheck: out/epub/plfa.epub
$(EPUBCHECK) out/epub/plfa.epub $(EPUBCHECK) out/epub/plfa.epub
out/epub/plfa.epub: out/epub/ | $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epub/acknowledgements.md out/epub/plfa.epub: $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epub/acknowledgements.md
@mkdir -p out/epub/
$(PANDOC) --strip-comments \ $(PANDOC) --strip-comments \
--css=epub/main.css \ --css=epub/main.css \
--epub-embed-font='assets/fonts/mononoki.woff' \ --epub-embed-font='assets/fonts/mononoki.woff' \
@ -157,19 +164,16 @@ out/epub/plfa.epub: out/epub/ | $(AGDA_FILES) $(LUA_FILES) epub/main.css out/epu
epub/index.md epub/index.md
out/epub/acknowledgements.md: src/plfa/acknowledgements.md _config.yml out/epub/acknowledgements.md: src/plfa/acknowledgements.md _config.yml
@mkdir -p out/epub/
$(BUNDLE) exec ruby epub/render-liquid-template.rb _config.yml $< $@ $(BUNDLE) exec ruby epub/render-liquid-template.rb _config.yml $< $@
out/epub/:
mkdir -p out/epub/
.phony: epub epubcheck .phony: epub epubcheck
# Clean auxiliary files # Clean auxiliary files
clean: clean:
rm -f .agda-stdlib.sed .links-*.sed out/epub/acknowledgements.md rm -f .agda-stdlib.sed .links-*.sed out/epub/acknowledgements.md
rm -f plfa.github.io-web-*.zip rm -rf .versions
rm -rf plfa.github.io-web-*/
ifneq ($(strip $(AGDAI_FILES)),) ifneq ($(strip $(AGDAI_FILES)),)
rm $(AGDAI_FILES) rm $(AGDAI_FILES)
endif endif
@ -178,6 +182,7 @@ endif
clobber: clean clobber: clean
$(JEKYLL) clean $(JEKYLL) clean
rm -rf out/ rm -rf out/
rm -rf latest/ $(RELEASES)
.phony: clean clobber .phony: clean clobber

View file

@ -55,16 +55,15 @@ markdown: kramdown
theme: minima theme: minima
excerpt_separator: <!--more--> excerpt_separator: <!--more-->
exclude: exclude:
- "hs/" - "*.lagda.md"
- "extra/"
- "depr/"
- "papers/"
- "slides/"
- "vendor/"
- ".versions/"
- "*.agdai" - "*.agdai"
- "*.agda-lib" - "*.agda-lib"
- "*.lagda.md" - "extra/"
- "papers/"
- "vendor/"
- "epub/"
- ".versions/"
- "_build/"
- "Guardfile" - "Guardfile"
- "Gemfile" - "Gemfile"
- "Gemfile.lock" - "Gemfile.lock"