Add low-output tooling mode

This commit is contained in:
Joe Tretter
2026-06-26 16:24:45 -05:00
parent 91913a9de8
commit 4b94173ae5
6 changed files with 224 additions and 207 deletions

View File

@@ -37,11 +37,66 @@ ANDROID_CMAKE_DIR="$SDK_DIR/cmake/3.22.1"
ANDROID_TOOLBIN="$ANDROID_NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64/bin"
STATE_TTL_SECONDS=86400
HIDE_EMULATOR_WINDOW="false"
QUIET_LOG_DIR="$PROJECT_DIR/build/reports/android-project-tooling"
log() {
printf '\n[%s] %s\n' "tooling" "$1"
}
quiet_log_name() {
local mode="setup"
local arg
for arg in "$@"; do
case "$arg" in
--build|--build-release-aab|--test|--clean-test|--test-emulator|--compile-git)
mode="${arg#--}"
;;
esac
done
printf '%s-%s.log\n' "$(date +%Y%m%d-%H%M%S)" "$mode"
}
run_quiet_if_requested() {
if [ "${ANDROID_PROJECT_TOOLING_QUIET_CHILD:-}" = "1" ]; then
return
fi
local quiet="false"
local filtered_args=()
local arg
for arg in "$@"; do
if [ "$arg" = "--quiet" ]; then
quiet="true"
else
filtered_args+=("$arg")
fi
done
if [ "$quiet" != "true" ]; then
return
fi
mkdir -p "$QUIET_LOG_DIR"
local log_file="$QUIET_LOG_DIR/$(quiet_log_name "${filtered_args[@]}")"
printf '[tooling] Running quietly; full log: %s\n' "${log_file#$PROJECT_DIR/}"
set +e
ANDROID_PROJECT_TOOLING_QUIET_CHILD=1 bash "$0" "${filtered_args[@]}" >"$log_file" 2>&1 &
local child_pid=$!
wait "$child_pid"
local status=$?
set -e
if [ "$status" -eq 0 ]; then
printf '[tooling] Completed successfully; full log: %s\n' "${log_file#$PROJECT_DIR/}"
else
printf '[tooling] Failed with exit code %s; full log: %s\n' "$status" "${log_file#$PROJECT_DIR/}" >&2
printf '[tooling] Last 120 log lines:\n' >&2
tail -n 120 "$log_file" >&2 || true
fi
exit "$status"
}
require_tool() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "Missing required tool: $1" >&2
@@ -795,7 +850,7 @@ maybe_run_operation() {
print_usage() {
cat <<EOF_USAGE
Usage: bash ./AndroidProjectTooling.sh [--build | --build-release-aab | --test | --clean-test | --test-emulator [--hide-emulator-window] | --compile-git]
Usage: bash ./AndroidProjectTooling.sh [--quiet] [--build | --build-release-aab | --test | --clean-test | --test-emulator [--hide-emulator-window] | --compile-git]
--build Set up the environment and build the debug APK
--build-release-aab Set up the environment and build a release Android App Bundle (AAB)
@@ -804,11 +859,16 @@ Usage: bash ./AndroidProjectTooling.sh [--build | --build-release-aab | --test |
--test-emulator Set up a visible Android emulator and run debug instrumentation tests on it
--hide-emulator-window Run --test-emulator with the emulator window hidden
--compile-git Compile Git for the development host and all Android target ABIs
--quiet Write full output to build/reports/android-project-tooling/ and print only a concise result
EOF_USAGE
}
validate_args() {
local mode="${1:-}"
if [ "$mode" = "--quiet" ]; then
mode="${2:-}"
shift || true
fi
shift || true
case "$mode" in
@@ -823,6 +883,8 @@ validate_args() {
while [ "$#" -gt 0 ]; do
case "$1" in
--quiet)
;;
--hide-emulator-window)
if [ "$mode" != "--test-emulator" ]; then
echo "--hide-emulator-window can only be used with --test-emulator" >&2
@@ -842,6 +904,7 @@ validate_args() {
}
main() {
run_quiet_if_requested "$@"
validate_args "$@"
require_tool curl