1#!/bin/bash 2# Copyright 2013 The Flutter Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6#TODO(dnfield): Get rid of this script and instead use proper build rules 7 8set -e 9 10HOST_TOOLS=$1 11DEVICE_TOOLS=$2 12 13if [[ ! -d "$HOST_TOOLS" ]]; then 14 echo "Must specify the host out directory containing dart." 15 exit 1 16fi 17 18if [[ ! -d "$DEVICE_TOOLS" ]]; then 19 echo "Must specify the device out directory containing gen_snapshot." 20 exit 1 21fi 22 23echo "Using dart from $HOST_TOOLS, gen_snapshot from $DEVICE_TOOLS." 24 25OUTDIR="${BASH_SOURCE%/*}/build/ios" 26 27echo "Creating $OUTDIR..." 28 29mkdir -p $OUTDIR 30mkdir -p "$OUTDIR/App.framework" 31 32echo "Compiling kernel..." 33 34"$HOST_TOOLS/dart" \ 35 "$HOST_TOOLS/gen/frontend_server.dart.snapshot" \ 36 --sdk-root "$HOST_TOOLS/flutter_patched_sdk" \ 37 --aot --tfa --target=flutter \ 38 --output-dill "$OUTDIR/app.dill" \ 39 "${BASH_SOURCE%/*}/lib/main.dart" 40 41echo "Compiling AOT Assembly..." 42 43"$DEVICE_TOOLS/gen_snapshot" --deterministic --snapshot_kind=app-aot-assembly --assembly=$OUTDIR/snapshot_assembly.S $OUTDIR/app.dill 44 45SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path) 46echo "Using $SYSROOT as sysroot." 47echo "Compiling Assembly..." 48 49cc -arch arm64 \ 50 -isysroot "$SYSROOT" \ 51 -miphoneos-version-min=8.0 \ 52 -c "$OUTDIR/snapshot_assembly.S" \ 53 -o "$OUTDIR/snapshot_assembly.o" 54 55echo "Linking App using $SYSROOT..." 56 57clang -arch arm64 \ 58 -isysroot "$SYSROOT" \ 59 -miphoneos-version-min=8.0 \ 60 -dynamiclib -Xlinker -rpath -Xlinker @executable_path/Frameworks \ 61 -Xlinker -rpath -Xlinker @loader_path/Frameworks \ 62 -install_name @rpath/App.framework/App \ 63 -o "$OUTDIR/App.framework/App" \ 64 "$OUTDIR/snapshot_assembly.o" 65 66strip "$OUTDIR/App.framework/App" 67 68cp "${BASH_SOURCE%/*}/ios/AppFrameworkInfo.plist" "$OUTDIR/App.framework/Info.plist" 69 70echo "Created $OUTDIR/App.framework/App." 71 72rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/App.framework" 73rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/Flutter.framework" 74cp -R "$OUTDIR/App.framework" "${BASH_SOURCE%/*}/ios/Scenarios" 75cp -R "$DEVICE_TOOLS/../Flutter.framework" "${BASH_SOURCE%/*}/ios/Scenarios" 76 77