|
| 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 | + |
| 8 | +set -e |
| 9 | + |
| 10 | +HOST_TOOLS=$1 |
| 11 | +DEVICE_TOOLS=$2 |
| 12 | + |
| 13 | +if [[ ! -d "$HOST_TOOLS" ]]; then |
| 14 | + echo "Must specify the host out directory containing dart." |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +if [[ ! -d "$DEVICE_TOOLS" ]]; then |
| 19 | + echo "Must specify the device out directory containing gen_snapshot." |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +echo "Using dart from $HOST_TOOLS, gen_snapshot from $DEVICE_TOOLS." |
| 24 | + |
| 25 | +OUTDIR="${BASH_SOURCE%/*}/build/ios" |
| 26 | + |
| 27 | +echo "Creating $OUTDIR..." |
| 28 | + |
| 29 | +mkdir -p "$OUTDIR" |
| 30 | +mkdir -p "$OUTDIR/App.framework/flutter_assets" |
| 31 | + |
| 32 | +echo "Compiling to kernel..." |
| 33 | + |
| 34 | +"$HOST_TOOLS/dart" \ |
| 35 | + "$HOST_TOOLS/gen/frontend_server.dart.snapshot" \ |
| 36 | + --sdk-root "$HOST_TOOLS/flutter_patched_sdk" \ |
| 37 | + --strong --target=flutter \ |
| 38 | + --no-link-platform \ |
| 39 | + --output-dill "$OUTDIR/App.framework/flutter_assets/kernel_blob.bin" \ |
| 40 | + "${BASH_SOURCE%/*}/lib/main.dart" |
| 41 | + |
| 42 | +echo "Compiling JIT Snapshot..." |
| 43 | + |
| 44 | +"$DEVICE_TOOLS/gen_snapshot" --deterministic \ |
| 45 | + --enable-asserts \ |
| 46 | + --causal_async_stacks \ |
| 47 | + --isolate_snapshot_instructions="$OUTDIR/isolate_snapshot_instr" \ |
| 48 | + --snapshot_kind=app-jit \ |
| 49 | + --load_vm_snapshot_data="$DEVICE_TOOLS/../gen/flutter/lib/snapshot/vm_isolate_snapshot.bin" \ |
| 50 | + --load_isolate_snapshot_data="$DEVICE_TOOLS/../gen/flutter/lib/snapshot/isolate_snapshot.bin" \ |
| 51 | + --isolate_snapshot_data="$OUTDIR/App.framework/flutter_assets/isolate_snapshot_data" \ |
| 52 | + --isolate_snapshot_instructions="$OUTDIR/App.framework/flutter_assets/isolate_snapshot_instr" \ |
| 53 | + "$OUTDIR/App.framework/flutter_assets/kernel_blob.bin" |
| 54 | + |
| 55 | +cp "$DEVICE_TOOLS/../gen/flutter/lib/snapshot/vm_isolate_snapshot.bin" "$OUTDIR/App.framework/flutter_assets/vm_snapshot_data" |
| 56 | + |
| 57 | +SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path) |
| 58 | +echo "Using $SYSROOT as sysroot." |
| 59 | + |
| 60 | +echo "Creating stub App using $SYSROOT..." |
| 61 | + |
| 62 | +echo "static const int Moo = 88;" | xcrun clang -x c \ |
| 63 | + -arch x86_64 \ |
| 64 | + -isysroot "$SYSROOT" \ |
| 65 | + -miphoneos-version-min=8.0 \ |
| 66 | + -dynamiclib \ |
| 67 | + -Xlinker -rpath -Xlinker '@executable_path/Frameworks' \ |
| 68 | + -Xlinker -rpath -Xlinker '@loader_path/Frameworks' \ |
| 69 | + -install_name '@rpath/App.framework/App' \ |
| 70 | + -o "$OUTDIR/App.framework/App" - |
| 71 | + |
| 72 | +strip "$OUTDIR/App.framework/App" |
| 73 | + |
| 74 | +cp "${BASH_SOURCE%/*}/ios/AppFrameworkInfo.plist" "$OUTDIR/App.framework/Info.plist" |
| 75 | +echo "Created $OUTDIR/App.framework/App." |
| 76 | + |
| 77 | +rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/App.framework" |
| 78 | +rm -rf "${BASH_SOURCE%/*}/ios/Scenarios/Flutter.framework" |
| 79 | +cp -R "$OUTDIR/App.framework" "${BASH_SOURCE%/*}/ios/Scenarios" |
| 80 | +cp -R "$DEVICE_TOOLS/../Flutter.framework" "${BASH_SOURCE%/*}/ios/Scenarios" |
| 81 | + |
0 commit comments