forked from play-co/native-android
-
Notifications
You must be signed in to change notification settings - Fork 3
/
sdktools.sh
103 lines (83 loc) · 2.27 KB
/
sdktools.sh
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
if [ "x${SDKDIR}" = "x" ]; then
echo "You need to set the SDKDIR environment variable in order to use this script! Nothing will work until you do."
fi
if [ "x${NDKDIR}" = "x" ]; then
echo "You need to set the NDKDIR environment variable in order to use this script! Nothing will work until you do."
fi
if [ "x${GCSDKDIR}" = "x" ]; then
echo "You need to set the GCSDKDIR environment variable in order to use this script! Nothing will work until you do."
fi
PATH="${SDKDIR}/platform-tools:${SDKDIR}/tools:${NDKDIR}:${PATH}"
function readmanifest () {
local source
source=$(cat <<END
import json,sys;
o = json.load(open(sys.argv[1]));
try:
exec("print(o['" + "']['".join(sys.argv[2].split('.')) + "'])");
except KeyError:
pass
END
)
echo `python -c "$source" manifest.json "$1"`
}
function serve () {
if [ ! -e "manifest.json" ]; then echo "You must be inside a project to do that!"; return -1; fi
source ${GCSDKDIR}/gc_env/bin/activate
tealeaf serve
deactivate
return 0
}
function deploy () {
local studio
local debug
if [ ! -e "manifest.json" ]; then echo "You must be inside a project to do that!"; return -1; fi
source "${GCSDKDIR}/gc_env/bin/activate"
tealeaf deploy --target android $*
if [ $? -ne 0 ]; then
echo "Deploy failed!"
return -1
fi
deactivate
return 0
}
function debug () {
if [ ! -e "AndroidManifest.xml" ]; then echo "You must be inside an Android project directory to do that!"; return -1; fi
rm -rf libs jni obj
for dir in jni obj libs; do
ln -s "${ANDROIDDIR}/TeaLeaf/${dir}" "${dir}"
done
ndk-gdb --start --force
rm -rf libs jni obj
}
function install () {
local apk
local shortname
if [ ! -e "manifest.json" ]; then echo "You must be inside a project to do that!"; return -1; fi
# does the apk exist already?
shortname=`readmanifest shortName`
apk="build/${shortname}.apk"
if [ ! -e "${apk}" ]; then
# nope, run deploy
deploy
if [ $? -ne 0 ]; then
echo "Install failed!"
return -1
fi
fi
adb install ${apk}
return $?
}
function uninstall () {
local pkg
if [ ! -e "manifest.json" ]; then echo "You must be inside a project to do that!"; return -1; fi
# TODO support other studio names
shortname=`readmanifest shortName`
pkg="cat.wee.${pkg}"
adb uninstall ${pkg}
return $?
}
function reinstall () {
uninstall
install
}