-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile.toml
370 lines (325 loc) · 9.43 KB
/
Makefile.toml
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [`cargo-make`] configuration for development workflow.
#
# Top-level targets:
#
# - bench: Runs benchmark with nightly toolchain and updates
# `report/bench_results.txt`.
# - codehealth: Performs linting, format checking and `test`.
# - format: Runs auto-formatter over toml, md, and source codes.
# - integration: Generates integration reports (aka performance comparison
# reports) with stable and nightly toolchains.
# - profile: Runs binary with pprof mode and updates `report/profile.st.pdf`.
# - report: Runs `bench`, `proflie`, and `integration`.
# - test: Runs unittests with stable and nightly toolchains.
[config]
skip_core_tasks = true
[env]
BENCH_FEATURES = "experimental,par,simd-nightly"
BENCH_RESULTS_TEXT = "report/bench_results.txt"
CLIPPY_FEATURES_NIGHTLY = "experimental,par,serde,simd-nightly"
CLIPPY_FEATURES_STABLE = "experimental,par,serde"
CLIPPY_FEATURES_BIN_NIGHTLY = "simd-nightly"
CLIPPY_FEATURES_DECBIN_NIGHTLY = ""
CLIPPY_FEATURES_FUZZ_NIGHTLY = ""
FLAC_VERSION = "1.4.3"
FLAC_RELEASE_DIR = "https://ftp.osuosl.org/pub/xiph/releases/flac"
INTEGRATION_REPORT_NIGHTLY = "report/report.nightly.md"
INTEGRATION_REPORT_STABLE = "report/report.stable.md"
PROFILE_ENCODER_CONFIG = "report/st.config.toml"
PROFILE_ENCODER_FEATURES = "pprof,simd-nightly"
PROFILE_INPUT = "wikimedia.winter_kiss.wav"
PROFILE_PPROF_OUTPUT_PDF = "report/profile.st.pdf"
TEST_FEATURES_NIGHTLY = "decode,experimental,par,simd-nightly"
TEST_FEATURES_STABLE = "decode,experimental,par"
TEST_FEATURES_BIN_NIGHTLY = "simd-nightly"
#
# TOP-LEVEL TARGETS
#
[tasks.bench]
description = "Run benchmark with nightly toolchain and update `report/bench_results.txt`."
script = """
rustup run nightly cargo bench \
--features ${BENCH_FEATURES} -- \
--skip tests:: | tee ${BENCH_RESULTS_TEXT}
"""
[tasks.codehealth]
description = "Performs linting, format checking and `test`."
dependencies = ["fmtcheck", "clippy", "test", "py-codehealth", "toml-lint"]
[tasks.format]
description = "Runs auto-formatter over toml, md, and source codes."
dependencies = ["toml-format", "md-format", "rs-format", "py-format"]
[tasks.integration]
description = "Generates integration reports (aka performance comparison reports) with stableand nightly toolchains."
dependencies = ["integration-stable", "integration-nightly"]
[tasks.profile]
description = "Runs binary with pprof mode and updates `report/profile.st.pdf`."
dependencies = ["testwavs"]
cwd = "flacenc-bin"
script = """
cargo build --release --features ${PROFILE_ENCODER_FEATURES}
./target/release/flacenc \
--output ./tmp.flac --config ../${PROFILE_ENCODER_CONFIG} \
--pprof-output ./profile.pb \
../testwav/${PROFILE_INPUT} && \
pprof -pdf -output ../${PROFILE_PPROF_OUTPUT_PDF} profile.pb
rm ./tmp.flac
"""
[tasks.report]
description = "Runs `bench`, `proflie`, and `integration`."
dependencies = ["bench", "profile", "integration"]
[tasks.test]
description = "Runs unittests with stable and nightly toolchains."
dependencies = [
"test-lib-nightly",
"test-bin-nightly",
"test-lib-stable",
"test-lib-stable-nofeatures",
]
#
# SUB-TARGETS
#
[tasks.clippy]
dependencies = [
"clippy-lib-nightly",
"clippy-bin-nightly",
"clippy-lib-stable",
"clippy-fuzz-nightly",
]
[tasks.clippy-lib-nightly]
command = "cargo"
toolchain = "nightly"
args = [
"clippy",
"--tests",
"--features",
"${CLIPPY_FEATURES_NIGHTLY}",
"--",
"-D",
"warnings",
]
[tasks.clippy-bin-nightly]
cwd = "flacenc-bin"
command = "cargo"
toolchain = "nightly"
args = [
"clippy",
"--tests",
"--features",
"${CLIPPY_FEATURES_BIN_NIGHTLY}",
"--",
"-D",
"warnings",
]
[tasks.clippy-fuzz-nightly]
cwd = "fuzz"
command = "cargo"
toolchain = "nightly"
args = [
"clippy",
"--tests",
"--features",
"${CLIPPY_FEATURES_FUZZ_NIGHTLY}",
"--",
"-D",
"warnings",
]
[tasks.clippy-lib-stable]
command = "cargo"
toolchain = "stable"
args = [
"clippy",
"--tests",
"--features",
"${CLIPPY_FEATURES_STABLE}",
"--",
"-D",
"warnings",
]
[tasks.fmtcheck]
dependencies = ["fmtcheck-lib", "fmtcheck-bin", "fmtcheck-fuzz"]
[tasks.fmtcheck-bin]
cwd = "flacenc-bin"
command = "cargo"
args = ["fmt", "--check", "--all"]
[tasks.fmtcheck-lib]
command = "cargo"
args = ["fmt", "--check", "--all"]
[tasks.fmtcheck-fuzz]
cwd = "fuzz"
command = "cargo"
args = ["fmt", "--check", "--all"]
[tasks.integration-nightly]
dependencies = ["py-venv", "reference-bin", "testwavs"]
script = """
pushd flacenc-bin
rustup run nightly cargo build --release --features ${TEST_FEATURES_BIN_NIGHTLY}
popd
source venv/bin/activate
python ./testtool/reporter.py \
--flacbin flac-${FLAC_VERSION}/src/flac/flac \
--testbin flacenc-bin/target/release/flacenc \
--workdir report/out/nightly \
--output ${INTEGRATION_REPORT_NIGHTLY}
"""
[tasks.integration-stable]
dependencies = ["py-venv", "reference-bin", "testwavs"]
script = """
pushd flacenc-bin
rustup run stable cargo build --release
popd
source venv/bin/activate
python ./testtool/reporter.py \
--flacbin flac-${FLAC_VERSION}/src/flac/flac \
--testbin flacenc-bin/target/release/flacenc \
--workdir report/out/stable \
--output ${INTEGRATION_REPORT_STABLE}
"""
[tasks.md-format]
dependencies = ["py-venv"]
script = """
source venv/bin/activate
venv/bin/mdformat --wrap 80 \
README.md \
CHANGELOG.md \
CONTRIBUTING.md \
flacenc-bin/README.md
"""
[tasks.py-codehealth]
dependencies = ["py-venv"]
script = """
source venv/bin/activate
black --check --line-length=79 --diff testtool
pytype testtool
flake8 testtool
"""
[tasks.py-format]
dependencies = ["py-venv"]
script = """
source venv/bin/activate
black --line-length=79 testtool/reporter.py
"""
[tasks.py-venv]
script = """
python3 -m venv venv
source venv/bin/activate
pip install --quiet --upgrade pip
pip install --quiet --upgrade black flake8
pip install --quiet --upgrade pytype --ignore-requires-python
pip install --quiet --upgrade mdformat
"""
[tasks.reference-bin]
condition = { files_not_exist = ["flac-${FLAC_VERSION}/src/flac/flac"] }
script = """
if ! command -v curl ; then
echo "cURL is not installed, cannot continue downloading testwavs."
exit 1
fi
rm -fr flac-${FLAC_VERSION}
curl "${FLAC_RELEASE_DIR}/flac-${FLAC_VERSION}.tar.xz" | tar -xJ
cd flac-${FLAC_VERSION}
./configure && make
"""
[tasks.rs-format]
dependencies = ["rs-format-bin", "rs-format-lib"]
[tasks.rs-format-bin]
cwd = "flacenc-bin"
command = "cargo"
args = ["fmt"]
[tasks.rs-format-lib]
command = "cargo"
args = ["fmt"]
[tasks.test-bin-nightly]
cwd = "flacenc-bin"
command = "cargo"
toolchain = "nightly"
args = ["test", "--features", "${TEST_FEATURES_BIN_NIGHTLY}"]
env = { "RUSTFLAGS" = "-D warnings" }
[tasks.test-lib-nightly]
command = "cargo"
toolchain = "nightly"
args = ["test", "--features", "${TEST_FEATURES_NIGHTLY}"]
env = { "RUSTFLAGS" = "-D warnings" }
[tasks.test-lib-stable]
command = "cargo"
toolchain = "stable"
args = ["test", "--features", "${TEST_FEATURES_STABLE}"]
env = { "RUSTFLAGS" = "-D warnings" }
[tasks.test-lib-stable-nofeatures]
command = "cargo"
toolchain = "stable"
args = ["test", "--no-default-features"]
env = { "RUSTFLAGS" = "-D warnings" }
[tasks.testwavs]
condition = { files_not_exist = [
"testwav/wikimedia.i_love_you_california.wav",
"testwav/wikimedia.jazz_funk_no1_sax.wav",
"testwav/wikimedia.suite_en_fa_op_33_1.wav",
"testwav/wikimedia.winter_kiss.wav",
] }
script = """
if ! command -v curl ; then
echo "cURL is not installed, cannot continue downloading testwavs."
exit 1
fi
if ! command -v ffmpeg ; then
echo "FFMpeg is not installed, cannot continue downloading testwavs."
exit 1
fi
WIKIMEDIA_ROOT="https://upload.wikimedia.org/wikipedia/commons"
rm -fr testwav; mkdir testwav
curl "${WIKIMEDIA_ROOT}/9/97/%22I_Love_You%2C_California%22%2C_performed_by_the_Prince%27s_Orchestra_in_1914_for_Columbia_Records.oga" \
| ffmpeg -i - testwav/wikimedia.i_love_you_california.wav
curl "${WIKIMEDIA_ROOT}/b/bd/Drozerix_-_A_Winter_Kiss.wav" \
> testwav/wikimedia.winter_kiss.wav
curl "${WIKIMEDIA_ROOT}/7/7f/Jazz_Funk_no1_%28saxophone%29.flac" \
| ffmpeg -i - testwav/wikimedia.jazz_funk_no1_sax.wav
curl "${WIKIMEDIA_ROOT}/5/5e/Albert_Roussel_-_Suite_en_Fa%2C_op.33_-_I._Pr%C3%A9lude.flac" \
| ffmpeg -i - testwav/wikimedia.suite_en_fa_op_33_1.wav
"""
[tasks.toml-format]
install_crate = { crate_name = "taplo-cli", binary = "taplo", test_arg = [
"--help",
] }
command = "taplo"
args = [
"format",
"Cargo.toml",
"Makefile.toml",
"flacenc-bin/Cargo.toml",
"report/experimental.config.toml",
"report/mt1.config.toml",
"report/st.config.toml",
]
[tasks.toml-lint]
install_crate = { crate_name = "taplo-cli", binary = "taplo", test_arg = [
"--help",
] }
command = "taplo"
args = [
"check",
"Cargo.toml",
"Makefile.toml",
"flacenc-bin/Cargo.toml",
"report/experimental.config.toml",
"report/mt1.config.toml",
"report/st.config.toml",
]
[tasks.refresh-lock]
script = """
rm -f flacenc-bin/Cargo.lock
cd ../flacenc-bin
cargo build --all-features
"""