-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun
More file actions
executable file
·118 lines (107 loc) · 3.65 KB
/
Copy pathrun
File metadata and controls
executable file
·118 lines (107 loc) · 3.65 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
#
# Cross-platform entrypoint for running a local CastCodes build.
#
# On macOS this delegates to `./script/macos/run`, which builds and runs CastCodes
# as a real `.app` bundle (with code signing, plist updates, etc.). On Linux
# and Windows it invokes `cargo run` directly for the appropriate binary.
#
# This script owns all cross-platform setup (running install_channel_config,
# detecting internal vs OSS builds, and mapping legacy `--features` entries
# to environment variables), so platform-specific scripts can assume those
# values are already provided via environment variables.
set -e
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
cd "${REPO_ROOT}"
OS_TYPE="$(uname -s)"
FEATURES="gui"
./script/install_channel_config || echo "Skipping internal channel config installation (no repo access)."
# If warp_channel_config is on PATH, build the Local channel binary; otherwise build the OSS channel.
if command -v warp-channel-config &>/dev/null; then
WARP_BIN_NAME="warp"
WARP_CHANNEL="local"
else
WARP_BIN_NAME="cast-codes"
WARP_CHANNEL="oss"
fi
# Shared argument parsing. macOS-specific flags (--dont-open,
# --open_with_launchd, --generate-schema) are forwarded through MAC_ARGS and
# silently ignored on other platforms.
MAC_ARGS=()
CARGO_PARAMS=()
WARP_ARGS=()
while (( "$#" )); do
case "$1" in
--)
shift
WARP_ARGS=("$@")
break
;;
--features)
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
FEATURES="$FEATURES,$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--release)
CARGO_PARAMS+=("$1")
MAC_ARGS+=("$1")
shift
;;
--profile)
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
CARGO_PARAMS+=("$1" "$2")
MAC_ARGS+=("$1" "$2")
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
*)
# Unknown flags (including macOS-only flags like --dont-open) and any
# positional arguments are forwarded to the platform-specific script.
MAC_ARGS+=("$1")
shift
;;
esac
done
# These cargo features were removed and replaced by environment variables read
# by warp-channel-config. Intercept them here so that existing --features
# invocations keep working.
for mapping in \
"with_local_server:WITH_LOCAL_SERVER" \
"with_local_session_sharing_server:WITH_LOCAL_SESSION_SHARING_SERVER" \
"with_sandbox_telemetry:WITH_SANDBOX_TELEMETRY"; do
feature="${mapping%%:*}"
env_var="${mapping##*:}"
if [[ ",$FEATURES," =~ ,"$feature", ]]; then
export "$env_var"=1
FEATURES="$(echo "$FEATURES" | sed "s/,$feature,/,/; s/^$feature,//; s/,$feature$//; s/^$feature$//")"
FEATURES="$(echo "$FEATURES" | sed 's/,,*/,/g; s/^,//; s/,$//')"
echo "Note: '$feature' is no longer a cargo feature; setting $env_var=1 instead."
fi
done
export FEATURES
export WARP_BIN_NAME
export WARP_CHANNEL
if [[ "$OS_TYPE" = "Darwin" ]]; then
if [[ ${#WARP_ARGS[@]} -gt 0 ]]; then
exec ./script/macos/run "${MAC_ARGS[@]}" -- "${WARP_ARGS[@]}"
else
exec ./script/macos/run "${MAC_ARGS[@]}"
fi
elif [[ "$OS_TYPE" = "Linux" ]] || [[ "$OS_TYPE" =~ ^(MINGW64_NT|MSYS_NT) ]]; then
echo "Running cargo run --bin $WARP_BIN_NAME --features \"$FEATURES\" ${CARGO_PARAMS[*]}"
if [[ ${#WARP_ARGS[@]} -gt 0 ]]; then
cargo run --bin "$WARP_BIN_NAME" --features "$FEATURES" "${CARGO_PARAMS[@]}" -- "${WARP_ARGS[@]}"
else
cargo run --bin "$WARP_BIN_NAME" --features "$FEATURES" "${CARGO_PARAMS[@]}"
fi
else
echo "No run script defined for the current platform ($OS_TYPE)!" >&2
exit 1
fi