|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Exit on error |
| 4 | +set -e |
| 5 | + |
| 6 | +thisFilePath=$(dirname "$0") |
| 7 | + |
| 8 | +# Validate SENTRY_DISABLE_NATIVE_START is set |
| 9 | +if [ -z "${SENTRY_DISABLE_NATIVE_START}" ]; then |
| 10 | + echo "Error: SENTRY_DISABLE_NATIVE_START environment variable is not set." |
| 11 | + echo "Usage: SENTRY_DISABLE_NATIVE_START=true|false $0" |
| 12 | + echo "" |
| 13 | + echo " true - Build for auto init from JS (native SDK disabled)" |
| 14 | + echo " false - Build for manual native init (native SDK enabled)" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +# Export so Gradle daemon can access it |
| 19 | +export SENTRY_DISABLE_NATIVE_START |
| 20 | + |
| 21 | +# Map SENTRY_DISABLE_NATIVE_START to build mode |
| 22 | +if [ "${SENTRY_DISABLE_NATIVE_START}" = "true" ]; then |
| 23 | + BUILD_MODE="auto" |
| 24 | + INIT_DESCRIPTION="initialize Sentry from JavaScript (auto init)" |
| 25 | +elif [ "${SENTRY_DISABLE_NATIVE_START}" = "false" ]; then |
| 26 | + BUILD_MODE="manual" |
| 27 | + INIT_DESCRIPTION="initialize Sentry natively before JS (manual init)" |
| 28 | +else |
| 29 | + echo "Error: Invalid value for SENTRY_DISABLE_NATIVE_START: '${SENTRY_DISABLE_NATIVE_START}'" |
| 30 | + echo "Expected 'true' or 'false'" |
| 31 | + exit 1 |
| 32 | +fi |
| 33 | + |
| 34 | +export RN_ARCHITECTURE="new" |
| 35 | +export CONFIG="debug" |
| 36 | + |
| 37 | +echo "Building Android with SENTRY_DISABLE_NATIVE_START=${SENTRY_DISABLE_NATIVE_START}" |
| 38 | +echo "This build will ${INIT_DESCRIPTION}" |
| 39 | + |
| 40 | +"${thisFilePath}/build-android.sh" |
| 41 | + |
| 42 | +# Rename the output APK based on build mode |
| 43 | +cd "${thisFilePath}/.." |
| 44 | +if [ -f "app.apk" ]; then |
| 45 | + mv app.apk "app-${BUILD_MODE}.apk" |
| 46 | + echo "Build complete: app-${BUILD_MODE}.apk" |
| 47 | +else |
| 48 | + echo "Error: Expected output file 'app.apk' not found" |
| 49 | + exit 1 |
| 50 | +fi |
0 commit comments