first pass of merging in warp (doesn't build)
This commit is contained in:
+66
-18
@@ -77,12 +77,8 @@ case "$PROFILE_MODE" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check for musl-cross linker
|
||||
if ! command -v x86_64-linux-musl-gcc &>/dev/null; then
|
||||
echo "Error: x86_64-linux-musl-gcc not found." >&2
|
||||
echo "Install it with: brew install filosottile/musl-cross/musl-cross" >&2
|
||||
exit 1
|
||||
fi
|
||||
TARGET="x86_64-unknown-linux-musl"
|
||||
source "$SCRIPT_DIR/linux/configure_musl_toolchain" "$TARGET"
|
||||
|
||||
# Check for musl target
|
||||
if ! rustup target list --installed 2>/dev/null | grep -q x86_64-unknown-linux-musl; then
|
||||
@@ -91,9 +87,7 @@ if ! rustup target list --installed 2>/dev/null | grep -q x86_64-unknown-linux-m
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine build parameters
|
||||
TARGET="x86_64-unknown-linux-musl"
|
||||
|
||||
# Select the requested Cargo build profile.
|
||||
case "$PROFILE_MODE" in
|
||||
dev-remote)
|
||||
CARGO_PROFILE="dev-remote"
|
||||
@@ -109,10 +103,13 @@ case "$PROFILE_MODE" in
|
||||
;;
|
||||
esac
|
||||
|
||||
FEATURES="release_bundle,crash_reporting,standalone,agent_mode_debug"
|
||||
FEATURES="release_bundle,crash_reporting,standalone,agent_mode_debug,remote_codebase_indexing"
|
||||
WARP_BIN="warp"
|
||||
BINARY_NAME="oz-local"
|
||||
REMOTE_DIR=".warp-local/remote-server"
|
||||
# Global, version-independent resources location read by the daemon. Must
|
||||
# match BUNDLED_RESOURCES_DIR_NAME in crates/remote_server/src/setup.rs.
|
||||
BUNDLED_RESOURCES_DIR_NAME="bundled_resources"
|
||||
|
||||
# Determine the output directory
|
||||
CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$WORKSPACE_ROOT/target}"
|
||||
@@ -125,17 +122,14 @@ case "$CARGO_PROFILE" in
|
||||
;;
|
||||
esac
|
||||
BUILT_BINARY="$OUTPUT_DIR/$WARP_BIN"
|
||||
LOCAL_RESOURCES_DIR="$OUTPUT_DIR/remote-server-resources"
|
||||
|
||||
echo "==> Building Oz CLI for $TARGET (profile=$CARGO_PROFILE)"
|
||||
echo " Binary: $WARP_BIN -> $BINARY_NAME"
|
||||
echo " Features: $FEATURES"
|
||||
echo ""
|
||||
|
||||
# Build with linker and rustflags overrides to avoid macOS-specific flags
|
||||
# from .cargo/config.toml
|
||||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc \
|
||||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C symbol-mangling-version=v0" \
|
||||
cargo build \
|
||||
cargo build \
|
||||
-p warp \
|
||||
--bin "$WARP_BIN" \
|
||||
--target "$TARGET" \
|
||||
@@ -150,6 +144,13 @@ fi
|
||||
BINARY_SIZE=$(du -h "$BUILT_BINARY" | cut -f1)
|
||||
echo ""
|
||||
echo "==> Build complete ($BINARY_SIZE)"
|
||||
# Prepare the bundled resources tree (skills, settings schema) deployed to
|
||||
# the global, version-independent location the daemon reads.
|
||||
rm -rf "$LOCAL_RESOURCES_DIR"
|
||||
"$WORKSPACE_ROOT/script/prepare_bundled_resources" \
|
||||
"$LOCAL_RESOURCES_DIR" \
|
||||
local \
|
||||
"$CARGO_PROFILE"
|
||||
|
||||
# Resolve $HOME on the remote so our upload lands in the same directory the
|
||||
# Warp client checks. The client runs `test -x ~/.warp-local/...` and lets
|
||||
@@ -175,10 +176,10 @@ if ! ssh "$HOST" "command -v rsync" &>/dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensure the remote directory exists
|
||||
# Ensure the remote install directory exists
|
||||
ssh "$HOST" "mkdir -p $REMOTE_ABS_DIR"
|
||||
|
||||
echo "==> Uploading to $HOST:$REMOTE_ABS_DIR/$BINARY_NAME"
|
||||
echo "==> Uploading binary to $HOST:$REMOTE_ABS_DIR/$BINARY_NAME"
|
||||
|
||||
# Upload via rsync with delta transfer and compression.
|
||||
# After the first deploy, only changed bytes are transferred.
|
||||
@@ -189,6 +190,53 @@ rsync -z -t --partial --progress \
|
||||
# Set executable permissions (done separately for openrsync compatibility on macOS)
|
||||
ssh "$HOST" "chmod 755 $REMOTE_ABS_DIR/$BINARY_NAME"
|
||||
|
||||
echo "==> Uploading bundled resources to $HOST:$REMOTE_ABS_DIR/$BUNDLED_RESOURCES_DIR_NAME"
|
||||
rsync -z -rlt --delete --partial --progress \
|
||||
"$LOCAL_RESOURCES_DIR/" \
|
||||
"$HOST:$REMOTE_ABS_DIR/$BUNDLED_RESOURCES_DIR_NAME/"
|
||||
|
||||
echo "==> Stopping stale remote-server daemons on $HOST"
|
||||
ssh "$HOST" bash <<'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
REMOTE_SERVER_ROOT="$HOME/.warp-local/remote-server"
|
||||
shopt -s nullglob
|
||||
|
||||
for pid_file in "$REMOTE_SERVER_ROOT"/*/server.pid; do
|
||||
daemon_dir="$(dirname "$pid_file")"
|
||||
pid="$(cat "$pid_file" 2>/dev/null || true)"
|
||||
if [[ -z "$pid" || ! "$pid" =~ ^[0-9]+$ ]]; then
|
||||
rm -f "$daemon_dir/server.sock" "$pid_file"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ! -r "/proc/$pid/cmdline" ]]; then
|
||||
rm -f "$daemon_dir/server.sock" "$pid_file"
|
||||
continue
|
||||
fi
|
||||
|
||||
cmdline="$(tr '\0' ' ' <"/proc/$pid/cmdline" || true)"
|
||||
if [[ "$cmdline" != *remote-server-daemon* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " Stopping stale daemon pid=$pid dir=$daemon_dir"
|
||||
kill "$pid" 2>/dev/null || true
|
||||
for _ in {1..50}; do
|
||||
if ! kill -0 "$pid" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
echo " Force-stopping stale daemon pid=$pid"
|
||||
kill -9 "$pid" 2>/dev/null || true
|
||||
fi
|
||||
rm -f "$daemon_dir/server.sock" "$pid_file"
|
||||
done
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "==> Done! Binary deployed to $HOST:$REMOTE_ABS_DIR/$BINARY_NAME"
|
||||
echo " (resolved from ~/$REMOTE_DIR/$BINARY_NAME on remote)"
|
||||
echo " Bundled resources: $REMOTE_ABS_DIR/$BUNDLED_RESOURCES_DIR_NAME"
|
||||
echo " (resolved from ~/$REMOTE_DIR on remote)"
|
||||
|
||||
Reference in New Issue
Block a user