SPB Git

Repository Public

build.sh 3.6 KB 54 lines shellscript

1#!/usr/bin/env bash2# VQuant iOS3# File: Scripts/build.sh4# Description: Generate the Xcode project, build, and run the tests (filtered xcodebuild output; full logs in build/logs).5#              usage: build.sh generate | core | debug | release | test | uitest [extra xcodebuild args]6#              VQUANT_SIM selects the simulator (default "VQuant iPhone"; "VQuant iPad" for the tablet runs).7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -uo pipefail11cd "$(dirname "$0")/.."12SIM="${VQUANT_SIM:-VQuant iPhone}"13DD="build/DerivedData"14mkdir -p build/logs build/results15filter() { sed "s|$PWD/||" | grep -E "error:|warning: unre|warning: var|\*\* |Test Suite .* (passed|failed)|Executed [0-9]+ tests|✘|✔ Test run|Testing failed|failed \(|: error|Test run with" | grep -v "^ *|" | sort -u | head -"${LINES_MAX:-70}"; }16simulators() {17  xcrun simctl list devices | grep -q "VQuant iPhone (" || xcrun simctl create "VQuant iPhone" "iPhone 17 Pro" >/dev/null18  xcrun simctl list devices | grep -q "VQuant iPad (" || xcrun simctl create "VQuant iPad" "iPad Pro 13-inch (M5)" >/dev/null19}20case "${1:-debug}" in21  generate)22    # Info-Debug.plist = Info.plist + loopback networking allowed (development copy of the backend through an SSH tunnel)23    cp VQuant/Resources/Info.plist VQuant/Resources/Info-Debug.plist24    /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsLocalNetworking true" VQuant/Resources/Info-Debug.plist25    # VQUANTKIT=<dir> builds against a frozen copy of the shared package (it is edited by other sessions on this Mac26    # and may not compile at every moment); the committed project.yml always points at ../VQuantKit.27    if [ -n "${VQUANTKIT:-}" ]; then28      sed "s|path: ../VQuantKit|path: $VQUANTKIT|" project.yml > build/project-snapshot.yml29      xcodegen generate --quiet --spec build/project-snapshot.yml --project . --project-root . && echo "projet généré (VQuantKit : $VQUANTKIT)"30    else31      xcodegen generate --quiet && echo "projet généré"32    fi ;;33  core)34    swift test 2>&1 | tee build/logs/core.log | sed 's/\x1b\[[0-9;]*m//g' | grep -E "error:|✘|failed|Test run with" | grep -v "^ *|" ;;35  debug)36    simulators37    xcodebuild -project VQuant.xcodeproj -scheme VQuant -configuration Debug -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" build 2>&1 | tee build/logs/debug.log | filter ;;38  release)39    xcodebuild -project VQuant.xcodeproj -scheme VQuant -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath "$DD" CODE_SIGNING_ALLOWED=NO build 2>&1 | tee build/logs/release.log | filter ;;40  test)41    shift || true; simulators42    xcodebuild -project VQuant.xcodeproj -scheme VQuant -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:VQuantTests "$@" test 2>&1 | tee build/logs/test.log | filter ;;43  uitest)44    shift || true; simulators45    R="build/results/uitest-${SIM// /_}.xcresult"; rm -rf "$R"46    xcodebuild -project VQuant.xcodeproj -scheme VQuant -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:VQuantUITests -resultBundlePath "$R" "$@" test 2>&1 | tee "build/logs/uitest-${SIM// /_}.log" | filter47    # a full run replaces the screenshots; a filtered run (extra arguments) goes beside them48    S="build/shots/${SIM// /_}"; [ "$#" -gt 0 ] && S="$S-partial"49    rm -rf "$S"; mkdir -p "$S"50    xcrun xcresulttool export attachments --path "$R" --output-path "$S" >/dev/null 2>&1 || true51    python3 Scripts/name-shots.py "$S" >/dev/null 2>&1 || true ;;52  *) echo "usage: build.sh generate|core|debug|release|test|uitest"; exit 2 ;;53esac54
Files main
Menu

Theme