builder & dev tools

This commit is contained in:
lyuksovannyy committed 2026-09-12 03:57:17 +02:00
1 parent c0ad0d49f2
commit ae63f8b9a3
26 files changed
+1504 -1

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$ADB" "$PY"
DEBUG=0
for arg in "$@"; do
case "$arg" in
--debug) DEBUG=1 ;;
*) die "unknown argument: $arg" ;;
esac
done
"$ADB" start-server
timeout 60 "$ADB" wait-for-device || die "timed out waiting for a device (ANDROID_SERIAL=${ANDROID_SERIAL:-<unset>})"
"$ADB" forward --remove "tcp:$DEV_PORT" >/dev/null 2>&1 || true
"$ADB" forward "tcp:$DEV_PORT" "tcp:$DEV_PORT"
if [[ "$DEBUG" -eq 1 ]]; then
"$ADB" forward --remove "tcp:$DEBUG_PORT" >/dev/null 2>&1 || true
"$ADB" forward "tcp:$DEBUG_PORT" "tcp:$DEBUG_PORT"
fi
if "$PY" tools/devclient.py ping >/dev/null 2>&1; then
echo "connected"
else
die "ping failed — is the plugin engine + developer mode enabled in exteraGram Preferences > Plugins?"
fi
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$ADB" "$PY"
usage() {
cat >&2 <<'EOF'
usage: scripts/debug.sh start|stop [--platform vscode|pycharm]
Requires the device-side debugger package to be present in the app's Python
runtime: `debugpy` for vscode, `pydevd-pycharm` for pycharm. If it is not
installed, add it to "requirements" in plugin.json so the app's pip
controller installs it on next load.
EOF
}
[[ $# -ge 1 ]] || { usage; exit 1; }
ACTION="$1"
shift
PLATFORM=vscode
while [[ $# -gt 0 ]]; do
case "$1" in
--platform)
PLATFORM="${2:-}"
shift 2
;;
--platform=*)
PLATFORM="${1#--platform=}"
shift
;;
*)
die "unknown argument: $1"
;;
esac
done
case "$ACTION" in
start|stop) ;;
*) usage; exit 1 ;;
esac
case "$PLATFORM" in
vscode|pycharm) ;;
*) die "--platform must be vscode or pycharm" ;;
esac
scripts/adb-connect.sh --debug
"$PY" tools/devclient.py debugger "$ACTION" --platform "$PLATFORM"
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$PY"
MODE=--dev
ENABLE=0
CONNECT=1
for arg in "$@"; do
case "$arg" in
--release) MODE=--release ;;
--enable) ENABLE=1 ;;
--no-connect) CONNECT=0 ;;
*) die "unknown argument: $arg" ;;
esac
done
"$PY" tools/bundle.py "$MODE" --out dist
BUNDLE="dist/${PLUGIN_ID}.plugin"
[[ -f "$BUNDLE" ]] || die "expected bundle not found at $BUNDLE"
echo "bundle: $BUNDLE ($(stat -c '%s' "$BUNDLE" 2>/dev/null || stat -f '%z' "$BUNDLE") bytes)"
if [[ "$CONNECT" -eq 1 ]]; then
need_cmd "$ADB"
scripts/adb-connect.sh
fi
DEPLOY_ARGS=(deploy "$BUNDLE" --id "$PLUGIN_ID")
if [[ "$ENABLE" -eq 1 ]]; then
DEPLOY_ARGS+=(--enable)
fi
"$PY" tools/devclient.py "${DEPLOY_ARGS[@]}"
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$PY" curl unzip sha256sum
BETA=0
for arg in "$@"; do
case "$arg" in
--beta) BETA=1 ;;
*) die "unknown argument: $arg" ;;
esac
done
API_URL="https://api.github.com/repos/exteraSquad/plugins-pysdk-builds/releases?per_page=20"
RELEASE_JSON="$(mktemp)"
trap 'rm -rf "$RELEASE_JSON" "$WORKDIR"' EXIT
curl -fsSL "$API_URL" -o "$RELEASE_JSON" || die "failed to query GitHub releases API"
read -r TAG ASSET_URL SHA_URL < <("$PY" - "$RELEASE_JSON" "$BETA" <<'PYEOF'
import json, sys
path, allow_beta = sys.argv[1], sys.argv[2] == "1"
with open(path, encoding="utf-8") as f:
releases = json.load(f)
for rel in releases:
if rel.get("prerelease") and not allow_beta:
continue
assets = {a["name"]: a["browser_download_url"] for a in rel.get("assets", [])}
if "stubs.zip" in assets:
sha_url = assets.get("stubs.zip.sha256", "")
print(rel["tag_name"], assets["stubs.zip"], sha_url)
break
else:
sys.exit("no release with a stubs.zip asset found")
PYEOF
) || die "no release with a stubs.zip asset found"
[[ -n "$TAG" ]] || die "could not determine a release to install"
WORKDIR="$(mktemp -d)"
curl -fsSL "$ASSET_URL" -o "$WORKDIR/stubs.zip" || die "failed to download stubs.zip"
if [[ -n "$SHA_URL" ]]; then
curl -fsSL "$SHA_URL" -o "$WORKDIR/stubs.zip.sha256" || die "failed to download stubs.zip.sha256"
(cd "$WORKDIR" && sha256sum -c stubs.zip.sha256) || die "checksum verification failed for stubs.zip"
else
echo "warning: no stubs.zip.sha256 asset published for $TAG; skipping checksum verification" >&2
fi
rm -rf stubs
mkdir -p stubs
unzip -q "$WORKDIR/stubs.zip" -d "$WORKDIR/outer"
INNER="$WORKDIR/outer/pyi-files.zip"
[[ -f "$INNER" ]] || die "expected pyi-files.zip inside stubs.zip, not found"
unzip -q "$INNER" -d stubs
echo "installed SDK stubs from release $TAG into stubs/"
+26
View File
@@ -0,0 +1,26 @@
# Shared helpers for scripts/*.sh. Source, do not execute:
# source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PKG=com.exteragram.messenger
DEV_PORT=42690
DEBUG_PORT=5678
PY="${PYTHON:-python3}"
ADB="${ADB:-adb}"
PLUGIN_ID="$("$PY" -c "import json,sys; print(json.load(open(sys.argv[1]))['id'])" "$REPO_ROOT/plugin.json")"
die() {
echo "error: $*" >&2
exit 1
}
need_cmd() {
for cmd in "$@"; do
command -v "$cmd" >/dev/null 2>&1 || die "required command not found on PATH: $cmd"
done
}
app_pid() {
"$ADB" shell pidof -s "$PKG" | tr -d '\r'
}
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$ADB"
CLEAR=0
STDIO=0
PATTERN=""
while [[ $# -gt 0 ]]; do
case "$1" in
-c) CLEAR=1; shift ;;
-t) STDIO=1; shift ;;
-g) PATTERN="${2:-}"; shift 2 ;;
*) die "unknown argument: $1" ;;
esac
done
if [[ "$CLEAR" -eq 1 ]]; then
"$ADB" logcat -c
fi
run_logcat() {
if [[ "$STDIO" -eq 1 ]]; then
"$ADB" logcat -s python.stdout:'*' python.stderr:'*'
else
local pid
pid="$(app_pid)"
[[ -n "$pid" ]] || die "exteraGram is not running — open the app first"
"$ADB" logcat --pid="$pid"
fi
}
if [[ -n "$PATTERN" ]]; then
run_logcat | grep --line-buffered -E "$PATTERN"
else
run_logcat
fi
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
source scripts/lib.sh
need_cmd "$PY"
checksum() {
find src plugin.json -type f -printf '%T@ %p\n' 2>/dev/null | sha256sum
}
run_deploy() {
if ! scripts/deploy.sh "$@"; then
echo "deploy failed, still watching..." >&2
fi
}
echo "watching src/ and plugin.json for changes..."
run_deploy "$@"
if command -v inotifywait >/dev/null 2>&1; then
while true; do
inotifywait -qq -r -e close_write,create,delete,move src plugin.json 2>/dev/null || true
sleep 0.3
run_deploy "$@"
done
else
echo "inotifywait not found; falling back to polling" >&2
last="$(checksum)"
while true; do
sleep 1
current="$(checksum)"
if [[ "$current" != "$last" ]]; then
last="$current"
sleep 0.3
run_deploy "$@"
fi
done
fi