返回 CodeWhale
dev-cargo.sh
根目录 / scripts / dev-cargo.sh
1 #!/bin/sh
2 # Run cargo with the portable Codewhale cache topology applied.
3 #
4 # scripts/dev-cargo.sh check -p codewhale-config --lib --locked
5 # scripts/dev-cargo.sh --status
6 # scripts/dev-cargo.sh --self-check
7 #
8 # This is the everyday compile entry point. Check, test, and debug builds do not
9 # change product behavior; clean release and install builds stamp
10 # CODEWHALE_LOCAL_BUILD_SHA for --version and receipts without setting
11 # telemetry provenance. Use scripts/dev-test.sh <area> for tests under the shared temporary
12 # HOME boundary. Arbitrary Cargo commands here do not isolate product config.
13 # See scripts/dev-cache.sh and docs/BUILD_PERFORMANCE.md.
14 set -eu
15
16 repo_root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
17 cd "$repo_root"
18
19 # shellcheck source=scripts/dev-cache.sh
20 . "$repo_root/scripts/dev-cache.sh"
21
22 case ${1:-} in
23 --status|--self-check|--print-exports|--help|-h)
24 exec "$repo_root/scripts/dev-cache.sh" "$1"
25 ;;
26 esac
27
28 codewhale_dev_cache_apply
29 # Match CI / the product's 16 MiB owner-thread stack so local cargo test
30 # and nextest do not abort on the default ~2 MiB (Windows ~1 MiB) stack.
31 if [ -z "${RUST_MIN_STACK:-}" ]; then
32 RUST_MIN_STACK=16777216
33 export RUST_MIN_STACK
34 fi
35 codewhale_dev_stamp_release_build() {
36 [ -z "${CODEWHALE_BUILD_SHA:-}" ] || return 0
37 [ -z "${DEEPSEEK_BUILD_SHA:-}" ] || return 0
38 [ -z "${CODEWHALE_LOCAL_BUILD_SHA:-}" ] || return 0
39 case ${1:-} in
40 +*) shift ;;
41 esac
42 _cw_cmd=${1:-}
43 _cw_release=0
44 case $_cw_cmd in
45 install) _cw_release=1 ;;
46 build|b|run|r) ;;
47 *) return 0 ;;
48 esac
49 shift || true
50 _cw_previous=
51 for _cw_arg in "$@"; do
52 case $_cw_arg in
53 --) break ;;
54 --debug)
55 [ "$_cw_cmd" = install ] && _cw_release=0
56 ;;
57 --release|-r|--profile=release|--profile=dist)
58 _cw_release=1
59 ;;
60 --profile=*)
61 [ "$_cw_cmd" = install ] && _cw_release=0
62 ;;
63 release|dist)
64 [ "$_cw_previous" = --profile ] && _cw_release=1
65 ;;
66 *)
67 [ "$_cw_previous" = --profile ] && [ "$_cw_cmd" = install ] && _cw_release=0
68 ;;
69 esac
70 _cw_previous=$_cw_arg
71 done
72 [ "$_cw_release" = 1 ] || return 0
73 _cw_head=$(git -C "$repo_root" rev-parse HEAD 2>/dev/null) || return 0
74 if git -C "$repo_root" diff --quiet HEAD -- 2>/dev/null; then
75 CODEWHALE_LOCAL_BUILD_SHA=$_cw_head
76 export CODEWHALE_LOCAL_BUILD_SHA
77 else
78 echo "dev-cargo: tracked changes present; this release build stays unstamped (dev). Commit first, or set CODEWHALE_BUILD_SHA." >&2
79 fi
80 }
81
82 codewhale_dev_stamp_release_build "$@"
83 codewhale_dev_cache_exec_cargo "$@"
84
84 lines BASH