Cotton code
30 lines · 1.9 KB · ShellRaw
#!/usr/bin/env bash# Android CI entrypoint. The workflow supplies a real SDK/NDK; fail before a costly build if it drifted.set -euo pipefailexport PATH="$HOME/.cargo/bin:$PATH": "${ANDROID_HOME:?ANDROID_HOME must name the Android SDK}": "${ANDROID_NDK_HOME:?ANDROID_NDK_HOME must name the Android NDK}"[ -d "$ANDROID_HOME/platforms/android-36" ] || { echo "Android API 36 is missing from $ANDROID_HOME" >&2; exit 1; }[ -x "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" ] || { echo "Android NDK is incomplete at $ANDROID_NDK_HOME" >&2; exit 1; }command -v cargo-ndk >/dev/null || { echo "cargo-ndk is required on the Android runner" >&2; exit 1; }# assembleDebug validates every ABI in the shipping APK, so build all four before# Gradle packages it. The host build prints the native library path as its last# line; use its directory for the JVM smoke-test seam.bash scripts/build-android-core.shhost_library="$(bash scripts/build-android-core.sh --host | tail -n 1)"[ -f "$host_library" ] || { echo "Host JNI library was not produced: $host_library" >&2; exit 1; }host_dir="$(dirname "$host_library")"# Inside a build slot shared with other jobs, Gradle's workers are the slot's# share of the host (`scripts/ci/build-slot.sh`, THE SHARE); alone, or outside# a slot, gradle.properties' 6 is the ceiling.gradle_workers=()case "${COTTON_BUILD_SLOT_THREADS:-}" in  ''|*[!0-9]*) ;;  *) gradle_workers=(--max-workers="$COTTON_BUILD_SLOT_THREADS") ;;esac# The instrumented tests need a device CI does not have, so they do not RUN# here — but they are compiled, or a reshaped read breaks them unseen.BUILD_LOCK_LABEL=ci-android bash scripts/with-build-lock.sh ./apps/cotton-android/gradlew -p apps/cotton-android ${gradle_workers[@]+"${gradle_workers[@]}"} \  :core:test :core:nativeSmoke -Pcotton.nativeLibraryDir="$host_dir" :app:assembleDebug :app:lintDebug \  :app:compileDebugAndroidTestKotlin