forked from linkerd/linkerd2-proxy-init
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile-rust
More file actions
58 lines (47 loc) · 2.39 KB
/
justfile-rust
File metadata and controls
58 lines (47 loc) · 2.39 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
# 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' or 'arm64'.
arch := env_var_or_default("TARGETARCH", "amd64")
# The OS name to use for packages. Either 'linux' or 'windows'.
os := "linux"
# 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 os + '-' + arch == "linux-amd64" {
"x86_64-unknown-linux-musl"
} else if os + '-' + arch == "linux-arm64" {
"aarch64-unknown-linux-musl"
} else if os + '-' + arch == "windows-amd64" {
"x86_64-pc-windows-gnu"
} else {
error("unsupported: os=" + os + " arch=" + arch)
}
_target-dir := "target" / _cargo-target / profile
_target-bin := _target-dir / crate + if os == 'windows' { '.exe' } else { '' }
_package-name := crate + "-" + version + "-" + arch + "-" + os
_package-tgz := "target/package" / _package-name + ".tgz"
_package-dir := "target/package" / _package-name
_package-bin := _package-dir / crate + if os == 'windows' { '.exe' } else { '' }
_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 {{ if crate == "" { "--workspace" } else { "-p " + crate } }} {{ flags }}