OLD | NEW |
| (Empty) |
1 #!/bin/bash | |
2 | |
3 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
4 # for details. All rights reserved. Use of this source code is governed by a | |
5 # BSD-style license that can be found in the LICENSE.md file. | |
6 | |
7 # Build steps | |
8 # - Run immic. | |
9 # - Run servicec. | |
10 # - Build dartino library generators for target platforms (here ia32 and arm). | |
11 # - In the servicec java output directory build libdartino using ndk-build. | |
12 # - Copy/link output files from immic and servicec to the jni and java director
ies. | |
13 # - Generate a snapshot of your Dart program and add it to you resources dir. | |
14 | |
15 PROJ=github | |
16 ANDROID_PROJ=GithubSample | |
17 | |
18 set -ue | |
19 | |
20 DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | |
21 | |
22 DARTINO_DIR="$(cd "$DIR/../../.." && pwd)" | |
23 | |
24 # TODO(zerny): Support other modes than Release in tools/android_build/jni/Andro
id.mk | |
25 TARGET_MODE=Release | |
26 TARGET_DIR="$(cd "$DIR/.." && pwd)" | |
27 TARGET_GEN_DIR="$TARGET_DIR/generated" | |
28 TARGET_PKG_FILE="$TARGET_DIR/.packages" | |
29 | |
30 IMMI_GEN_DIR="$TARGET_GEN_DIR/immi" | |
31 SERVICE_GEN_DIR="$TARGET_GEN_DIR/service" | |
32 | |
33 JAVA_DIR=$DIR/$ANDROID_PROJ/app/src/main/java/dartino | |
34 JNI_LIBS_DIR=$DIR/$ANDROID_PROJ/app/src/main/jniLibs | |
35 | |
36 DART="$DARTINO_DIR/out/ReleaseIA32/dart" | |
37 IMMIC="$DART $DARTINO_DIR/tools/immic/bin/immic.dart" | |
38 DARTINO="$DARTINO_DIR/out/ReleaseIA32/dartino" | |
39 SERVICEC="$DARTINO x-servicec" | |
40 | |
41 set -x | |
42 | |
43 (cd $DARTINO_DIR; ninja -C out/ReleaseIA32) | |
44 | |
45 # Generate dart service file and other immi files with the compiler. | |
46 if [[ $# -eq 0 ]] || [[ "$1" == "immi" ]]; then | |
47 rm -rf "$IMMI_GEN_DIR" | |
48 mkdir -p "$IMMI_GEN_DIR" | |
49 $IMMIC --packages "$TARGET_PKG_FILE" --out "$IMMI_GEN_DIR" "$TARGET_DIR/lib/
$PROJ.immi" | |
50 | |
51 rm -rf "$SERVICE_GEN_DIR" | |
52 mkdir -p "$SERVICE_GEN_DIR" | |
53 $SERVICEC file "$IMMI_GEN_DIR/idl/immi_service.idl" out "$SERVICE_GEN_DIR" | |
54 | |
55 # TODO(zerny): Change the servicec output directory structure to allow easy | |
56 # referencing from Android Studio. | |
57 mkdir -p $JAVA_DIR | |
58 cp -R $SERVICE_GEN_DIR/java/dartino/*.java $JAVA_DIR/ | |
59 fi | |
60 | |
61 # Build the native interpreter src for arm and x86. | |
62 if [[ $# -eq 0 ]] || [[ "$1" == "dartino" ]]; then | |
63 cd $DARTINO_DIR | |
64 ninja | |
65 ninja -C out/${TARGET_MODE}XARMAndroid dartino_vm_library_generator | |
66 ninja -C out/${TARGET_MODE}IA32Android dartino_vm_library_generator | |
67 mkdir -p out/${TARGET_MODE}XARMAndroid/obj/src/vm/dartino_vm.gen | |
68 mkdir -p out/${TARGET_MODE}IA32Android/obj/src/vm/dartino_vm.gen | |
69 out/${TARGET_MODE}XARMAndroid/dartino_vm_library_generator > \ | |
70 out/${TARGET_MODE}XARMAndroid/obj/src/vm/dartino_vm.gen/generated.S | |
71 out/${TARGET_MODE}IA32Android/dartino_vm_library_generator > \ | |
72 out/${TARGET_MODE}IA32Android/obj/src/vm/dartino_vm.gen/generated.S | |
73 | |
74 cd $SERVICE_GEN_DIR/java | |
75 CPUCOUNT=1 | |
76 if [[ $(uname) = 'Darwin' ]]; then | |
77 CPUCOUNT=$(sysctl -n hw.logicalcpu_max) | |
78 else | |
79 CPUCOUNT=$(lscpu -p | grep -vc '^#') | |
80 fi | |
81 NDK_MODULE_PATH=. ndk-build -j$CPUCOUNT | |
82 | |
83 mkdir -p $JNI_LIBS_DIR | |
84 cp -R libs/* $JNI_LIBS_DIR/ | |
85 fi | |
86 | |
87 if [[ $# -eq 0 ]] || [[ "$1" == "snapshot" ]]; then | |
88 # Kill the persistent process | |
89 cd $DARTINO_DIR | |
90 | |
91 SNAPSHOT="$DIR/$ANDROID_PROJ/app/src/main/res/raw/${PROJ}_snapshot" | |
92 mkdir -p `dirname "$SNAPSHOT"` | |
93 $DART -c --packages=.packages \ | |
94 -Dsnapshot="$SNAPSHOT" \ | |
95 -Dpackages="$TARGET_PKG_FILE" \ | |
96 tests/dartino_compiler/run.dart "$TARGET_DIR/bin/$PROJ.dart" | |
97 fi | |
98 | |
99 set +x | |
100 | |
101 if [[ $# -eq 1 ]]; then | |
102 echo | |
103 echo "Only ran task $1." | |
104 echo "Possible tasks: immi, dartino, and snapshot" | |
105 echo "If Dartino or any IMMI files changed re-run compile.sh without argumen
ts." | |
106 fi | |
OLD | NEW |