Repository navigation
Expand file tree
/
Copy pathsync-harness.sh
More file actions
executable file
·120 lines (98 loc) · 4.89 KB
/
Copy pathsync-harness.sh
File metadata and controls
executable file
·120 lines (98 loc) · 4.89 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
119
120
#!/usr/bin/env bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HARNESS_DIR="${SCRIPT_DIR}/antigravity-sdk-harness"
BIN_DIR="${HARNESS_DIR}/src/main/resources/google/antigravity/bin"
SLICES=("linux-x86_64" "osx-aarch64" "osx-x86_64" "linux-aarch64" "windows-x86_64" "windows-aarch64")
# Check if binaries exist in legacy wrapper dir locally, copy them over
LEGACY_WRAPPER_BIN="${SCRIPT_DIR}/antigravity-sdk-wrapper/src/main/resources/google/antigravity/bin"
if [ -d "$LEGACY_WRAPPER_BIN" ] && [ -n "$(ls -A "$LEGACY_WRAPPER_BIN" 2>/dev/null)" ] && [ ! -d "$BIN_DIR" ]; then
echo "Migrating binaries from wrapper to harness module..."
mkdir -p "$BIN_DIR"
cp -R "$LEGACY_WRAPPER_BIN"/* "$BIN_DIR"/
fi
# If running inside a nested checkout (e.g. target/checkout during maven-release-plugin),
# check if the parent project already downloaded the binaries
PARENT_BIN_DIR="${SCRIPT_DIR}/../../antigravity-sdk-harness/src/main/resources/google/antigravity/bin"
if [ -d "$PARENT_BIN_DIR" ] && [ -n "$(ls -A "$PARENT_BIN_DIR" 2>/dev/null)" ]; then
echo "Found pre-synced binaries in parent directory: $PARENT_BIN_DIR"
echo "Copying binaries from parent..."
mkdir -p "$BIN_DIR"
cp -R "$PARENT_BIN_DIR"/* "$BIN_DIR"/
echo "Binaries successfully copied from parent."
exit 0
fi
PACKAGE_INFO=$(curl -s https://pypi.org/pypi/google-antigravity/json)
UPSTREAM_VERSION=$(echo "$PACKAGE_INFO" | jq -r '.info.version // "unknown"')
echo "Detected upstream google-antigravity version: v${UPSTREAM_VERSION}"
VERSION_FILE="${BIN_DIR}/.version"
CURRENT_VERSION=""
if [ -f "$VERSION_FILE" ]; then
CURRENT_VERSION=$(cat "$VERSION_FILE" | tr -d '[:space:]')
fi
# Check if all slices already exist locally, are non-empty, and match upstream version
ALL_EXIST=true
for SLICE in "${SLICES[@]}"; do
BINARY_PATH="$BIN_DIR/$SLICE/localharness"
if [[ "$SLICE" == windows* ]]; then
BINARY_PATH="$BIN_DIR/$SLICE/localharness.exe"
fi
if [ ! -f "$BINARY_PATH" ] || [ ! -s "$BINARY_PATH" ]; then
ALL_EXIST=false
break
fi
done
if [ "$ALL_EXIST" = true ] && [ "$CURRENT_VERSION" = "$UPSTREAM_VERSION" ] && [ "${FORCE_SYNC:-false}" != "true" ]; then
echo "All Go harness binaries are already present and up-to-date (v${CURRENT_VERSION}) in $BIN_DIR. (Set FORCE_SYNC=true to re-download and unpack Python source)"
exit 0
fi
echo "Syncing Go harness binaries from upstream PyPI wheels (current: '${CURRENT_VERSION:-none}', target: 'v${UPSTREAM_VERSION}')..."
PLATFORMS=("manylinux" "macosx" "macosx" "manylinux" "win" "win")
ARCHS=("x86_64" "arm64" "x86_64" "aarch64" "amd64" "arm64")
EXTRACTED_PYTHON=false
for i in "${!PLATFORMS[@]}"; do
PLATFORM="${PLATFORMS[$i]}"
ARCH="${ARCHS[$i]}"
SLICE="${SLICES[$i]}"
echo "Searching wheel for: $SLICE"
WHEEL_URL=$(echo "$PACKAGE_INFO" | jq -r --arg plt "$PLATFORM" --arg arc "$ARCH" '.urls[] | select(.filename | contains($plt) and contains($arc)) | .url' | head -n 1)
if [ -n "$WHEEL_URL" ] && [ "$WHEEL_URL" != "null" ]; then
WHEEL_FILE="wheel_${SLICE}.whl"
echo "Downloading $SLICE from $WHEEL_URL"
curl -sL -o "$WHEEL_FILE" "$WHEEL_URL"
# Extract Python package source from the first downloaded wheel for systematic diffing and API audit
if [ "$EXTRACTED_PYTHON" = false ]; then
UPSTREAM_PYTHON_DIR="${SCRIPT_DIR}/target/upstream-python"
echo "Extracting Python SDK source to $UPSTREAM_PYTHON_DIR and /tmp/antigravity_upstream/ for API audit..."
rm -rf "$UPSTREAM_PYTHON_DIR" /tmp/antigravity_upstream
mkdir -p "$UPSTREAM_PYTHON_DIR" /tmp/antigravity_upstream
unzip -q -o "$WHEEL_FILE" "google/antigravity/*" -d "$UPSTREAM_PYTHON_DIR" 2>/dev/null || true
if [ -d "$UPSTREAM_PYTHON_DIR/google/antigravity" ]; then
cp -R "$UPSTREAM_PYTHON_DIR"/google/antigravity/* /tmp/antigravity_upstream/ 2>/dev/null || true
echo "Python SDK source successfully unpacked."
fi
EXTRACTED_PYTHON=true
fi
TARGET_DIR="$BIN_DIR/$SLICE"
mkdir -p "$TARGET_DIR"
if [[ "$PLATFORM" == "win" ]]; then
unzip -p "$WHEEL_FILE" "google/antigravity/bin/localharness.exe" > "$TARGET_DIR/localharness.exe"
chmod +x "$TARGET_DIR/localharness.exe"
else
unzip -p "$WHEEL_FILE" "google/antigravity/bin/localharness" > "$TARGET_DIR/localharness"
chmod +x "$TARGET_DIR/localharness"
fi
rm -f "$WHEEL_FILE"
else
echo "Warning: No matching upstream wheel found for platform slice: $SLICE"
fi
done
# Write version stamp
echo "$UPSTREAM_VERSION" > "$BIN_DIR/.version"
echo "================================================================="
echo "Go harness synchronization complete (upstream v${UPSTREAM_VERSION})."
if [ "$EXTRACTED_PYTHON" = true ]; then
echo "Python SDK source unpacked at: /tmp/antigravity_upstream/"
echo "Audit step: diff -r <previous_source_dir> /tmp/antigravity_upstream/"
fi
echo "================================================================="