forked from momodalo/vimtouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·77 lines (66 loc) · 1.9 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
NDK=$ANDROID_NDK_ROOT
SDK=`grep sdk.dir local.properties | tr '=' '\n' | tail -1`
package="net.momodalo.app.vimtouch"
if ! [ -f $NDK/ndk-build ] ; then
# If ANDROID_NDK_ROOT is not set, try this heuristics: look up all the
# siblings of SDK that start with 'android-ndk*', sort them by revision and
# pick the latest one
parent=$(dirname $SDK)
all_ndks=`find $parent -maxdepth 1 -type d -name android-ndk* -printf '%f\n'`
latest_ndk=`echo $all_ndks | tr ' ' '\n' | sort -t'r' -k3n | tail -1`
NDK=$(dirname $SDK)/$latest_ndk
# If still nothing, well, then bark and quit
if ! [ -f $NDK/ndk-build ] ; then
echo Android NDK not found. Please export ANDROID_NDK_ROOT. Exiting.
exit
fi
fi
function build {
set -e
ant debug
ant installd
$SDK/platform-tools/adb shell am start -n $package/.VimTouch
}
function build_native {
set -e
gen_signatures
$NDK/ndk-build -j`grep -c ^processor /proc/cpuinfo`
}
function gen_signatures {
signatures="./gen/signatures.h"
echo "#ifndef SIGNATURES_H__" > $signatures
echo "#define SIGNATURES_H__" >> $signatures
echo "" >> $signatures
class="./bin/classes/`echo $package | tr '.' '/'`/Exec"
javap -s $class \
| awk '/native/,/Signature/{ print };' \
| awk '/Signature/{ print "\011\042"$2"\042;\n"; next }{ split($5,a1,/\(/); print "char const* jni_signature_"a1[1]" = " };' \
>> $signatures
echo "#endif // SIGNATURES_H__" >> $signatures
}
if [ $# -eq 0 ] ; then
build
exit
fi
if [ $1 == "lint" ] ; then
$SDK/tools/lint .
fi
case $1 in
"lint")
$SDK/tools/lint .
;;
"rm")
$SDK/platform-tools/adb uninstall $package
;;
"log")
$SDK/platform-tools/adb logcat
;;
"adb")
shift
$SDK/platform-tools/adb $*
;;
"buildnative")
build_native
;;
esac