-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
130 lines (101 loc) · 3.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
SHELL := /bin/bash
ifdef METANORMA_DOCKER
METANORMA_PREFIX_CMD := >&2 echo "Running via docker..."; docker run -v "$$(pwd)":/metanorma/ $(METANORMA_DOCKER)
else
METANORMA_PREFIX_CMD := >&2 echo "Running locally..."; BUNDLE_GEMFILE=src-documents/Gemfile bundle exec
endif
.PHONY: all
## Install dependencies, build Jekyll site, then build all the documents in parallel
all: prep build-all-parallel
.PHONY: clean
## Clean up generated files
clean:
rm -rf _site
# `bundle` command alias just for Jekyll
JEKYLL_BUNDLE = bundle
# This is used to generate `metanorma.source.files` for each doc type,
# which is the same as `DOC_TYPES` except for `public-review` and
# `pending-publication`.
REPOPULATING_DOC_TYPES := \
administrative \
standard \
report \
directive \
specification \
advisory \
amendment \
technical-corrigendum \
guide \
# This is used to generate `make` targets for each doc type.
DOC_TYPES := \
$(REPOPULATING_DOC_TYPES) \
public-review \
pending-publication \
define DOC_TYPE_TASKS
.PHONY: repopulate-metanorma-yaml-$(doc_type)
## Update Metanorma YAML file (`metanorma.source.files`) for $(doc_type)
repopulate-metanorma-yaml-$(doc_type):
DOC_TYPE=$(doc_type) \
DOC_CLASS=cc \
EMPTY_ADOC=src-documents/empty_index.adoc \
scripts/repopulate-metanorma-yaml src-documents src-documents/metanorma-$(doc_type).yml
.PHONY: build-$(doc_type)
## Build Metanorma document artifacts for $(doc_type)
build-$(doc_type):
$(METANORMA_PREFIX_CMD) metanorma site generate \
-o _site/$(doc_type) \
-c ./src-documents/metanorma-$(doc_type).yml
endef
$(foreach doc_type,$(DOC_TYPES),$(eval $(DOC_TYPE_TASKS)))
.PHONY: repopulate-metanorma-yamls
## Update Metanorma YAML files (`metanorma.source.files`) for all doc types
repopulate-metanorma-yamls: $(addprefix repopulate-metanorma-yaml-,$(REPOPULATING_DOC_TYPES))
.PHONY: repopulate-metanorma-yamls-parallel
## Update Metanorma YAML files (`metanorma.source.files`) for all doc types in parallel
repopulate-metanorma-yamls-parallel:
$(foreach doc_type,$(REPOPULATING_DOC_TYPES),make repopulate-metanorma-yaml-$(doc_type) &) wait
.PHONY: build
## Build all the documents in sequence
build: $(addprefix build-,$(DOC_TYPES))
.PHONY: build-all
## Build Jekyll, then build all the documents in sequence
build-all: _site build
.PHONY: build-parallel
## Build all the documents in parallel
build-parallel:
$(foreach doc_type,$(DOC_TYPES),make build-$(doc_type) &) wait
.PHONY: build-all-parallel
## Build Jekyll, then build all the documents in parallel
build-all-parallel: _site build-parallel
.PHONY: prep
## Checkout document modules and install dependencies
prep: checkout-modules prep-jekyll prep-metanorma
.PHONY: prep-metanorma
## Install Metanorma dependencies
prep-metanorma:
BUNDLE_GEMFILE=src-documents/Gemfile bundle install
.PHONY: prep-jekyll
## Install Jekyll dependencies
prep-jekyll:
$(JEKYLL_BUNDLE) install
.PHONY: jekyll
## Build Jekyll site
jekyll:
$(JEKYLL_BUNDLE) exec jekyll build
## Build Jekyll site
_site: jekyll
.PHONY: serve
## Serve Jekyll site
serve:
$(JEKYLL_BUNDLE) exec jekyll serve
.PHONY: checkout-modules
## Initialize and checkout submodules (e.g., Metanorma documents)
checkout-modules:
git submodule update --init
.PHONY: update-modules
## Pull latest changes from submodules (e.g., Metanorma documents)
update-modules:
git submodule foreach git pull origin main
.PHONY: update-documents
## Update Metanorma documents
update-documents: update-modules repopulate-metanorma-yamls-parallel