Repository navigation
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
389 lines (331 loc) · 11.9 KB
/
Copy pathTaskfile.yaml
File metadata and controls
389 lines (331 loc) · 11.9 KB
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# https://taskfile.dev
#Called by the vnbuild system to produce builds for my website
#https://www.vaughnnugent.com/resources/software
#This taskfile performs the build operations for a module, it handles
#git code updates, msbuild on solutions, and sleet NuGet feed pushes.
#this file must be in the same directory as the solution file
#NOTES: Since CI project is pulled from the module root, MODULE_DIR is used instead of PROJECT_DIR
version: '3.45'
vars:
BINARY_DIR: '{{ .BINARY_DIR | default "bin" }}'
TEST_EXE_NAME: 'nctest'
#cmake defaults
CMAKE_BUILD_DIR: 'build/{{ OS }}'
CMAKE_BUILD_VERSION: '{{ .ASSEMBLY_SEMVER | default "0.0.0.0" }}'
CMAKE_BUILD_CONFIG: '{{ .CMAKE_BUILD_CONFIG | default "Release" }}'
CMAKE_TEST_STATUS: '{{ .CMAKE_TEST_STATUS | default "OFF" }}'
MBEDTLS_SRC_DIR: '{{ .USER_WORKING_DIR }}/vendor/mbedtls'
SECP256_SRC_DIR: '{{ .USER_WORKING_DIR }}/vendor/secp256k1'
OPENSSL_SRC_DIR: '{{ .USER_WORKING_DIR }}/vendor/openssl'
MONOCYPHER_SRC_DIR: '{{ .USER_WORKING_DIR }}/vendor/monocypher'
tasks:
default:
desc: "Build the library for your system"
summary:
Builds Noscrypt for your system using safe defaults. The default configuration is
set to 'Release' and the test executable is not built.
You may specify additional arguments like this 'task -- -DNC_ENABLE_UTILS=ON'
cmds:
- task: cmake-build
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
CMAKE_BUILD_CONFIG: '{{ .CMAKE_BUILD_CONFIG }}'
CMAKE_BUILD_VERSION: '{{ .CMAKE_BUILD_VERSION }}'
CMAKE_TEST_STATUS: '{{ .CMAKE_TEST_STATUS }}'
CMAKE_CONFIG_ARGS: '{{ .CMAKE_CONFIG_ARGS }} {{ .CLI_ARGS }}'
build-mbedtls:
desc: "Build the library linking against mbedtls as a crypto backend"
summary: |
Configures, and compiles mbedtls, then builds noscrypt linking against mbedtls
as a crypto backend.
vars:
MBEDTLS_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/_deps/mbedtls'
cmds:
- task: mbedtls-build
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
MBEDTLS_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}'
- task: default
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
CMAKE_BUILD_CONFIG: '{{ .CMAKE_BUILD_CONFIG }}'
CMAKE_BUILD_VERSION: '{{ .CMAKE_BUILD_VERSION }}'
CMAKE_TEST_STATUS: '{{ .CMAKE_TEST_STATUS }}'
CMAKE_CONFIG_ARGS: '
{{ .CMAKE_CONFIG_ARGS }}
-DCRYPTO_LIB=mbedtls
-DCRYPTO_LIB_DIR={{ .MBEDTLS_BUILD_DIR }}'
build-debug:
desc: "Build libraries and test executable in debug mode"
summary: |
Runs the CMake configure and compile steps to build the library
and test executable in debug mode.
cmds:
- task: default
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
CMAKE_BUILD_CONFIG: 'Debug'
CMAKE_BUILD_VERSION: '{{ .CMAKE_BUILD_VERSION }}'
CMAKE_TEST_STATUS: 'ON'
CMAKE_CONFIG_ARGS: '{{ .CMAKE_CONFIG_ARGS }}'
#available to users and vnbuild runner
test:
desc: "Builds a local copy of the library in a debug configuration, then runs the test executable"
cmds:
- task: build-debug
- task: cmake-test
vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
install:
desc: "Uses cmake to install the library on your system"
cmds:
- cmd: echo "Installing noscrypt globally"
silent: true
- task: cmake-install
#Test executable and library must be built for tests to run
memcheck:
desc: 'Runs Valgrind memcheck in debug mode against the nctest executable (Linux only)'
summary: |
Runs Valgrind memcheck in debug mode against the nctest executable.
This task is only available on Linux platforms with Valgrind and the
Memcheck tool is installed. You must build the test executable in debug
mode before running this task.
platforms:
- linux
preconditions:
- command -v valgrind
cmds:
- cmd: echo "Running valgrind memory check on test executable"
silent: true
- cmd:
valgrind
--tool=memcheck
--leak-check=full
--show-leak-kinds=all
--track-origins=yes
{{ .CMAKE_BUILD_DIR }}/{{ .TEST_EXE_NAME }}
clean:
desc: "Cleans the build and artifact directories"
ignore_error: true
cmds:
- for: [ bin/, build/ ]
cmd: rm -rf "{{ .ITEM }}"
#################################
#
# INTERNAL TASKS
#
#################################
cmake-configure:
internal: true
requires: { CMAKE_BUILD_DIR, CMAKE_BUILD_VERSION, CMAKE_BUILD_CONFIG, CMAKE_TEST_STATUS }
cmds:
- cmd: cmake
-S .
-B{{ .CMAKE_BUILD_DIR }}
-DCMAKE_BUILD_TYPE={{ .CMAKE_BUILD_CONFIG }}
-DCMAKE_PROJECT_VERSION={{ .CMAKE_BUILD_VERSION }}
-DNC_BUILD_TESTS={{ .CMAKE_TEST_STATUS }}
{{ .CMAKE_CONFIG_ARGS }}
#perfoms CMake compile step
cmake-compile:
internal: true
requires: { CMAKE_BUILD_DIR, CMAKE_BUILD_CONFIG }
cmds:
- cmd: cmake
--build {{ .CMAKE_BUILD_DIR }}
--config {{ .CMAKE_BUILD_CONFIG }}
-j {{ numCPU }}
#runs the configure and compile cmake steps
cmake-build:
internal: true
requires: { CMAKE_BUILD_VERSION, CMAKE_BUILD_DIR, CMAKE_BUILD_CONFIG, CMAKE_TEST_STATUS, CMAKE_CONFIG_ARGS }
cmds:
- task: cmake-configure
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
CMAKE_BUILD_CONFIG: '{{ .CMAKE_BUILD_CONFIG }}'
CMAKE_BUILD_VERSION: '{{ .CMAKE_BUILD_VERSION }}'
CMAKE_TEST_STATUS: '{{ .CMAKE_TEST_STATUS }}'
CMAKE_CONFIG_ARGS: '{{ .CMAKE_CONFIG_ARGS }}'
- task: cmake-compile
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
CMAKE_BUILD_CONFIG: '{{ .CMAKE_BUILD_CONFIG }}'
#runs the cmake install step
cmake-install:
internal: true
requires: { CMAKE_BUILD_DIR }
cmds:
- cmd: cmake --install {{ .CMAKE_BUILD_DIR }} {{ .CLI_ARGS }}
cmake-test:
internal: true
requires: { CMAKE_BUILD_DIR }
cmds:
- cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose --output-on-failure
mbedtls-configure:
internal: true
requires: { CMAKE_BUILD_DIR, MBEDTLS_SRC_DIR, MBEDTLS_BUILD_DIR }
vars:
MBEDTLS_CONFIG_FILE: '{{ .USER_WORKING_DIR }}/vendor/mbedtls/mbedtls_noscrypt_config.h'
cmds:
#clear build dir before re-configuring
- cmd: rm -rf "{{ .MBEDTLS_BUILD_DIR }}"
ignore_error: true
- cmd: cmake
-S '{{ .MBEDTLS_SRC_DIR }}'
-B '{{ .MBEDTLS_BUILD_DIR }}'
-DCMAKE_BUILD_TYPE=Release
-DENABLE_PROGRAMS=OFF
-DENABLE_TESTING=OFF
-DBUILD_SHARED_LIBS=OFF
-DUSE_SHARED_MBEDTLS_LIBRARY=OFF
-DUSE_STATIC_MBEDTLS_LIBRARY=ON
-DDISABLE_PACKAGE_CONFIG_AND_INSTALL=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DMBEDTLS_CONFIG_FILE='{{ .MBEDTLS_CONFIG_FILE }}'
mbedtls-compile:
internal: true
requires: { CMAKE_BUILD_DIR, MBEDTLS_BUILD_DIR }
cmds:
- cmd: cmake --build '{{ .MBEDTLS_BUILD_DIR }}' --config Release
mbedtls-build:
internal: true
desc: "Configures, and compiles mbedtls locally"
requires: { CMAKE_BUILD_DIR, MBEDTLS_BUILD_DIR }
cmds:
- task: mbedtls-configure
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
MBEDTLS_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}'
- task: mbedtls-compile
vars:
CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
MBEDTLS_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}'
#################################
#
# CI TASKS
#
#################################
# called by Module.taskfile to run tests
ci-test:
vars:
MBEDTLS_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/test/mbedtls'
DEFAULT_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/test/default'
BUILD_ARGS: '-DNC_ENABLE_UTILS=ON'
deps:
- task: build-debug
vars:
CMAKE_BUILD_DIR: '{{ .DEFAULT_BUILD_DIR }}'
CMAKE_CONFIG_ARGS: '{{ .BUILD_ARGS }}'
- task: build-mbedtls
vars:
CMAKE_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}'
CMAKE_BUILD_CONFIG: 'Debug'
CMAKE_TEST_STATUS: 'ON'
CMAKE_CONFIG_ARGS: '{{ .BUILD_ARGS }}'
cmds:
#cleanup build directories after testing
- defer: rm -rf "{{ .CMAKE_BUILD_DIR }}/test"
#run tests and memcheck against default build
- task: cmake-test
vars: { CMAKE_BUILD_DIR: '{{ .DEFAULT_BUILD_DIR }}' }
- task: memcheck
vars: { CMAKE_BUILD_DIR: '{{ .DEFAULT_BUILD_DIR }}' }
#run tests and memcheck against mbedtls build
- task: cmake-test
vars: { CMAKE_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}' }
- task: memcheck
vars: { CMAKE_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}' }
ci-pack-source:
internal: true
desc: "Packs up the project source code and creates a tarball in the builds binary directory"
vars:
TARGET_SOURCE: '{{ .PROJECT_DIR }}/{{ .BINARY_DIR }}/{{ .PROJECT_NAME }}-src.tgz'
SOURCE_FILES:
CMakeLists.txt
Taskfile.yaml
src
include
license
tests
vendor
readme.md
CMakePresets.json
cmds:
#tar up the source
- cmd: tar{{ if eq OS "windows" }}.exe{{ end }} -czf "{{ .TARGET_SOURCE }}" {{ .SOURCE_FILES | join " " }}
ci-build-win_x64:
internal: true
requires: { CMAKE_BUILD_DIR, BINARY_DIR, PROJECT_DIR, CMAKE_BUILD_CONFIG, PROJECT_NAME }
platforms: [ windows ]
vars:
TARGET: '{{ .PROJECT_DIR }}/{{ .BINARY_DIR }}/msvc-x64-{{ lower .CMAKE_BUILD_CONFIG }}-{{ .PROJECT_NAME }}.tgz'
BUILD_DIR: 'build/win-x64'
TAR_FILES: "
{{ .PROJECT_NAME }}.dll
{{ .PROJECT_NAME }}.lib
{{ .PROJECT_NAME }}_static.lib
license.txt"
cmds:
# run configure and compile commands
# when running in CI the assembly version is set to the build number
# because it's all numbers and does not contain metadata
- task: default
vars:
CMAKE_BUILD_DIR: '{{ .BUILD_DIR }}'
CMAKE_BUILD_VERSION: '{{ .ASSEMBLY_SEMVER }}'
CMAKE_TEST_STATUS: 'OFF'
CMAKE_CONFIG_ARGS: '-G "Visual Studio 17 2022" -A x64 -DNC_ENABLE_UTILS=ON'
#copy license to build dir
- cmd: cp license '{{ .BUILD_DIR }}/{{ .CMAKE_BUILD_CONFIG }}/license.txt'
#tar up the binaries
- cmd: cd {{ .BUILD_DIR }}/{{ .CMAKE_BUILD_CONFIG }} && tar{{ if eq OS "windows" }}.exe{{ end }} -czf "{{ .TARGET }}" {{ .TAR_FILES }}
#called by build pipeline to build module
build:
cmds:
- cmd: echo "building project {{ .PROJECT_NAME }}"
- cmd: mkdir -p "{{ .BINARY_DIR }}"
#build windows x64
- task: ci-build-win_x64
#pack source
- task: ci-pack-source
postbuild_success:
cmds: []
#################################
#
# DEV TASKS
#
#################################
dev-test:
desc: "Re-runs compilation phase and test executable"
cmds:
- task: cmake-compile
vars: { CMAKE_BUILD_CONFIG: 'Debug' }
- task: cmake-test
vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
- task: memcheck
dev:
desc: "Runs local development tests and watches for changes"
summary: |
Watches for changes to source and config files, recompiles, and runs tests
automatically when changes are detected.
watch: true
sources:
- include/*
- src/*
- src/*/*
- tests/*
- CMakelists.txt
- vendor/*
cmds:
- task: dev-test
dev-gdb-test:
platforms: [ linux ]
desc: "Starts a new gdb session on the test executable"
summary: |
(Linux only) Starts a new gdb session on the test executable.
Use the 'run' command to start the test executable.
interactive: true
cmds:
- task: cmake-compile
vars: { CMAKE_BUILD_CONFIG: 'Debug' }
- cmd: gdb '{{ .CMAKE_BUILD_DIR }}/{{ .TEST_EXE_NAME }}'