-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
231 lines (180 loc) · 7.59 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.PHONY: all tag push check-versions clean tabularasa docroot
PANDOC_VERSION=2.18
REVEALJS_VERSION=4.3.1
ASCIINEMAPLAYER_VERSION=v2.6.1
JQUERY_VERSION=3.6.0.slim.min
IMPRESSJS_VERSION=1.1.0
MERMAID_VERSION=9.0.0
SVGBOB_VERSION=0.5.0-alpha.6
VERSION=0.60.1
MOTTO=rusty version
.PHONY: all target/binaries/markdeck.x86_64-apple-darwin target/binaries/markdeck.x86_64-unknown-linux-musl
all: docroot pandocs binaries docker-image
debug:
time cargo build
pandocs: src/docroot/pandoc-x86_64-apple-darwin src/docroot/pandoc-x86_64-unknown-linux-musl
src/docroot/pandoc-x86_64-apple-darwin:
curl -OL https://github.com/jgm/pandoc/releases/download/$(PANDOC_VERSION)/pandoc-$(PANDOC_VERSION)-macOS.zip
unzip -p pandoc-$(PANDOC_VERSION)-macOS.zip pandoc-$(PANDOC_VERSION)/bin/pandoc > $@
chmod a+rx $@
rm -f pandoc-$(PANDOC_VERSION)-macOS.zip
src/docroot/pandoc-x86_64-unknown-linux-musl:
curl -OL https://github.com/jgm/pandoc/releases/download/$(PANDOC_VERSION)/pandoc-$(PANDOC_VERSION)-linux-amd64.tar.gz
tar zxvOf pandoc-$(PANDOC_VERSION)-linux-amd64.tar.gz pandoc-$(PANDOC_VERSION)/bin/pandoc > $@
chmod a+rx $@
rm -f pandoc-$(PANDOC_VERSION)-linux-amd64.tar.gz
src/docroot/pandoc-aarch64-apple-darwin: src/docroot/pandoc-x86_64-apple-darwin
cp $< $@
binaries: target/binaries/markdeck.x86_64-apple-darwin target/binaries/markdeck.x86_64-unknown-linux-musl target/binaries/markdeck.aarch64-apple-darwin
time upx --best --lzma target/binaries/*x86_64-apple-*
target/binaries/markdeck.x86_64-apple-darwin:
export TARGET=x86_64-apple-darwin
time cargo build --release --target $${TARGET}
mkdir -p target/binaries
cp target/$${TARGET}/release/markdeck $@
target/binaries/markdeck.x86_64-unknown-linux-musl:
export CC_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-gcc
export CXX_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-g++
export AR_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-ar
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-unknown-linux-musl-gcc
export TARGET=x86_64-unknown-linux-musl
time cargo build --release --target $${TARGET}
mkdir -p target/binaries
cp target/$${TARGET}/release/markdeck $@
target/binaries/markdeck.aarch64-apple-darwin:
export TARGET=aarch64-apple-darwin
time cargo build --release --target $${TARGET}
mkdir -p target/binaries
cp target/$${TARGET}/release/markdeck $@
docker-image:
docker build -f docker/Dockerfile.markdeck target/binaries -t arne/markdeck:$(VERSION)
push-image:
docker push arne/markdeck:$(VERSION)
docker tag arne/markdeck:$(VERSION) quay.io/arne/markdeck:$(VERSION)
docker push quay.io/arne/markdeck:$(VERSION)
run-as-container:
mkdir -p example/test
# docker run -it -v $(PWD)/example/:/source:ro -v $(PWD)/example/test/:/target -p 8080:8080 markdeck:$(VERSION)
docker rm -f markdeck
docker run -it -v $(PWD)/example/:/source:ro -p 8080:8080 -e RUST_LOG=debug --name markdeck markdeck:$(VERSION)
debug-container:
docker exec -it markdeck ash
images.built: Makefile docker/Dockerfile.*
cp target/binaries/markdeck.x86_64-unknown-linux-musl ./
docker compose build \
--no-rm --progress plain \
--build-arg MERMAID_VERSION=$(MERMAID_VERSION) \
--build-arg PANDOC_VERSION=$(PANDOC_VERSION) \
--build-arg JQUERY_VERSION=$(JQUERY_VERSION) \
--build-arg REVEALJS_VERSION=$(REVEALJS_VERSION) \
--build-arg IMPRESSJS_VERSION=$(IMPRESSJS_VERSION) \
--build-arg ASCIINEMAPLAYER_VERSION=$(ASCIINEMAPLAYER_VERSION) \
--build-arg SVGBOB_VERSION=$(SVGBOB_VERSION)
touch images.built
src/docroot/main/assets/3rdparty/jspdf/jspdf.umd.min.js:
mkdir -p $(shell dirname $@)
curl -Lo $@ https://unpkg.com/[email protected]/dist/jspdf.umd.min.js
src/docroot/main/toplevel/admin.html: src/docroot/main/admin.template target/versions
export $(shell cat target/versions | xargs)
envsubst < $< > $@
docroot: src/docroot/main/toplevel/admin.html src/docroot/main/assets/3rdparty/jspdf/jspdf.umd.min.js
docker build -t arne/markdeck-docroot:latest -f docker/Dockerfile.docroot \
--build-arg MERMAID_VERSION=$(MERMAID_VERSION) \
--build-arg PANDOC_VERSION=$(PANDOC_VERSION) \
--build-arg JQUERY_VERSION=$(JQUERY_VERSION) \
--build-arg REVEALJS_VERSION=$(REVEALJS_VERSION) \
--build-arg IMPRESSJS_VERSION=$(IMPRESSJS_VERSION) \
--build-arg ASCIINEMAPLAYER_VERSION=$(ASCIINEMAPLAYER_VERSION) \
--build-arg SVGBOB_VERSION=$(SVGBOB_VERSION) \
--target build-docroot \
.
# docker scan arne/markdeck-docroot:latest
rm -rf docroot/main
mkdir -p src/docroot/main
docker rm -f docroot-main
docker create --name=docroot-main arne/markdeck-docroot:latest foo
docker export docroot-main | tar -C src/docroot/main --strip-components 1 -x markdeck/
docker rm docroot-main
# docker build -t arne/markdown-friends-docroot:latest \
# -f ../markdown-friends/Dockerfile \
# --target build-docroot \
# ../markdown-friends
# # docker scan arne/markdown-friends-docroot:latest
# rm -rf docroot/live_server/helper
# mkdir -p src/docroot/live_server/helper
# docker rm -f docroot-helper
# docker create --name=docroot-helper arne/markdown-friends-docroot:latest foo
# docker export docroot-helper | tar -C src/docroot/live_server/helper --strip-components 1 -x docroot/
tag:
@echo $(VERSION)
git tag -a v$(VERSION) -m v$(VERSION)
git push --tags
check-versions:
@echo "PANDOC_VERSION"
@echo "$(PANDOC_VERSION)"
@curl -s https://github.com/jgm/pandoc/releases/latest | sed 's_.*/releases/tag/__;s/">.*//'
@echo
@echo "REVEALJS_VERSION"
@echo "$(REVEALJS_VERSION)"
@curl -s https://github.com/hakimel/reveal.js/releases/latest | sed 's_.*/releases/tag/__;s/">.*//'
@echo
@echo "ASCIINEMAPLAYER_VERSION"
@echo "$(ASCIINEMAPLAYER_VERSION)"
@curl -s https://github.com/asciinema/asciinema-player/releases/latest | sed 's_.*/releases/tag/__;s/">.*//'
@echo
@echo "JQUERY_VERSION"
@echo "$(JQUERY_VERSION)"
@echo ?
@echo
@echo "IMPRESSJS_VERSION"
@echo "$(IMPRESSJS_VERSION)"
@curl -s https://github.com/impress/impress.js/releases/latest | sed 's_.*/releases/tag/__;s/">.*//'
@echo
@echo "MERMAID_VERSION"
@echo "$(MERMAID_VERSION)"
@curl -s https://github.com/mermaid-js/mermaid/releases/latest | sed 's_.*/releases/tag/__;s/">.*//'
@echo
@echo "SVGBOB_VERSION"
@echo "$(SVGBOB_VERSION)"
@echo ?
@echo
target/versions: Makefile
rm -f $@
mkdir -p $(shell dirname $@)
echo "MARKDECK_VERSION=$(VERSION)" >> $@
echo "PANDOC_VERSION=$(PANDOC_VERSION)" >> $@
echo "REVEALJS_VERSION=$(REVEALJS_VERSION)" >> $@
echo "ASCIINEMAPLAYER_VERSION=$(ASCIINEMAPLAYER_VERSION)" >> $@
echo "JQUERY_VERSION=$(JQUERY_VERSION)" >> $@
echo "IMPRESSJS_VERSION=$(IMPRESSJS_VERSION)" >> $@
echo "MERMAID_VERSION=$(MERMAID_VERSION)" >> $@
echo "SVGBOB_VERSION=$(SVGBOB_VERSION)" >> $@
update-rust:
rustup self update
rustup update
cargo clean
cargo update
# brew tap SergioBenitez/osxct # no update since 4 years?!
# from https://github.com/messense/homebrew-macos-cross-toolchains
brew tap messense/macos-cross-toolchains
brew upgrade x86_64-unknown-linux-gnu || brew install x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-gnu
brew upgrade x86_64-unknown-linux-musl || brew install x86_64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl
brew upgrade mingw-w64 || brew install mingw-w64
rustup target add x86_64-pc-windows-gnu
clean:
rm -f downloaded/bin/*
rm -rf markdeck/assets/3rdparty markdeck/assets/framework
git clean -fx
tabularasa:
docker images "arne/markdeck*"
docker images -q "arne/markdeck*" | xargs docker rmi -f
docker system prune -f
docker images "arne/markdeck*"