xref: /aosp_15_r20/external/executorch/build/build_apple_llm_demo.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1#!/bin/bash
2# Copyright (c) Meta Platforms, Inc. and affiliates.
3# All rights reserved.
4#
5# This source code is licensed under the BSD-style license found in the
6# LICENSE file in the root directory of this source tree.
7
8set -euo pipefail
9
10ARTIFACTS_DIR_NAME="$1"
11APP_PATH="extension/benchmark/apple/Benchmark/Benchmark"
12
13xcodebuild build-for-testing \
14  -project "${APP_PATH}.xcodeproj" \
15  -scheme Benchmark \
16  -destination "platform=iOS" \
17  -sdk iphoneos \
18  -allowProvisioningUpdates \
19  DEVELOPMENT_TEAM=78E7V7QP35 \
20  CODE_SIGN_STYLE=Manual \
21  PROVISIONING_PROFILE_SPECIFIER="ExecuTorch Benchmark" \
22  CODE_SIGN_IDENTITY="iPhone Distribution" \
23  CODE_SIGNING_REQUIRED=No \
24  CODE_SIGNING_ALLOWED=No
25
26# The hack to figure out where the xctest package locates
27BUILD_DIR=$(xcodebuild -showBuildSettings -project "$APP_PATH.xcodeproj" -json | jq -r ".[0].buildSettings.BUILD_DIR")
28
29# Prepare the demo app, debug mode here is the default from xcodebuild and match
30# with what we have in the test spec
31MODE="Release"
32PLATFORM="iphoneos"
33pushd "${BUILD_DIR}/${MODE}-${PLATFORM}"
34
35rm -rf Payload && mkdir Payload
36APP_NAME=Benchmark
37
38ls -lah
39cp -r "${APP_NAME}.app" Payload && zip -vr "${APP_NAME}.ipa" Payload
40
41popd
42
43# Prepare the test suite
44pushd "${BUILD_DIR}"
45
46ls -lah
47zip -vr "${APP_NAME}.xctestrun.zip" *.xctestrun
48
49popd
50
51if [[ -n "${ARTIFACTS_DIR_NAME}" ]]; then
52  mkdir -p "${ARTIFACTS_DIR_NAME}"
53  # Prepare all the artifacts to upload
54  cp "${BUILD_DIR}/${MODE}-${PLATFORM}/${APP_NAME}.ipa" "${ARTIFACTS_DIR_NAME}/"
55  cp "${BUILD_DIR}/${APP_NAME}.xctestrun.zip" "${ARTIFACTS_DIR_NAME}/"
56
57  ls -lah "${ARTIFACTS_DIR_NAME}/"
58fi
59