-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.sh
More file actions
107 lines (88 loc) · 2.65 KB
/
build.sh
File metadata and controls
107 lines (88 loc) · 2.65 KB
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
#!/bin/bash
set -e
# Configure where we can find things here
export ANDROID_NDK_ROOT=/android_ndk
export ANDROID_SDK_ROOT=/android_sdk
# Platform architecture
export ARCH=${1-x86}
if [ "$ARCH" = "arm" ] ;
then
BUILDCHAIN=arm-linux-androideabi
export TARGET_ARCH_ABI=armeabi-v7a
elif [ "$ARCH" = "x86" ] ;
then
BUILDCHAIN=i686-linux-android
export TARGET_ARCH_ABI=x86
fi
pushd crossbuild
# Initialise cross toolchain
if [ ! -e ndk-$ARCH ] ; then
$ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh --system=linux-x86_64 --arch=$ARCH --install-dir=ndk-$ARCH --platform=android-19
fi
# Declare necessary variables for cross compilation
export BUILDROOT=$PWD
export PATH=${BUILDROOT}/ndk-$ARCH/bin:$PATH
export PREFIX=${BUILDROOT}/ndk-$ARCH/sysroot/usr
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
export CC=${BUILDCHAIN}-gcc
export CXX=${BUILDCHAIN}-g++
# Download libdivecomputer, libusb and libftdi submodule
if [ ! -e libdivecomputer/configure.ac ] || [ ! -e libusb/configure.ac ] || [ ! -e libftdi/CMakeLists.txt] ; then
git submodule init
git submodule update
fi
# Prepare for building
mkdir -vp build
# Build libusb
if [ ! -e libusb/configure ] ; then
pushd libusb
autoreconf --install
popd
fi
mkdir -p build/libusb-build-$ARCH
pushd build/libusb-build-$ARCH
if [ ! -e Makefile ] ; then
../../libusb/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared --disable-udev
fi
make
make install
popd
# Build libftdi
mkdir -p build/libftdi-build-$ARCH
pushd build/libftdi-build-$ARCH
if [ ! -e Makefile ] ; then
cmake -DCMAKE_C_COMPILER=${CC} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_PREFIX_PATH=${PREFIX} -DBUILD_SHARED_LIBS=OFF -DSTATICLIBS=ON -DPYTHON_BINDINGS=OFF -DDOCUMENTATION=OFF -DFTDIPP=OFF ../../libftdi
fi
make
make install
popd
# Build libdivecomputer
if [ ! -e libdivecomputer/configure ] ; then
pushd libdivecomputer
autoreconf -i
popd
fi
mkdir -p build/libdivecomputer-build-$ARCH
pushd build/libdivecomputer-build-$ARCH
if [ ! -e Makefile ] ; then
../../libdivecomputer/configure --host=${BUILDCHAIN} --prefix=${PREFIX} --enable-static --disable-shared --enable-logging LDFLAGS=-llog
fi
make
make install
popd
popd # from crossbuild
if [[ $? == 0 ]] ; then
echo "Finished building requisites."
fi
# Build native libraries
$ANDROID_NDK_ROOT/ndk-build -B
# Update application if build.xml is not present
if [ ! -e build.xml ] ; then
android update project -p .
fi
# Build the project in debug mode and install on the connected device
#ant clean
#ant -Dadb.device.arg="-e" debug install
ant debug install
# Run the application on the emulator
adb shell am start -a android.intent.action.MAIN -n com.subsurface/com.subsurface.Home