first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+24 -5
View File
@@ -5,12 +5,31 @@
set -e
if ! [ -d "/Applications/Xcode.app" ]; then
echo "Please install Xcode from the App Store before continuing."
exit 1
fi
. "$PWD/script/warp_sudo"
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
DEVELOPER_DIR="$(xcode-select -p 2>/dev/null || true)"
if [ -z "$DEVELOPER_DIR" ] || [ ! -x "$DEVELOPER_DIR/usr/bin/xcodebuild" ] || [ "$DEVELOPER_DIR" = "/Library/Developer/CommandLineTools" ]; then
XCODE_APP=""
# Prefer the stable /Applications/Xcode.app when present so users with
# both stable and beta/versioned installs aren't switched away from it.
if [ -x "/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" ]; then
XCODE_APP="/Applications/Xcode.app"
else
for candidate in /Applications/Xcode*.app; do
if [ -x "$candidate/Contents/Developer/usr/bin/xcodebuild" ]; then
XCODE_APP="$candidate"
break
fi
done
fi
if [ -z "$XCODE_APP" ]; then
echo "Please install Xcode before continuing."
exit 1
fi
echo "Selected Xcode at $XCODE_APP"
echo "You may be prompted for your password so bootstrap can set Xcode as the active developer directory."
warp_sudo xcode-select --switch "$XCODE_APP/Contents/Developer"
fi
# Mimic actually launching XCode, which performs some necessary set-up of the
# development environment.
xcodebuild -runFirstLaunch
+49 -12
View File
@@ -223,8 +223,8 @@ while (( "$#" )); do
;;
--artifact)
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
if [[ "$2" != "app" && "$2" != "cli" ]]; then
echo "Error: --artifact must be either 'app' or 'cli', got '$2'" >&2
if [[ "$2" != "app" && "$2" != "cli" && "$2" != "warpctrl" ]]; then
echo "Error: --artifact must be 'app', 'cli', or 'warpctrl', got '$2'" >&2
exit 1
fi
ARTIFACT="$2"
@@ -250,13 +250,13 @@ elif [[ $RELEASE_CHANNEL = "local" || $RELEASE_CHANNEL = "dev" ]]; then
# For dev bundles, we want to enable debug assertions to
# catch violations that would otherwise silently pass in
# a normal release build (e.g. in stable).
if [[ "$ARTIFACT" == "cli" ]]; then
if [[ "$ARTIFACT" == "cli" || "$ARTIFACT" == "warpctrl" ]]; then
CARGO_PROFILE="release-cli-debug_assertions"
else
CARGO_PROFILE="release-lto-debug_assertions"
fi
else
if [[ "$ARTIFACT" == "cli" ]]; then
if [[ "$ARTIFACT" == "cli" || "$ARTIFACT" == "warpctrl" ]]; then
CARGO_PROFILE="release-cli"
else
CARGO_PROFILE="release-lto"
@@ -286,6 +286,8 @@ elif [[ $RELEASE_CHANNEL = "dev" ]]; then
FEATURES="$FEATURES,agent_mode_debug"
# Enable heap usage tracking & profiling using jemalloc through pprof.
FEATURES="$FEATURES,jemalloc_pprof,heap_usage_tracking"
# Enable the Warp Control CLI wrapper for local scripting/automation.
FEATURES="$FEATURES,warp_control_cli"
# For dev builds, use different versions of our bundled frameworks (e.g.:
# Sentry). This needs to be exported so it can be referenced by
# app/build.rs later, while running `cargo bundle`.
@@ -304,6 +306,8 @@ elif [[ $RELEASE_CHANNEL = "stable" ]]; then
BUNDLE_ID="com.samsung.Galaxy"
WARP_APP_NAME="Galaxy"
WARP_SCHEME_NAME="galaxy"
# Enable heap usage tracking & profiling using jemalloc through pprof.
FEATURES="$FEATURES,jemalloc_pprof,heap_usage_tracking"
elif [[ $RELEASE_CHANNEL = "oss" ]]; then
WARP_BIN="galaxy-ai-oss"
BUNDLE_ID="com.samsung.Galaxy"
@@ -345,12 +349,13 @@ else
fi
# Set artifact-specific configuration.
if [[ "$ARTIFACT" == cli ]]; then
if [[ "$ARTIFACT" == cli || "$ARTIFACT" == warpctrl ]]; then
UNIVERSAL_BINARY=false
OPEN_AFTER_BUNDLE=false
FEATURES="$FEATURES,standalone"
elif [[ "$ARTIFACT" == app ]]; then
FEATURES="$FEATURES,gui,nld_improvements"
# All channels ship the v3 classifier and v2 heuristic.
FEATURES="$FEATURES,gui,nld_classifier_v3,nld_heuristic_v2"
fi
# If we're building a universal bundle for the app artifact, make sure the additional target is available.
@@ -363,7 +368,7 @@ fi
# using the same feature flags and profile that we would be using in production.
if [[ "$CHECK_ONLY" == "true" ]]; then
cargo check --profile "$CARGO_PROFILE" --bin "$WARP_BIN" --target "$DEFAULT_TARGET" --features "$FEATURES"
if [[ $UNIVERSAL_BINARY = true && "$ARTIFACT" != "cli" ]]; then
if [[ $UNIVERSAL_BINARY = true && "$ARTIFACT" != "cli" && "$ARTIFACT" != "warpctrl" ]]; then
cargo check --profile "$CARGO_PROFILE" --bin "$WARP_BIN" --target "$ADDITIONAL_TARGET" --features "$FEATURES"
fi
exit 0
@@ -551,10 +556,26 @@ EOF
# Make the script executable
chmod +x "$CLI_SCRIPT_PATH"
if [[ ",$FEATURES," =~ ",warp_control_cli," ]]; then
# Each value must match `Channel::warpctrl_command_name` in the Rust source.
if [[ $RELEASE_CHANNEL = "stable" ]]; then
WARPCTRL_COMMAND_NAME="warpctrl"
elif [[ $RELEASE_CHANNEL = "oss" ]]; then
WARPCTRL_COMMAND_NAME="warpctrl-oss"
else
WARPCTRL_COMMAND_NAME="warpctrl-$RELEASE_CHANNEL"
fi
WARPCTRL_SCRIPT_PATH="$BUNDLED_RESOURCES_DIR/bin/$WARPCTRL_COMMAND_NAME"
echo "Creating warpctrl wrapper script at $WARPCTRL_SCRIPT_PATH..."
"$WORKSPACE_ROOT_DIR/script/macos/create_warpctrl_wrapper" \
"$WARPCTRL_SCRIPT_PATH" \
"../../MacOS/$WARP_BIN"
fi
# Store the built artifact locations for GitHub Actions outputs.
BINARY_PATH="target/$DEFAULT_TARGET/$TARGET_PROFILE_DIR/$WARP_BIN"
DMG_PATH="$OUT_DIR/$FINAL_DMG_NAME"
elif [[ "$ARTIFACT" == "cli" ]]; then
elif [[ "$ARTIFACT" == "cli" || "$ARTIFACT" == "warpctrl" ]]; then
if [[ $BUILD_BINARY == true ]]; then
# Create Info.plist before building the app, since it's embedded at build time.
# Apple's codesigning tools will detect Info.plist files in the same directory as an executable.
@@ -581,6 +602,18 @@ elif [[ "$ARTIFACT" == "cli" ]]; then
echo "Copying binary into $OUT_DIR/$WARP_BIN"
cp "target/$DEFAULT_TARGET/$TARGET_PROFILE_DIR/$WARP_BIN" "$OUT_DIR/$WARP_BIN"
if [[ "$ARTIFACT" == "warpctrl" ]]; then
if [[ ! ",$FEATURES," =~ ",warp_control_cli," ]]; then
echo "warpctrl artifact requires the warp_control_cli feature" >&2
exit 1
fi
WARPCTRL_SCRIPT_PATH="$OUT_DIR/warpctrl"
echo "Creating warpctrl wrapper script at $WARPCTRL_SCRIPT_PATH"
"$WORKSPACE_ROOT_DIR/script/macos/create_warpctrl_wrapper" \
"$WARPCTRL_SCRIPT_PATH" \
"$WARP_BIN"
fi
if [[ -n "$TARGET_ARCH" && -e "target/$DEFAULT_TARGET/$TARGET_PROFILE_DIR/$WARP_BIN.dSYM" ]]; then
echo "Copying .dSYM into $OUT_DIR/$WARP_BIN.dSYM"
cp -HR "target/$DEFAULT_TARGET/$TARGET_PROFILE_DIR/$WARP_BIN.dSYM" "$OUT_DIR/"
@@ -592,7 +625,11 @@ elif [[ "$ARTIFACT" == "cli" ]]; then
# Set the primary binary path to output.
BINARY_PATH="$OUT_DIR/$WARP_BIN"
if [[ "$ARTIFACT" == "warpctrl" ]]; then
BINARY_PATH="$OUT_DIR/warpctrl"
else
BINARY_PATH="$OUT_DIR/$WARP_BIN"
fi
else
echo "Unsupported artifact: $ARTIFACT" >&2
exit 1
@@ -659,7 +696,7 @@ if [[ $SELFSIGN = true ]]; then
if [[ "$ARTIFACT" == app ]]; then
echo "Self-signing $BUNDLE_DIR/$WARP_APP_NAME.app with ${SIGNING_CERT}..."
codesign --force --deep --options runtime --sign "$SIGNING_CERT" "$BUNDLE_DIR/$WARP_APP_NAME.app" --entitlements script/Debug-Entitlements.plist
elif [[ "$ARTIFACT" == cli ]]; then
elif [[ "$ARTIFACT" == cli || "$ARTIFACT" == warpctrl ]]; then
echo "Self-signing $OUT_DIR/$WARP_BIN with ${SIGNING_CERT}..."
codesign --force --options runtime --sign "$SIGNING_CERT" "$OUT_DIR/$WARP_BIN" --entitlements script/Debug-Entitlements.plist
fi
@@ -668,7 +705,7 @@ elif [[ $CODESIGN = true ]]; then
echo "Codesigning $BUNDLE_DIR/$WARP_APP_NAME.app..."
# Use --deep so we sign bundled frameworks as well
codesign --deep -f -o runtime --timestamp -s "$APPLE_TEAM_ID" "$BUNDLE_DIR/$WARP_APP_NAME.app" --entitlements script/Entitlements.plist
elif [[ "$ARTIFACT" == cli ]]; then
elif [[ "$ARTIFACT" == cli || "$ARTIFACT" == warpctrl ]]; then
echo "Codesigning $OUT_DIR/$WARP_BIN..."
codesign -f -o runtime --timestamp -s "$APPLE_TEAM_ID" "$OUT_DIR/$WARP_BIN" --entitlements script/Entitlements.plist
@@ -779,7 +816,7 @@ if [[ $CODESIGN = true ]]; then
echo "Verifying notarization ticket..."
if [[ "$ARTIFACT" = app ]]; then
xcrun stapler validate "$DMG_DIR/$DMG_NAME"
elif [[ "$ARTIFACT" = cli ]]; then
elif [[ "$ARTIFACT" = cli || "$ARTIFACT" = warpctrl ]]; then
spctl -a -t open --context context:primary-signature -vv "$OUT_DIR/$WARP_BIN"
fi
fi
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
set -e
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <wrapper-path> <binary-relative-path>" >&2
exit 1
fi
WRAPPER_PATH="$1"
BINARY_RELATIVE_PATH="$2"
mkdir -p "$(dirname "$WRAPPER_PATH")"
cat > "$WRAPPER_PATH" << EOF
#!/bin/bash
# This wrapper may be installed through a symlink in /usr/local/bin. Resolve
# symlinks before locating the Warp executable relative to the bundled wrapper.
wrapper_path="\${BASH_SOURCE[0]}"
while [[ -L "\$wrapper_path" ]]; do
wrapper_dir="\$(cd -P "\$(dirname "\$wrapper_path")" && pwd)"
wrapper_path="\$(readlink "\$wrapper_path")"
if [[ "\$wrapper_path" != /* ]]; then
wrapper_path="\$wrapper_dir/\$wrapper_path"
fi
done
script_dir="\$(cd -P "\$(dirname "\$wrapper_path")" && pwd)"
# Warp Control has a separate argument parser from the normal Warp/Oz parser.
# The hidden flag selects it before normal CLI parsing or GUI startup.
# Replace the wrapper process while preserving its invocation name as argv[0].
exec -a "\$0" "\$script_dir/$BINARY_RELATIVE_PATH" --warpctrl "\$@"
EOF
chmod +x "$WRAPPER_PATH"
+36 -11
View File
@@ -21,11 +21,19 @@ cd "${REPO_ROOT}"
: "${WARP_CHANNEL:?WARP_CHANNEL must be set (invoke via ./script/run)}"
: "${FEATURES:?FEATURES must be set (invoke via ./script/run)}"
# Resolve Cargo's actual target directory rather than assuming ./target. This
# honors a shared CARGO_TARGET_DIR / build.target-dir (e.g. set in
# ~/.cargo/config.toml), which is where `cargo bundle` writes the .app bundle.
TARGET_DIR="$(cargo metadata --no-deps --format-version 1 | jq -r .target_directory)"
if [ -z "$TARGET_DIR" ] || [ "$TARGET_DIR" = "null" ]; then
TARGET_DIR="${REPO_ROOT}/target"
fi
if [ "$WARP_CHANNEL" = "local" ]; then
WARP_APP_PATH="target/debug/bundle/osx/Galaxy Local.app"
WARP_APP_PATH="${TARGET_DIR}/debug/bundle/osx/Galaxy Local.app"
WARP_SCHEME_NAME="galaxylocal"
else
WARP_APP_PATH="target/debug/bundle/osx/Galaxy.app"
WARP_APP_PATH="${TARGET_DIR}/debug/bundle/osx/Galaxy.app"
WARP_SCHEME_NAME="galaxyoss"
fi
DONT_OPEN=false
@@ -58,11 +66,11 @@ while (( "$#" )); do
shift
;;
--release)
echo "Detected release build, pointing at release bundle under target/release/bundle"
echo "Detected release build, pointing at release bundle under ${TARGET_DIR}/release/bundle"
if [ "$WARP_CHANNEL" = "local" ]; then
WARP_APP_PATH="target/release/bundle/osx/Galaxy Local.app"
WARP_APP_PATH="${TARGET_DIR}/release/bundle/osx/Galaxy Local.app"
else
WARP_APP_PATH="target/release/bundle/osx/Galaxy.app"
WARP_APP_PATH="${TARGET_DIR}/release/bundle/osx/Galaxy.app"
fi
PARAMS="$PARAMS $1"
shift
@@ -71,9 +79,9 @@ while (( "$#" )); do
PROFILE="$2"
shift 2
if [ "$WARP_CHANNEL" = "local" ]; then
WARP_APP_PATH="target/${PROFILE}/bundle/osx/Galaxy Local.app"
WARP_APP_PATH="${TARGET_DIR}/${PROFILE}/bundle/osx/Galaxy Local.app"
else
WARP_APP_PATH="target/${PROFILE}/bundle/osx/Galaxy.app"
WARP_APP_PATH="${TARGET_DIR}/${PROFILE}/bundle/osx/Galaxy.app"
fi
PARAMS="$PARAMS --profile $PROFILE"
;;
@@ -103,6 +111,7 @@ popd > /dev/null
if [[ ",$FEATURES," =~ ",cocoa_sentry," ]]; then
echo "Copying Sentry framework into app bundle..."
SENTRY_FRAMEWORK="app/frameworks/dev/Sentry-Dynamic-WithARM64e.xcframework/macos-arm64_arm64e_x86_64/Sentry.framework"
mkdir -p "$WARP_APP_PATH/Contents/Frameworks"
cp -a "$SENTRY_FRAMEWORK" "$WARP_APP_PATH/Contents/Frameworks/"
fi
echo "Adding rpath to support mac frameworks (e.g. Sentry)"
@@ -126,6 +135,14 @@ if [[ ",$FEATURES," =~ ",heap_usage_tracking," ]]; then
"${REPO_ROOT}/script/prepare_bundled_pprof" "$HELPERS_DIR"
fi
if [[ ",$FEATURES," =~ ",warp_control_cli," ]]; then
WARPCTRL_SCRIPT_PATH="$WARP_APP_PATH/Contents/Resources/bin/warpctrl-$WARP_CHANNEL"
echo "Creating warpctrl wrapper script at $WARPCTRL_SCRIPT_PATH..."
"${REPO_ROOT}/script/macos/create_warpctrl_wrapper" \
"$WARPCTRL_SCRIPT_PATH" \
"../../MacOS/$WARP_BIN_NAME"
fi
echo "Codesigning app..."
SIGNING_CERT="$(security find-identity -p codesigning -v | grep "Apple Development" | awk '{print $2}' | head -1)"
codesign --force --deep --options runtime --sign "${SIGNING_CERT:--}" "$WARP_APP_PATH" --entitlements script/Debug-Entitlements.plist
@@ -133,10 +150,18 @@ codesign --force --deep --options runtime --sign "${SIGNING_CERT:--}" "$WARP_APP
if [ "$DONT_OPEN" = false ] ; then
if [ "$OPEN_WITH_LAUNCHD" = true ]; then
echo "Launching with MacOS application launcher"
PATH="" /usr/bin/open "./$WARP_APP_PATH"
tail -f ~/Library/Logs/warp_local.log
PATH="" /usr/bin/open "$WARP_APP_PATH"
if [ "$WARP_CHANNEL" = "local" ]; then
LOG_FILE=~/Library/Logs/warp_local.log
elif [ "$WARP_CHANNEL" = "oss" ]; then
LOG_FILE=~/Library/Logs/warp-oss.log
else
echo "Warning: unrecognized WARP_CHANNEL '$WARP_CHANNEL', defaulting to OSS log path" >&2
LOG_FILE=~/Library/Logs/warp-oss.log
fi
tail -F "$LOG_FILE"
else
echo "Opening app at ./$WARP_APP_PATH/Contents/MacOS/$WARP_BIN_NAME"
"./$WARP_APP_PATH/Contents/MacOS/$WARP_BIN_NAME" "${WARP_ARGS[@]}"
echo "Opening app at $WARP_APP_PATH/Contents/MacOS/$WARP_BIN_NAME"
"$WARP_APP_PATH/Contents/MacOS/$WARP_BIN_NAME" "${WARP_ARGS[@]}"
fi
fi
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
set -e
workspace_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
temp_dir="$(mktemp -d)"
trap 'rm -rf "$temp_dir"' EXIT
bundle_dir="$temp_dir/WarpDev.app/Contents"
wrapper_path="$bundle_dir/Resources/bin/warpctrl-dev"
binary_path="$bundle_dir/MacOS/dev"
installed_path="$temp_dir/usr/local/bin/warpctrl-dev"
forwarded_args_file="$temp_dir/forwarded-args"
expected_args_file="$temp_dir/expected-args"
mkdir -p "$(dirname "$binary_path")" "$(dirname "$installed_path")"
cat > "$binary_path" << 'EOF'
#!/bin/bash
printf '%s\n' "$@" > "$FORWARDED_ARGS_FILE"
EOF
chmod +x "$binary_path"
"$workspace_root/script/macos/create_warpctrl_wrapper" \
"$wrapper_path" \
"../../MacOS/dev"
cat > "$expected_args_file" << 'EOF'
--warpctrl
tab
create
--instance
inst 123
EOF
FORWARDED_ARGS_FILE="$forwarded_args_file" \
"$wrapper_path" tab create --instance "inst 123"
cmp "$expected_args_file" "$forwarded_args_file"
ln -s "$wrapper_path" "$installed_path"
FORWARDED_ARGS_FILE="$forwarded_args_file" \
"$installed_path" tab create --instance "inst 123"
cmp "$expected_args_file" "$forwarded_args_file"