-
Notifications
You must be signed in to change notification settings - Fork 33
/
justfile-rust
55 lines (45 loc) · 2.15 KB
/
justfile-rust
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
# This justfile includes recipes for building and packaging the validator and
# the repair controller crates for release. This file is separated so that we
# can invoke cargo, etc when building defaults. If this logic were in the main
# justfile, then these tools would be invoked (possibly updating Rust, etc),
# for unrelated targets.
#
# Users are expected to interact with this via the main Justfile.
crate := env_var('TARGETCRATE')
# The version name to use for packages.
version := `just-cargo crate-version $TARGETCRATE`
profile := 'debug'
# The architecture name to use for packages. Either 'amd64', 'arm64', or 'arm'.
arch := env_var_or_default("TARGETARCH", "amd64")
# If an `_arch` is specified, then we change the default cargo `--target` to
# support cross-compilation. Otherwise, we use `rustup` to find the default.
_cargo-target := if arch == "amd64" {
"x86_64-unknown-linux-musl"
} else if arch == "arm64" {
"aarch64-unknown-linux-musl"
} else if arch == "arm" {
"armv7-unknown-linux-musleabihf"
} else {
`rustup show | sed -n 's/^Default host: \(.*\)/\1/p'`
}
_target-dir := "target" / _cargo-target / profile
_target-bin := _target-dir / crate
_package-name := crate + "-" + version + "-" + arch
_package-tgz := "target/package" / _package-name + ".tgz"
_package-dir := "target/package" / _package-name
_package-bin := _package-dir / crate
_package-dbg := _package-bin + ".dbg"
_cargo := 'just-cargo profile=' + profile + ' target=' + _cargo-target
_objcopy := 'llvm-objcopy-' + `just-cargo --evaluate _llvm-version`
_shasum := "shasum -a 256"
package: build
@mkdir -p {{ _package-dir }}
{{ _objcopy }} --only-keep-debug {{ _target-bin }} {{ _package-bin }}.dbg
{{ _objcopy }} --strip-unneeded {{ _target-bin }} {{ _package-bin }}
{{ _objcopy }} --add-gnu-debuglink={{ _package-dbg }} {{ _package-bin }}
tar -C target/package -czf {{ _package-tgz }} {{ _package-name }}
(cd target/package && {{ _shasum }} {{ _package-name }}.tgz > {{ _package-name }}.txt)
@rm -rf {{ _package-dir }}
build *flags:
{{ _cargo }} fetch --locked
{{ _cargo }} build --workspace -p {{ crate }} {{ flags }}