-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·85 lines (71 loc) · 2.43 KB
/
build.sh
File metadata and controls
executable file
·85 lines (71 loc) · 2.43 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
set -e
run_cargo_stable() {
if command -v rustup >/dev/null 2>&1; then
RUSTC_BIN=$(rustup which --toolchain stable rustc 2>/dev/null || true)
CARGO_BIN=$(rustup which --toolchain stable cargo 2>/dev/null || true)
if [ -n "$RUSTC_BIN" ] && [ -n "$CARGO_BIN" ]; then
TOOLCHAIN_BIN=$(dirname "$RUSTC_BIN")
PATH="$TOOLCHAIN_BIN:$PATH" RUSTC="$RUSTC_BIN" "$CARGO_BIN" "$@"
return
fi
fi
cargo "$@"
}
run_with_stable_rustc() {
if command -v rustup >/dev/null 2>&1; then
RUSTC_BIN=$(rustup which --toolchain stable rustc 2>/dev/null || true)
if [ -n "$RUSTC_BIN" ]; then
TOOLCHAIN_BIN=$(dirname "$RUSTC_BIN")
PATH="$TOOLCHAIN_BIN:$PATH" RUSTC="$RUSTC_BIN" "$@"
return
fi
fi
"$@"
}
stable_target_dir_name() {
if command -v rustup >/dev/null 2>&1; then
RUSTC_BIN=$(rustup which --toolchain stable rustc 2>/dev/null || true)
if [ -n "$RUSTC_BIN" ]; then
RELEASE=$("$RUSTC_BIN" -Vv 2>/dev/null | awk '/^release:/ { print $2; exit }')
if [ -n "$RELEASE" ]; then
printf 'target-rustup-%s\n' "$(printf '%s' "$RELEASE" | tr '.' '_')"
return
fi
fi
fi
}
prune_rust_build_artifacts() {
rm -rf target/debug/incremental
for path in target-rustup-*/debug/incremental; do
[ -d "$path" ] || continue
rm -rf "$path"
done
current_target_dir=$(stable_target_dir_name)
for path in target-rustup-*; do
[ -d "$path" ] || continue
if [ -n "$current_target_dir" ] && [ "$(basename "$path")" = "$current_target_dir" ]; then
continue
fi
rm -rf "$path"
done
}
prune_rust_build_artifacts
# Frontend
cd packages/ui && npm install && cd ../..
cd web && npm install && npm run build && cd ..
# Worker (skip in CI where it's built separately with cache)
if [ -z "$SKIP_WORKER_BUILD" ]; then
if command -v rustup >/dev/null 2>&1; then
rustup target add wasm32-unknown-unknown --toolchain stable >/dev/null
fi
if ! command -v worker-build >/dev/null 2>&1; then
run_cargo_stable install -q worker-build --locked
fi
cd crates/worker
run_with_stable_rustc worker-build --release
cd ../..
# worker-build outputs to crates/worker/build; wrangler expects build/ at root
rm -rf build
cp -R crates/worker/build ./build
fi