-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
106 lines (84 loc) · 3.06 KB
/
Justfile
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
default: build-dev
alias b := build-dev
alias i := install-dev
alias l := lint-dev
export RUST_BACKTRACE := "1"
export RUST_LOG := "debug"
cli := "openproject-cli"
lib := "libOpenProject.so"
target_dev := if os() == "linux" {
"x86_64-unknown-linux-gnu"
} else if os() == "mac" {
"universal2-apple-darwin"
} else {
error("Unsupported OS: {{ os() }}; only supporting {{ supported_os }}")
}
# TODO: replace with command in backticks; figure out why x86_64-unknown-linux-gnu breaks
# https://just.systems/man/en/chapter_33.html#command-evaluation-using-backticks
target_release := """
aarch64-apple-darwin
aarch64-unknown-linux-gnu
universal2-apple-darwin
x86_64-apple-darwin
x86_64-unknown-linux-gnu
"""
set ignore-comments
set shell := ["bash", "-c"]
# build for the local machine
build-dev: install-rustup setup lint-dev
@echo "Compiling development binaries for target: {{ target_dev }}"
cargo build --target {{ target_dev }}
# build for all supported targets in docker
build: setup
@echo "Cross-compiling binaries..."
@for target in $(echo "{{ target_release }}" | sed "s/\n/ /g"); do \
echo "Compiling release binaries for target: ${target}"; \
cargo zigbuild --release --target ${target}; \
done
echo "Compilation completed";
# install the cli and library to the local machine
install-dev: build-dev
# https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#:~:text=3.1.1.%20Shared%20Library%20Names
install -Dm755 target/{{ cli }} /bin/{{ cli }}
install -Dm755 target/{{ lib }} /usr/lib/{{ lib }}
# Install rustup if rustc or cargo are not installed
install-rustup:
@if command -v rustc &> /dev/null || command -v cargo &> /dev/null; then \
echo "Rustc and Cargo are already installed"; \
else \
echo "Installing rustup (rustc & cargo)"; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \
fi
check:
cargo fmt -- --check
lint:
cargo clippy --all-targets --all-features -- -D warnings
# lint with pedantic warnings
lint-dev: check
cargo clippy --all-targets --all-features -- -D warnings -W clippy::pedantic
cargo clippy --fix
publish: test
cargo publish
# build and publish to crates.io
release: build publish
# install rustup, rustc, cargo, and cross-compilation targets
setup:
@echo "Setup"
@for target in $(echo "{{ target_release }}" | sed "s/\n/ /g"); do \
if [[ ${target} =~ "universal" ]]; then \
echo "Skipping toolchain installation for: ${target}"; \
continue; \
fi; \
echo "Adding toolchain and build target: ${target}"; \
rustup toolchain install --force-non-host stable-${target} --component clippy; \
rustup target add --toolchain stable-${target} ${target}; \
echo "Finished ${target}" && echo ""; \
done
test:
cargo test
zigbuild:
echo "Installing cargo-zigbuild"
@if ! command -v "cargo install cargo-zigbuild" &> /dev/null; then \
echo "Installing cargo-zigbuild"; \
cargo install cargo-zigbuild; \
fi