forked from whirm/tgs-android
-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup-linux-environment.sh
executable file
·119 lines (87 loc) · 2.81 KB
/
setup-linux-environment.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#set -x
set -e
ROOT=$PWD
SDK_VERSION=16
#NDK_VERSION=7b
NDK_VERSION=6
SDK_FILE="android-sdk_r$SDK_VERSION-linux.tgz"
NDK_FILE="android-ndk-r$NDK_VERSION-linux-x86.tar.bz2"
get_package_index(){
echo "$SDKS_BUFFER" | grep "$1" | awk '{ print substr($1, 0, length($1)-1)}'
}
echo "Ok, let's set this up..."
echo ''
mkdir -p externals/downloads
cd externals/
if [ ! -e downloads/$SDK_FILE ]; then
wget http://dl.google.com/android/$SDK_FILE -O downloads/$SDK_FILE
fi
if [ ! -e downloads/$NDK_FILE ]; then
wget http://dl.google.com/android/ndk/$NDK_FILE -O downloads/$NDK_FILE
fi
if [ ! -e android-sdk-linux ]; then
tar xapf downloads/$SDK_FILE
fi
if [ ! -e android-ndk-r7b ]; then
tar xapf downloads/$NDK_FILE
fi
if [ ! -e android-sdk-linux/platforms/android-14 ]; then
cd android-sdk-linux/tools
SDKS_BUFFER=`./android list sdk`
PLATFORM_4=`get_package_index "SDK Platform Android 4.0, API 14"`
PLATFORM_TOOLS=`get_package_index "Android SDK Platform-tools"`
./android update sdk --no-ui --filter $PLATFORM_4,$PLATFORM_TOOLS,tool,platform-tool
./android update adb
cd ..
platform-tools/adb kill-server
fi
if [ ! -z "`uname -a | grep x86_64`" ]; then
echo "64 bit system detected, installing ia32-libs"
set +e
dpkg -l ia32-libs &>/dev/null
if [ $? == 1 ]; then
set -e
sudo apt-get install ia32-libs
else
echo "already installed, skipping"
fi
echo "This will fail in Debian, this shouldn't be a problem."
set +e
dpkg -l ia32-libs-multiarch &>/dev/null
if [ $? == 1 ]; then
sudo apt-get install ia32-libs-multiarch
else
echo ''
echo "already installed, skipping"
fi
set -e
fi
cd $ROOT/externals
#We aren't using this ATM
#if [ ! -e android-scripting ]; then
# echo ''
# echo "Cloning android scripting repo."
# hg clone https://code.google.com/p/android-scripting
#fi
cd $ROOT
export PATH=$PATH:$PWD/externals/android-ndk-r$NDK_VERSION:$PWD/externals/android-sdk-linux/tools:$PWD/externals/android-sdk-linux/platform-tools:$PWD/externals/android-scripting/tools/agcc
echo ''
echo "Building JNI"
ndk-build -C $ROOT/jni
echo ''
echo "Copying libcom_googlecode_android_scripting_Exec.so..."
cp $ROOT/hack/lib/armeabi/libcom_googlecode_android_scripting_Exec.so $ROOT/libs/armeabi/libcom_googlecode_android_scripting_Exec.so
echo ''
echo "Setting up local project configuration..."
android update project -p .
echo ''
echo "Looks like everything went OK."
echo ''
echo 'Now you need to import the project to Eclipse and "Run as Android app", to generate and install the APK to your phone or emulator.'
echo ''
echo ' OR'
echo ''
echo "Execute \"ant debug\" from the root's project dir. The .apk file will end up in bin/"
echo ''
echo "Have fun!"