-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake.vsh
More file actions
executable file
·67 lines (56 loc) · 1.66 KB
/
Copy pathmake.vsh
File metadata and controls
executable file
·67 lines (56 loc) · 1.66 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
#!/usr/bin/env -S v run
import build
import crypto.sha256
import os
import term
const output_dir = './release'
const docker_command = 'docker'
const docker_image = 'vlang-cross:latest-trixie'
const compile_command = 'env VFLAGS="-cflags -s" DEBUG=1 ./crosscompile.vsh -release'
const help_text = '
Options:
-tasks List available tasks.
-help Print this help message and exit. Aliases: help, --help.
'.trim_indent()
if 'help' in os.args || '-help' in os.args || '--help' in os.args {
println(help_text)
exit(0)
}
mut context := build.context(default: 'release')
context.task(
name: docker_image
help: 'Build Docker image for cross-compilation'
run: |self| os.system('${docker_command} build -t ${docker_image} .')
)
context.task(
name: 'build'
help: 'Build binaries'
run: |self| os.system('${docker_command} run --rm -v .:/app ${docker_image} ${compile_command}')
should_run: |self| os.is_dir_empty(output_dir)
depends: [docker_image]
)
context.task(
name: 'sha256sums'
help: 'Calculate SHA256 sums for built binaries'
run: |self| os.walk(output_dir, fn (file string) {
out_file := os.abs_path(file + '.sha256')
eprintln(term.bold('Generating: ${out_file}'))
data := os.read_bytes(file) or { return }
sum := sha256.sum(data)
result := '${sum.hex()} ${os.file_name(file)}\n'
os.write_file(out_file, result) or { return }
})
depends: ['build']
)
context.task(
name: 'release'
help: 'Make release'
run: |self| true
depends: ['sha256sums']
)
context.task(
name: 'clean'
help: 'Cleanup build directory (delete all build artifacts)'
run: |self| os.rmdir_all(output_dir) or {}
)
context.run()