diff --git a/.circleci/config.yml b/.circleci/config.yml index 511896a994..55e48c78e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -586,7 +586,7 @@ jobs: - v2-cargo-cache-{{arch}}-{{checksum "buildtype.txt"}}-{{checksum "Cargo.lock"}} - run: name: Run iOS build - command: bash bin/run-ios-build.sh + command: make build-swift - save_cache: paths: - /Users/distiller/.cargo/registry @@ -598,14 +598,14 @@ jobs: if git log -1 "$CIRCLE_SHA1" | grep -q '\[doc only\]'; then echo "Skipping this step. Last commit was tagged to not require tests." else - bash bin/run-ios-tests.sh + make test-swift fi - run: name: Generate Swift documentation command: | # Skip doc generation for pull requests. if [ "$CIRCLE_BRANCH" = "main" ]; then - bash bin/build-swift-docs.sh + make docs-swift else mkdir -p build/docs/swift fi @@ -666,14 +666,14 @@ jobs: - run: name: Build sample app command: | - bash bin/run-ios-sample-app-build.sh + bin/iosbuild build sample - store_artifacts: path: raw_sample_xcodebuild.log destination: raw_sample_xcodebuild.log - run: name: Run sample app tests command: | - bash bin/run-ios-sample-app-test.sh + bin/iosbuild test sample - store_artifacts: path: raw_sample_xcodetest.log destination: raw_sample_xcodetest.log diff --git a/Makefile b/Makefile index 386ab200e4..b92dd33a96 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ build-kotlin: ## Build all Kotlin code ./gradlew build -x test build-swift: ## Build all Swift code - bin/run-ios-build.sh + bin/iosbuild build sdk build-apk: build-kotlin ## Build an apk of the Glean sample app ./gradlew glean-sample-app:build glean-sample-app:assembleAndroidTest @@ -83,13 +83,13 @@ test-kotlin: ## Run all Kotlin tests ./gradlew :glean:testDebugUnitTest test-swift: ## Run all Swift tests - bin/run-ios-tests.sh + bin/iosbuild test sdk test-android-sample: build-apk ## Run the Android UI tests on the sample app ./gradlew :glean-sample-app:connectedAndroidTest test-ios-sample: ## Run the iOS UI tests on the sample app - bin/run-ios-sample-app-test.sh + bin/iosbuild test sample test-python: build-python ## Run all Python tests $(GLEAN_PYENV)/bin/py.test -v glean-core/python/tests $(PYTEST_ARGS) @@ -147,7 +147,7 @@ docs-rust: ## Build the Rust documentation bin/build-rust-docs.sh docs-swift: ## Build the Swift documentation - bin/build-swift-docs.sh + bin/iosbuild build docs docs-python: build-python ## Build the Python documentation $(GLEAN_PYENV)/bin/python3 -m pdoc --html glean --force -o build/docs/python --config show_type_annotations=True diff --git a/bin/build-swift-docs.sh b/bin/build-swift-docs.sh deleted file mode 100755 index b230707999..0000000000 --- a/bin/build-swift-docs.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -set -eo pipefail - -# Build Swift with one command -# Requires jazzy from https://github.com/realm/jazzy - -WORKSPACE_ROOT="$( cd "$(dirname "$0")/.." ; pwd -P )" -cd "$WORKSPACE_ROOT" - -jazzy --version -jazzy \ - --clean \ - --config "$WORKSPACE_ROOT/.circleci/jazzy.yml" \ - --output "$WORKSPACE_ROOT/build/docs/swift" diff --git a/bin/iosbuild b/bin/iosbuild new file mode 100755 index 0000000000..b6caee3626 --- /dev/null +++ b/bin/iosbuild @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SDK_WORKSPACE="./glean-core/ios/Glean.xcodeproj/project.xcworkspace" +SDK_SCHEME="Glean" + +SAMPLE_WORKSPACE="./samples/ios/app/glean-sample-app.xcodeproj/project.xcworkspace" +SAMPLE_SCHEME="glean-sample-app" + +DESTINATION="platform=iOS Simulator,name=iPhone 17" + +cmd="${1:-}" +target="${2:-sdk}" + +function help() { + echo "Usage: bin/iosbuild cmd [target]" + echo + echo "Commands: build test update-xcode" + echo "Targets: sdk sample xcframework" +} + +function xbuild() { + local workspace="$1" + local scheme="$2" + local cmd="$3" + local tee_file="$4" + + set -euvx + set -o pipefail && \ + xcodebuild \ + -workspace "$workspace" \ + -scheme "$scheme" \ + -sdk iphonesimulator \ + -destination "$DESTINATION" \ + "$cmd" | \ + tee "$tee_file" | \ + xcpretty && exit "${PIPESTATUS[0]}" +} + +if [[ -z "$cmd" ]]; then + help + exit 2 +fi + +WORKSPACE_ROOT="$( cd "$(dirname "$0")/.." ; pwd -P )" +cd "$WORKSPACE_ROOT" + +case "${cmd}-${target}" in + "build-sdk") + xbuild "$SDK_WORKSPACE" "$SDK_SCHEME" build "raw_xcodebuild.log" + ;; + "test-sdk") + xbuild "$SDK_WORKSPACE" "$SDK_SCHEME" test "raw_xcodetest.log" + ;; + "build-sample") + xbuild "$SAMPLE_WORKSPACE" "$SAMPLE_SCHEME" build "raw_sample_xcodebuild.log" + ;; + "test-sample") + xbuild "$SAMPLE_WORKSPACE" "$SAMPLE_SCHEME" test "raw_sample_xcodetest.log" + ;; + "build-xcframework") + ./bin/build-xcframework.sh + ;; + "build-docs") + set -eo pipefail + + # Requires jazzy from https://github.com/realm/jazzy + jazzy --version + jazzy \ + --clean \ + --config "$WORKSPACE_ROOT/.circleci/jazzy.yml" \ + --output "$WORKSPACE_ROOT/build/docs/swift" + ;; + update-xcode-*) + ./bin/update-xcode-version.sh "$target" + ;; + *) + echo "Unknown cmd/target combination." + echo + help + exit 2 + ;; +esac diff --git a/bin/run-ios-build.sh b/bin/run-ios-build.sh deleted file mode 100755 index d8bfa0f867..0000000000 --- a/bin/run-ios-build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -set -euvx - -set -o pipefail && \ -xcodebuild \ - -workspace ./glean-core/ios/Glean.xcodeproj/project.xcworkspace \ - -scheme Glean \ - -sdk iphonesimulator \ - -destination 'platform=iOS Simulator,name=iPhone 17' \ - build | \ -tee raw_xcodebuild.log | \ -xcpretty && exit "${PIPESTATUS[0]}" diff --git a/bin/run-ios-sample-app-build.sh b/bin/run-ios-sample-app-build.sh deleted file mode 100755 index 8d7e9a989f..0000000000 --- a/bin/run-ios-sample-app-build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -set -euvx - -set -o pipefail && \ -xcodebuild \ - -workspace ./samples/ios/app/glean-sample-app.xcodeproj/project.xcworkspace \ - -scheme glean-sample-app \ - -sdk iphonesimulator \ - -destination 'platform=iOS Simulator,name=iPhone 17' \ - build | \ -tee raw_sample_xcodebuild.log | \ -xcpretty && exit "${PIPESTATUS[0]}" diff --git a/bin/run-ios-sample-app-test.sh b/bin/run-ios-sample-app-test.sh deleted file mode 100755 index a7e7ebfa03..0000000000 --- a/bin/run-ios-sample-app-test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -set -euvx - -set -o pipefail && \ -xcodebuild \ - -workspace ./samples/ios/app/glean-sample-app.xcodeproj/project.xcworkspace \ - -scheme glean-sample-app \ - -sdk iphonesimulator \ - -destination 'platform=iOS Simulator,name=iPhone 17' \ - test | \ -tee raw_sample_xcodetest.log | \ -xcpretty && exit "${PIPESTATUS[0]}" diff --git a/bin/run-ios-tests.sh b/bin/run-ios-tests.sh deleted file mode 100755 index 19e5704214..0000000000 --- a/bin/run-ios-tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -set -euvx - -set -o pipefail && \ -xcodebuild \ - -workspace ./glean-core/ios/Glean.xcodeproj/project.xcworkspace \ - -scheme Glean \ - -sdk iphonesimulator \ - -destination 'platform=iOS Simulator,name=iPhone 17' \ - test | \ -tee raw_xcodetest.log | \ -xcpretty && exit "${PIPESTATUS[0]}" diff --git a/bin/rust-wrapper-hack.sh b/bin/rust-wrapper-hack.sh deleted file mode 100755 index ed0b9a3371..0000000000 --- a/bin/rust-wrapper-hack.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# A hack to not do anything when targetting darwin (macOS), -# but still correctly build everything else. -# Only to be used on Linux hosts. - -unset RUSTC -if echo "$*" | grep -q "print=cfg"; then - rustc $* -elif echo "$*" | grep -q "target x86_64-apple-darwin"; then - true -else - rustc $* -fi