forked from chainguard-dev/melange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.yaml
67 lines (56 loc) · 1.94 KB
/
build.yaml
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
name: Compile an auditable rust binary with Cargo
needs:
packages:
- build-base
- busybox
- cargo-auditable
- rust
inputs:
output:
description: |
Filename to use when writing the binary. The final install location inside
the apk will be in prefix / install-dir / output
opts:
default: --release
description: |
Options to pass to cargo build. Defaults to release
modroot:
default: "."
required: false
description: |
Top directory of the rust package, this is where the target package lives.
Before building, the cargo pipeline wil cd into this directory. Defaults
to current working directory
rustflags:
default: ""
required: false
description: |
Rustc flags to be passed to pass to all compiler invocations that Cargo performs.
In contrast with cargo rustc, this is useful for passing a flag to all compiler instances.
This string is split by whitespace.
prefix:
default: usr
description: |
Installation prefix. Defaults to usr
install-dir:
description: |
Directory where binaries will be installed
default: bin
output-dir:
description: |
Directory where the binaris will be placed after building. Defaults to target/release
default: target/release
pipeline:
- runs: |
# Installation directory should always be bin as we are producing a binary
INSTALL_PATH="${{targets.contextdir}}/${{inputs.prefix}}/${{inputs.install-dir}}"
OUTPUT_PATH="${{inputs.output-dir}}"
# Enter target package directory
cd "${{inputs.modroot}}"
# Build and install package(s)
RUSTFLAGS="${{inputs.rustflags}}" cargo auditable build --target-dir target ${{inputs.opts}}
if [[ ! -z "${{inputs.output}}" ]]; then
install -Dm755 "${OUTPUT_PATH}/${{inputs.output}}" "${INSTALL_PATH}/${{inputs.output}}"
else
install -Dm755 "${OUTPUT_PATH}"/* -t "${INSTALL_PATH}"
fi