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 servicec. | |
9 # - Build dartino library generators for target platforms (here ia32 and arm). | |
10 # - In the servicec java output directory build libdartino using ndk-build. | |
11 # - Copy/link output files servicec to the jni and java directories. | |
12 # - Generate a snapshot of your Dart program and add it to you resources dir. | |
13 | |
14 PROJ=github | |
15 ANDROID_PROJ=GithubMock | |
16 DART_FILE=bin/github_mock_service.dart | |
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 SERVICE_GEN_DIR="$TARGET_GEN_DIR/service" | |
31 | |
32 JAVA_DIR=$DIR/$ANDROID_PROJ/app/src/main/java/dartino | |
33 JNI_LIBS_DIR=$DIR/$ANDROID_PROJ/app/src/main/jniLibs | |
34 | |
35 MOCK_SERVER_SNAPSHOT="$TARGET_DIR/github_mock_service.snapshot" | |
36 | |
37 set -x | |
38 | |
39 # Compile dart service file. | |
40 if [[ $# -eq 0 ]] || [[ "$1" == "service" ]]; then | |
41 rm -rf "$SERVICE_GEN_DIR" | |
42 $DIR/../compile_mock_service.sh service | |
43 | |
44 # TODO(zerny): Change the servicec output directory structure to allow easy | |
45 # referencing from Android Studio. | |
46 mkdir -p $JAVA_DIR | |
47 cp -R $SERVICE_GEN_DIR/java/dartino/*.java $JAVA_DIR/ | |
48 fi | |
49 | |
50 # Build the native interpreter src for arm and x86. | |
51 if [[ $# -eq 0 ]] || [[ "$1" == "dartino" ]]; then | |
52 cd $DARTINO_DIR | |
53 ninja | |
54 ninja -C out/${TARGET_MODE}XARMAndroid dartino_vm_library_generator | |
55 ninja -C out/${TARGET_MODE}IA32Android dartino_vm_library_generator | |
56 mkdir -p out/${TARGET_MODE}XARMAndroid/obj/src/vm/dartino_vm.gen | |
57 mkdir -p out/${TARGET_MODE}IA32Android/obj/src/vm/dartino_vm.gen | |
58 out/${TARGET_MODE}XARMAndroid/dartino_vm_library_generator > \ | |
59 out/${TARGET_MODE}XARMAndroid/obj/src/vm/dartino_vm.gen/generated.S | |
60 out/${TARGET_MODE}IA32Android/dartino_vm_library_generator > \ | |
61 out/${TARGET_MODE}IA32Android/obj/src/vm/dartino_vm.gen/generated.S | |
62 | |
63 cd $SERVICE_GEN_DIR/java | |
64 CPUCOUNT=1 | |
65 if [[ $(uname) = 'Darwin' ]]; then | |
66 CPUCOUNT=$(sysctl -n hw.logicalcpu_max) | |
67 else | |
68 CPUCOUNT=$(lscpu -p | grep -vc '^#') | |
69 fi | |
70 NDK_MODULE_PATH=. ndk-build -j$CPUCOUNT | |
71 | |
72 mkdir -p $JNI_LIBS_DIR | |
73 cp -R libs/* $JNI_LIBS_DIR/ | |
74 fi | |
75 | |
76 # TODO(zerny): should this always recompile the mock data and snapshot? | |
77 if [[ $# -eq 0 ]] && [[ ! -f "$MOCK_SERVER_SNAPSHOT" ]]; then | |
78 $DIR/../compile_mock_service.sh | |
79 fi | |
80 | |
81 if [[ $# -eq 0 ]] || [[ "$1" == "snapshot" ]]; then | |
82 SNAPSHOT="$DIR/$ANDROID_PROJ/app/src/main/res/raw/snapshot" | |
83 mkdir -p `dirname "$SNAPSHOT"` | |
84 cp "$MOCK_SERVER_SNAPSHOT" "$SNAPSHOT" | |
85 fi | |
86 | |
87 set +x | |
88 | |
89 if [[ $# -eq 1 ]]; then | |
90 echo | |
91 echo "Only ran task $1." | |
92 echo "Possible tasks: service, dartino, and snapshot" | |
93 echo "If Dartino or any IMMI files changed re-run compile.sh without argumen
ts." | |
94 fi | |
OLD | NEW |