mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
e58cbcdb5f
Move the scattered root-level native projects into per-platform folders and drop
the now-redundant platform prefix:
- android-ime-helper/ -> android/ime-helper/
- android-multitouch-helper/ -> android/multitouch-helper/
- android-snapshot-helper/ -> android/snapshot-helper/
- apple-runner/ -> apple/runner/
- macos-helper/ -> apple/macos-helper/
- src/platforms/linux/atspi-dump.py -> linux/atspi-dump.py
Only repo source paths move. Identity surfaces stay frozen so no user's runner
cache is invalidated on upgrade: the derived-cache key hashes source paths
relative to AgentDeviceRunner and excludes packageVersion, and the
~/.agent-device/{apple-runner,macos-helper} namespaces, the
agent-device-android-*-helper artifact/manifest/protocol names, the
AgentDeviceRunner Xcode project, and the `prepare ios-runner` CLI command are
unchanged. Updates build/package scripts, CI, package.json files+scripts,
ignore/attr/fallow configs, runtime path resolvers, and test fixtures.
Also: re-base repo-root-relative refs inside the moved apple/runner for the
added nesting level (gated XCUITest fixture walk + two doc links), and clean the
legacy dist/apple-runner packaged output so the relocated runner can't
double-ship into the wholesale-included dist (with a regression test).
112 lines
3.0 KiB
Bash
112 lines
3.0 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
if [ "$#" -ne 2 ]; then
|
|
echo "Usage: $0 <version> <output-dir>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
VERSION="$1"
|
|
OUTPUT_DIR="$2"
|
|
PROJECT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
|
|
HELPER_DIR="$PROJECT_DIR/android/multitouch-helper"
|
|
PACKAGE_NAME="com.callstack.agentdevice.multitouchhelper"
|
|
MIN_SDK=23
|
|
TARGET_SDK=36
|
|
APK_BASENAME="agent-device-android-multitouch-helper-$VERSION.apk"
|
|
|
|
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}"
|
|
if [ -z "$SDK_ROOT" ] || [ ! -d "$SDK_ROOT" ]; then
|
|
echo "ANDROID_HOME or ANDROID_SDK_ROOT must point to an Android SDK" >&2
|
|
exit 1
|
|
fi
|
|
|
|
ANDROID_JAR="$SDK_ROOT/platforms/android-$TARGET_SDK/android.jar"
|
|
if [ ! -f "$ANDROID_JAR" ]; then
|
|
echo "Missing Android platform jar: $ANDROID_JAR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
BUILD_TOOLS_DIR="$(
|
|
find "$SDK_ROOT/build-tools" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sort -V | tail -n 1
|
|
)"
|
|
if [ -z "$BUILD_TOOLS_DIR" ] || [ ! -x "$BUILD_TOOLS_DIR/aapt2" ]; then
|
|
echo "Missing Android build tools under $SDK_ROOT/build-tools" >&2
|
|
exit 1
|
|
fi
|
|
|
|
VERSION_CODE="$(
|
|
printf '%s\n' "$VERSION" | awk -F. '
|
|
/^[0-9]+[.][0-9]+[.][0-9]+$/ {
|
|
print ($1 * 1000000) + ($2 * 1000) + $3
|
|
next
|
|
}
|
|
{ print 1 }
|
|
'
|
|
)"
|
|
|
|
BUILD_DIR="$HELPER_DIR/build"
|
|
CLASSES_DIR="$BUILD_DIR/classes"
|
|
TEST_CLASSES_DIR="$BUILD_DIR/test-classes"
|
|
DEX_DIR="$BUILD_DIR/dex"
|
|
KEYSTORE="$PROJECT_DIR/android/snapshot-helper/debug.keystore"
|
|
UNSIGNED_APK="$BUILD_DIR/helper-unsigned.apk"
|
|
ALIGNED_APK="$BUILD_DIR/helper-aligned.apk"
|
|
APK_PATH="$OUTPUT_DIR/$APK_BASENAME"
|
|
|
|
rm -rf "$BUILD_DIR"
|
|
mkdir -p "$CLASSES_DIR" "$TEST_CLASSES_DIR" "$DEX_DIR" "$OUTPUT_DIR"
|
|
|
|
javac \
|
|
--release 11 \
|
|
-classpath "$ANDROID_JAR" \
|
|
-d "$CLASSES_DIR" \
|
|
$(find "$HELPER_DIR/src/main/java" -name '*.java' | sort)
|
|
|
|
javac \
|
|
--release 11 \
|
|
-classpath "$ANDROID_JAR:$CLASSES_DIR" \
|
|
-d "$TEST_CLASSES_DIR" \
|
|
$(find "$HELPER_DIR/src/test/java" -name '*.java' | sort)
|
|
|
|
java \
|
|
-classpath "$ANDROID_JAR:$CLASSES_DIR:$TEST_CLASSES_DIR" \
|
|
com.callstack.agentdevice.multitouchhelper.PointerEventScheduleTest
|
|
|
|
"$BUILD_TOOLS_DIR/d8" \
|
|
--min-api "$MIN_SDK" \
|
|
--classpath "$ANDROID_JAR" \
|
|
--output "$DEX_DIR" \
|
|
$(find "$CLASSES_DIR" -name '*.class' | sort)
|
|
|
|
"$BUILD_TOOLS_DIR/aapt2" link \
|
|
--manifest "$HELPER_DIR/AndroidManifest.xml" \
|
|
-I "$ANDROID_JAR" \
|
|
--min-sdk-version "$MIN_SDK" \
|
|
--target-sdk-version "$TARGET_SDK" \
|
|
--version-code "$VERSION_CODE" \
|
|
--version-name "$VERSION" \
|
|
-o "$UNSIGNED_APK"
|
|
|
|
zip -q -j "$UNSIGNED_APK" "$DEX_DIR/classes.dex"
|
|
|
|
"$BUILD_TOOLS_DIR/zipalign" -f 4 "$UNSIGNED_APK" "$ALIGNED_APK"
|
|
|
|
if [ ! -f "$KEYSTORE" ]; then
|
|
echo "Missing Android helper signing keystore: $KEYSTORE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
"$BUILD_TOOLS_DIR/apksigner" sign \
|
|
--ks "$KEYSTORE" \
|
|
--ks-pass pass:android \
|
|
--key-pass pass:android \
|
|
--out "$APK_PATH" \
|
|
"$ALIGNED_APK"
|
|
|
|
"$BUILD_TOOLS_DIR/apksigner" verify --min-sdk-version "$MIN_SDK" "$APK_PATH"
|
|
|
|
printf 'apk=%s\n' "$APK_PATH"
|
|
printf 'package=%s\n' "$PACKAGE_NAME"
|
|
printf 'version_code=%s\n' "$VERSION_CODE"
|