• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/android"
26
27echo "Creating $OUTDIR..."
28
29mkdir -p $OUTDIR
30
31echo "Compiling kernel..."
32
33"$HOST_TOOLS/dart" \
34  "$HOST_TOOLS/gen/frontend_server.dart.snapshot" \
35  --sdk-root "$HOST_TOOLS/flutter_patched_sdk" \
36  --aot --tfa --target=flutter \
37  --output-dill "$OUTDIR/app.dill" \
38  "${BASH_SOURCE%/*}/lib/main.dart"
39
40echo "Compiling ELF Shared Library..."
41
42"$DEVICE_TOOLS/gen_snapshot" --deterministic --snapshot_kind=app-aot-elf --elf="$OUTDIR/libapp.so" --strip "$OUTDIR/app.dill"
43
44mkdir -p "${BASH_SOURCE%/*}/android/app/src/main/jniLibs/arm64-v8a"
45mkdir -p "${BASH_SOURCE%/*}/android/app/libs"
46cp "$OUTDIR/libapp.so" "${BASH_SOURCE%/*}/android/app/src/main/jniLibs/arm64-v8a/"
47cp "$DEVICE_TOOLS/../flutter.jar" "${BASH_SOURCE%/*}/android/app/libs/"
48
49echo "Created $OUTDIR/libapp.so."
50