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
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')
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')
MARKDOWN_FILES := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(AGDA_FILES))))
PLFA_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PANDOC := pandoc
@ -21,6 +21,12 @@ else
AGDA_STDLIB_URL := https://agda.github.io/agda-stdlib/v$(AGDA_STDLIB_VERSION)/
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
default: test
@ -52,11 +58,14 @@ build-incremental: $(MARKDOWN_FILES)
# Download PLFA web releases
build-history: latest/ $(RELEASES)
latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION))) | .versions/
cd $< && $(JEKYLL) clean && $(JEKYLL) build --destination '../../latest' --baseurl '/latest'
latest/: $(addprefix .versions/plfa.github.io-web-,$(addsuffix /,$(LATEST_VERSION)))
cd $< \
&& $(JEKYLL) clean \
&& $(JEKYLL) build --destination '../../latest' --baseurl '/latest'
# Download PLFA web release and build it under the relevant folder
define build_release
version := $(1)
out := $(addsuffix /,$(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)))
@ -66,12 +75,15 @@ baseurl := $(addprefix /,$(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):
@mkdir -p .versions/
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_zip = $(addprefix .versions/plfa.github.io-web-,$(addsuffix .zip,$(1)))
$$(tmp_dir): $$(tmp_zip) | .versions/
unzip -qq $$(tmp_zip) -d .versions/
$$(tmp_dir): $$(tmp_zip)
yes | unzip -qq $$(tmp_zip) -d .versions/
$(SEDI) "s/branch: dev/branch: dev-$$(version)/" $$(addsuffix _config.yml,$$(tmp_dir))
$$(out): out = $(addsuffix /,$(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
$(foreach release_version,$(RELEASE_VERSIONS),$(eval $(call build_release,$(release_version))))
.versions/:
mkdir -p .versions/
# Convert literal Agda to Markdown using highlight.sh
define AGDA_template
in := $(1)
out := $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
$$(out) : in = $(1)
$$(out) : out = $(subst courses/,out/,$(subst src/,out/,$(subst .lagda.md,.md,$(1))))
$$(out) : $$(in) | out/
$$(out) : $$(in)
@echo "Processing $$(subst ./,,$$(in))"
@mkdir -p out/
ifeq (,$$(findstring courses/,$$(in)))
./highlight.sh $$(subst ./,,$$(in)) --include-path=src/
else
@ -126,9 +135,6 @@ test-stable-offline: $(MARKDOWN_FILES)
$(JEKYLL) build --destination '_site/stable' --baseurl '/stable'
$(HTMLPROOFER) '_site' --disable-external
out/:
mkdir -p out/
.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
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 \
--css=epub/main.css \
--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
out/epub/acknowledgements.md: src/plfa/acknowledgements.md _config.yml
@mkdir -p out/epub/
$(BUNDLE) exec ruby epub/render-liquid-template.rb _config.yml $< $@
out/epub/:
mkdir -p out/epub/
.phony: epub epubcheck
# Clean auxiliary files
clean:
rm -f .agda-stdlib.sed .links-*.sed out/epub/acknowledgements.md
rm -f plfa.github.io-web-*.zip
rm -rf plfa.github.io-web-*/
rm -rf .versions
ifneq ($(strip $(AGDAI_FILES)),)
rm $(AGDAI_FILES)
endif
@ -178,6 +182,7 @@ endif
clobber: clean
$(JEKYLL) clean
rm -rf out/
rm -rf latest/ $(RELEASES)
.phony: clean clobber

View file

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