-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
186 lines (151 loc) · 4.88 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
# These are valid.
YAML_SAFE_OBJECTS = \
$(wildcard data/relation-*.yaml) \
data/relations.yaml \
# These are well-formed.
YAML_OBJECTS = \
$(YAML_SAFE_OBJECTS) \
.github/workflows/tests.yml \
data/refcounty-names.yaml \
data/refsettlement-names.yaml \
YAML_TEST_OBJECTS = \
$(wildcard tests/data/relation-*.yaml) \
tests/data/relations.yaml \
tests/data/refcounty-names.yaml \
tests/data/refsettlement-names.yaml \
TS_OBJECTS = \
src/browser/config.ts \
src/browser/main.ts \
src/browser/stats.ts \
src/browser/types.d.ts \
RS_OBJECTS = \
src/area_files.rs \
src/areas.rs \
src/areas/tests.rs \
src/cache.rs \
src/cache/tests.rs \
src/cache_yamls.rs \
src/cache_yamls/tests.rs \
src/context.rs \
src/context/system.rs \
src/context/tests.rs \
src/cron.rs \
src/cron/tests.rs \
src/i18n.rs \
src/i18n/tests.rs \
src/lib.rs \
src/main.rs \
src/missing_housenumbers.rs \
src/missing_housenumbers/tests.rs \
src/overpass_query.rs \
src/overpass_query/tests.rs \
src/parse_access_log.rs \
src/parse_access_log/tests.rs \
src/ranges.rs \
src/ranges/tests.rs \
src/serde.rs \
src/sql.rs \
src/stats.rs \
src/stats/tests.rs \
src/sync_ref.rs \
src/sync_ref/tests.rs \
src/util.rs \
src/util/tests.rs \
src/validator.rs \
src/validator/tests.rs \
src/webframe.rs \
src/webframe/tests.rs \
src/wsgi.rs \
src/wsgi/tests.rs \
src/wsgi_additional.rs \
src/wsgi_additional/tests.rs \
src/wsgi_json.rs \
src/wsgi_json/tests.rs \
src/yattag.rs \
src/yattag/tests.rs \
# Source local config if it's there.
-include config.mak
ifdef RSDEBUG
CARGO_OPTIONS =
TARGET_PATH = debug
else
CARGO_OPTIONS = --release
TARGET_PATH = release
endif
CARGO_OPTIONS += --color always
ifndef V
QUIET_MSGFMT = @echo ' ' MSGMFT $@;
QUIET_ESLINT = @echo ' ' ESLINT $@;
QUIET_WEBPACK = @echo ' ' WEBPACK $@;
QUIET_VALIDATOR = @echo ' ' VALIDATOR $@;
endif
all: target/browser/bundle.js css workdir/wsgi.ini data/yamls.cache locale/hu/LC_MESSAGES/osm-gimmisn.mo target/${TARGET_PATH}/osm-gimmisn
clean:
rm -rf target
rm -f $(patsubst %.yaml,%.validyaml,$(YAML_SAFE_OBJECTS))
rm -f config.ts $(patsubst %.ts,%.eslint,$(TS_OBJECTS))
check: all check-filters check-unit check-eslint check-rustfmt check-clippy
@echo "make check: ok"
check-rustfmt: Cargo.toml $(RS_OBJECTS)
cargo fmt -- --check && touch $@
check-clippy: Cargo.toml .github/workflows/tests.yml $(RS_OBJECTS)
cargo clippy ${CARGO_OPTIONS} && touch $@
target/${TARGET_PATH}/osm-gimmisn: $(RS_OBJECTS) Cargo.toml Makefile
cargo build ${CARGO_OPTIONS}
# Without coverage: cargo test --lib
check-unit: Cargo.toml $(RS_OBJECTS) locale/hu/LC_MESSAGES/osm-gimmisn.mo data/yamls.cache
cargo llvm-cov --lib -q --ignore-filename-regex '(serde|system).rs' --show-missing-lines --fail-under-lines 100 ${CARGO_OPTIONS} -- --test-threads=1
src/browser/config.ts: workdir/wsgi.ini Makefile
printf 'const uriPrefix = "%s";\nexport { uriPrefix };\n' $(shell (grep uri_prefix workdir/wsgi.ini || echo "/osm") |sed 's/uri_prefix = //') > $@
ifdef TSDEBUG
WEBPACK_OPTIONS = --mode=development --devtool inline-source-map
else
WEBPACK_OPTIONS = --mode=production
endif
target/browser/bundle.js: $(TS_OBJECTS) package-lock.json Makefile
mkdir -p target/browser
$(QUIET_WEBPACK)npx webpack ${WEBPACK_OPTIONS} --config webpack.config.js
touch $@
package-lock.json: package.json
npm install
touch $@
css: target/browser/osm.min.css
target/browser/osm.min.css: static/osm.css package-lock.json
mkdir -p workdir
[ -x "./node_modules/.bin/cleancss" ] && npx cleancss -o $@ $< || cp -a $< $@
# Intentionally don't update this when the source changes.
workdir/wsgi.ini:
mkdir -p workdir
cp data/wsgi.ini.template workdir/wsgi.ini
data/yamls.cache: target/${TARGET_PATH}/osm-gimmisn $(YAML_OBJECTS)
target/${TARGET_PATH}/osm-gimmisn cache-yamls data workdir
check-eslint: $(patsubst %.ts,%.eslint,$(TS_OBJECTS))
%.eslint : %.ts Makefile eslint.config.mjs package-lock.json
$(QUIET_ESLINT)npx eslint $< && touch $@
check-filters: $(patsubst %.yaml,%.validyaml,$(YAML_SAFE_OBJECTS))
%.validyaml : %.yaml target/${TARGET_PATH}/osm-gimmisn
$(QUIET_VALIDATOR)target/${TARGET_PATH}/osm-gimmisn validator $< && touch $@
run: all
target/${TARGET_PATH}/osm-gimmisn rouille
deploy:
ifeq (,$(wildcard ./deploy.sh))
git pull -r
make
else
./deploy.sh
endif
update-pot: src/areas.rs src/cache.rs src/util.rs src/webframe.rs src/wsgi.rs src/wsgi_additional.rs Makefile
xtr --keyword=tr --charset UTF-8 -o po/osm-gimmisn.pot $(filter %.rs,$^)
update-po: po/osm-gimmisn.pot Makefile
msgmerge --update po/hu/osm-gimmisn.po po/osm-gimmisn.pot
locale/hu/LC_MESSAGES/osm-gimmisn.mo: po/hu/osm-gimmisn.po Makefile
$(QUIET_MSGFMT)msgfmt --check --statistics --output-file=$@ $<
tags:
rusty-tags vi
ln -sf rusty-tags.vi tags
guide:
cd guide && mdbook build
cargo about generate about.hbs > guide/book/license.html
run-guide:
cd guide && mdbook serve --hostname 127.0.0.1
.PHONY: tags guide