SPB Git

Repository Public BSD-3-Clause

build.sh 4.6 KB 101 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : ORIX Maps8# File             : scripts/build.sh9# Module           : scripts10# Repository       : https://git.spboucher.ai/orix-maps11# Created          : 2026-11-2512# Last Modified    : 2026-11-2513#14# Author           : Simon-Pierre Boucher15# Position         : Professor of Finance16# Institution      : Université du Québec en Outaouais (UQO)17# Organization     : SP Boucher18# Website          : https://spboucher.ai19# Git              : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin   : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License          : Proprietary, all rights reserved (see license file)32# License File     : LICENSE33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# ORIX Maps — build helper.42# usage: scripts/build.sh generate | packages | debug | release | test | uitest | run [launch arguments…] | shot <file.png>43# ORIX_SIM selects the simulator (default "ORIXMaps iPhone", created on first use).44set -euo pipefail45ROOT="$(cd "$(dirname "$0")/.." && pwd)"46APP="$ROOT/Apps/ORIXMaps"47SIM="${ORIX_SIM:-ORIXMaps iPhone}"48SIM_TYPE="${ORIX_SIM_TYPE:-iPhone 17 Pro}"49DD="$ROOT/build/DerivedData"50mkdir -p "$ROOT/build/logs"5152sim_id() {53  local id54  id=$(xcrun simctl list devices available | grep -F "$SIM (" | head -1 | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/')55  if [ -z "$id" ]; then id=$(xcrun simctl create "$SIM" "$SIM_TYPE"); fi56  echo "$id"57}58boot() {59  local id; id=$(sim_id)60  xcrun simctl bootstatus "$id" -b >/dev/null 2>&1 || true61  echo "$id"62}63xb() { # xb <configuration> <log name> <action…>64  local config="$1" log="$ROOT/build/logs/$2.log"; shift 265  (cd "$APP" && xcodegen generate --quiet && xcodebuild -project ORIXMaps.xcodeproj -scheme ORIXMaps -configuration "$config" \66      -destination "platform=iOS Simulator,id=$(sim_id)" -derivedDataPath "$DD" -skipPackagePluginValidation "$@") > "$log" 2>&1 \67    || { grep -E "error:|\*\* .* FAILED|✘|failed" "$log" | sort -u | head -40; return 1; }68}6970case "${1:?usage: build.sh generate|packages|debug|release|test|uitest|run|shot}" in71generate) (cd "$APP" && xcodegen generate --quiet) ;;72packages)73  for p in "$ROOT"/Packages/*/ "$ROOT"/Infrastructure/*/ "$ROOT"/Infrastructure/ingestion/*/; do74    [ -f "$p/Package.swift" ] || continue75    printf "%-28s " "$(basename "$p")"76    (cd "$p" && swift test 2>&1 | grep -E "Test run with|error:" | tail -1)77  done ;;78debug) xb Debug build-debug build; echo "Debug build succeeded" ;;79release) xb Release build-release build; echo "Release build succeeded" ;;80test) xb Debug test test -only-testing:ORIXMapsTests; grep -E "Test run with|Executed [0-9]+ tests" "$ROOT/build/logs/test.log" | tail -2 ;;81uitest)82  # scripts/build.sh uitest [xcodebuild test options, e.g. -only-testing:ORIXMapsUITests/SearchTests/testSearchByName]83  # Runs the UI tests on the simulator, one at a time. scripts/uitest.sh prepares the servers, permissions and position.84  boot >/dev/null85  selection=(-only-testing:ORIXMapsUITests)86  for a in "${@:2}"; do case "$a" in -only-testing:*) selection=() ;; esac; done87  result="$ROOT/build/results/${ORIX_RESULT_NAME:-uitest}.xcresult"; mkdir -p "$ROOT/build/results"; rm -rf "$result"88  status=089  xb Debug "${ORIX_RESULT_NAME:-uitest}" test ${selection[@]+"${selection[@]}"} -parallel-testing-enabled NO -resultBundlePath "$result" "${@:2}" || status=$?90  log="$ROOT/build/logs/${ORIX_RESULT_NAME:-uitest}.log"91  count() { grep -c "^Test Case .* $1 (" "$log" || true; }92  echo "UI tests: $(count passed) passed, $(count failed) failed, $(count skipped) skipped"93  exit $status ;;94run)95  id=$(boot)96  xcrun simctl install "$id" "$DD/Build/Products/Debug-iphonesimulator/ORIXMaps.app"97  xcrun simctl launch --terminate-running-process "$id" ai.spboucher.orix.maps "${@:2}" ;;98shot) xcrun simctl io "$(boot)" screenshot "${2:?file}" >/dev/null 2>&1 && echo "$2" ;;99*) echo "unknown step: $1"; exit 2 ;;100esac101
Files main
Menu

Theme