forked from Blendman974/faceclaw
Refactor build scripts
This commit is contained in:
1 parent
f858f10ce2
commit
ed8302bc6b
7 files changed
+81
-28
No files matched your search
+2
-2
@@ -41,5 +41,5 @@ old
|
||||
faceclaw_settings.xml
|
||||
|
||||
# Developer configs
|
||||
build.sh
|
||||
build_and_run.sh
|
||||
build_paths.sh
|
||||
|
||||
@@ -8,20 +8,19 @@ Typescript parts are in app/. Java parts are in App_Resources/Android/src/main/j
|
||||
wear/ is a separate Gradle project (Kotlin + Compose for Wear OS): the watch
|
||||
remote that drives Faceclaw over the Wearable Data Layer. Its phone-side
|
||||
counterparts are FaceclawWearBridge.java, app/native/wear-bridge.ts and
|
||||
app/g2/wear-remote.ts; the message format is in wear/PROTOCOL.md. Build it
|
||||
with `cd wear && ./gradlew :app:assembleDebug` (needs JAVA_HOME and
|
||||
ANDROID_HOME); it is not part of `npm run build`.
|
||||
app/g2/wear-remote.ts; the message format is in wear/PROTOCOL.md.
|
||||
|
||||
If build.sh exists, it's a machine-specific wrapper that sets some environment
|
||||
variables to point to where tools are installed, then runs `npm run build`.
|
||||
If build_and_run.sh exists, it does everything build.sh does plus
|
||||
`nativescript run android --device <id> --justlaunch`,
|
||||
which will launch the app on the developer's phone if it is plugged in and has
|
||||
adb enabled. If no phone is connected, it will still build but the install step
|
||||
will fail and the output will contain the string "Cannot find connected
|
||||
devices." To lint and typecheck, prefer to use build.sh; if the user asks you
|
||||
to run or test the app, use build_and_run.sh and then use `adb logcat` to view
|
||||
the results.
|
||||
`build.sh` and `build_wear.sh` build the Android and Wear OS apps respectively.
|
||||
`build_and_run.sh` builds the Android app then also installs it on a phone
|
||||
paired with `adb`. Building may require configuring environment variables
|
||||
(JAVA_HOME, ANDROID_HOME, PATH, ANDROID_KEYSTORE, ANDROID_KEYSTORE) to point at
|
||||
relevant tools and an Android device ID to install on; do this in
|
||||
build_paths.sh, which is created from build_paths.sh.template and not checked
|
||||
into git.
|
||||
|
||||
To lint and typecheck, prefer to use build.sh; if the user asks you to run or
|
||||
test the app, use build_and_run.sh and then use `adb logcat` to view the
|
||||
results.
|
||||
|
||||
If you are working on low-level communication bits, consider checking out
|
||||
https://github.com/Commute773/g2-kit-unofficial/ and referring to ble/docs/
|
||||
@@ -30,4 +29,10 @@ well as some communication test scripts and documentation of caveats that
|
||||
come up when communicating with the headset. There may already be an existing
|
||||
local checkout above this workspace at ../g2-kit-unofficial.
|
||||
|
||||
This Android app uses a modded firmware for the G2 smart glasses. Source code
|
||||
to the corresponding firmware modifications lives in
|
||||
https://github.com/jimrandomh/g2flash; there is a compiled version of the
|
||||
firmware patch-set in app/g2/firmware/cfw-patches.ts. Strongly prefer making
|
||||
changes to the Android app over making changes to changes to the firmware, as
|
||||
firmware development is considerably more fraught.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"; source scripts/before_build.sh
|
||||
|
||||
npx nativescript build android "$@"
|
||||
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"; source scripts/before_build.sh
|
||||
|
||||
npx nativescript build android "$@" && \
|
||||
adb connect "$DEVICE_ID" >/dev/null && \
|
||||
nativescript run android --device "$DEVICE_ID" --justlaunch
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# Copy this file to build_paths.sh and add any paths or other prelude needed
|
||||
# before build. Other build scripts will `source` it.
|
||||
|
||||
#export JAVA_HOME=
|
||||
#export ANDROID_HOME=
|
||||
#export PATH=
|
||||
#export ANDROID_KEYSTORE=
|
||||
#export DEVICE_ID=
|
||||
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$0")"; source scripts/before_build.sh
|
||||
|
||||
cd wear && ./gradlew build "$@"
|
||||
|
||||
+35
-13
@@ -1,20 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Build a signed release APK at dist/Faceclaw-<version>.apk, where <version>
|
||||
# comes from FACECLAW_VERSION in app/version.ts.
|
||||
# Build signed release APKs at dist/Faceclaw-<version>.apk (phone) and
|
||||
# dist/Faceclaw-Wear-<version>.apk (watch), where <version> comes from
|
||||
# FACECLAW_VERSION in app/version.ts. Both are signed with the same key:
|
||||
# the Wearable Data Layer only routes between apps with matching package
|
||||
# names and signing keys.
|
||||
#
|
||||
# Prompts for the keystore passphrase. Override the keystore location with
|
||||
# ANDROID_KEYSTORE=/path/to/store.jks.
|
||||
#
|
||||
# Note: the passphrase is passed to the nativescript CLI on its command line,
|
||||
# so it is briefly visible in `ps` on this machine while the build runs.
|
||||
# Note: the passphrase is passed to the nativescript CLI and Gradle on their
|
||||
# command lines, so it is briefly visible in `ps` on this machine while the
|
||||
# build runs.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
source scripts/before_build.sh
|
||||
|
||||
KEYSTORE="${ANDROID_KEYSTORE:-$HOME/repositories/AndroidKeystore/jimrandomh-android-keystore.jks}"
|
||||
if [ ! -f "$KEYSTORE" ]; then
|
||||
echo "Keystore not found: $KEYSTORE (set ANDROID_KEYSTORE to override)" >&2
|
||||
if [ ! -f "$ANDROID_KEYSTORE" ]; then
|
||||
echo "Keystore not found: $ANDROID_KEYSTORE (set ANDROID_KEYSTORE in build_paths.sh)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -34,17 +38,17 @@ if [ -z "$VERSION" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -r -s -p "Keystore passphrase for $(basename "$KEYSTORE"): " STORE_PASS
|
||||
read -r -s -p "Keystore passphrase for $(basename "$ANDROID_KEYSTORE"): " STORE_PASS
|
||||
echo
|
||||
|
||||
# Validate the passphrase up front and discover the signing-key alias.
|
||||
if ! LISTING="$(keytool -list -keystore "$KEYSTORE" -storepass "$STORE_PASS" 2>&1)"; then
|
||||
if ! LISTING="$(keytool -list -keystore "$ANDROID_KEYSTORE" -storepass "$STORE_PASS" 2>&1)"; then
|
||||
printf '%s\n' "$LISTING" >&2
|
||||
exit 1
|
||||
fi
|
||||
ALIAS="$(printf '%s\n' "$LISTING" | awk -F', ' '/PrivateKeyEntry/{print $1; exit}')"
|
||||
if [ -z "$ALIAS" ]; then
|
||||
echo "No private-key entry found in $KEYSTORE:" >&2
|
||||
echo "No private-key entry found in $ANDROID_KEYSTORE:" >&2
|
||||
printf '%s\n' "$LISTING" >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -55,19 +59,37 @@ echo
|
||||
KEY_PASS="${KEY_PASS:-$STORE_PASS}"
|
||||
|
||||
OUT="dist/Faceclaw-$VERSION.apk"
|
||||
WEAR_OUT="dist/Faceclaw-Wear-$VERSION.apk"
|
||||
mkdir -p dist
|
||||
rm -f "$OUT"
|
||||
rm -f "$OUT" "$WEAR_OUT"
|
||||
|
||||
echo "=== Building Android app ==="
|
||||
npx nativescript build android --release \
|
||||
--key-store-path "$KEYSTORE" \
|
||||
--key-store-path "$ANDROID_KEYSTORE" \
|
||||
--key-store-password "$STORE_PASS" \
|
||||
--key-store-alias "$ALIAS" \
|
||||
--key-store-alias-password "$KEY_PASS" \
|
||||
--copy-to "$OUT"
|
||||
|
||||
# Wear app: sign with the same key via AGP's injected signing properties, so
|
||||
# no signing config needs to live in the wear build files.
|
||||
echo "=== Building Wear app ==="
|
||||
(cd wear && ./gradlew :app:assembleRelease \
|
||||
-Pandroid.injected.signing.store.file="$ANDROID_KEYSTORE" \
|
||||
-Pandroid.injected.signing.store.password="$STORE_PASS" \
|
||||
-Pandroid.injected.signing.key.alias="$ALIAS" \
|
||||
-Pandroid.injected.signing.key.password="$KEY_PASS")
|
||||
cp wear/app/build/outputs/apk/release/app-release.apk "$WEAR_OUT"
|
||||
|
||||
echo
|
||||
echo "Built $OUT"
|
||||
echo "Built $WEAR_OUT"
|
||||
if [ -n "${ANDROID_HOME:-}" ] && [ -d "$ANDROID_HOME/build-tools" ]; then
|
||||
APKSIGNER="$(printf '%s\n' "$ANDROID_HOME/build-tools"/*/apksigner | sort -V | tail -1)"
|
||||
[ -x "$APKSIGNER" ] && "$APKSIGNER" verify --print-certs "$OUT" | head -5
|
||||
if [ -x "$APKSIGNER" ]; then
|
||||
for apk in "$OUT" "$WEAR_OUT"; do
|
||||
echo "== $apk"
|
||||
"$APKSIGNER" verify --print-certs "$apk" | head -5
|
||||
done
|
||||
fi
|
||||
fi
|
||||
Reference in new issue
Block a user