forked from Unity-Technologies/monobuildtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_runtime_android_x86.sh
executable file
·126 lines (108 loc) · 3.13 KB
/
build_runtime_android_x86.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
120
121
122
123
124
125
126
#!/bin/bash
# NB! Prereq : ANDROID_NDK_ROOT=/usr/local/android-ndk-xxx or similar
# Todo: set appropriate ARM flags for hard floats
export ANDROID_PLATFORM=android-9
GCC_VERSION=4.4.3
OUTDIR="$ROOT/builds/embedruntimes/android"
PREFIX="$ROOT/builds/android"
NDK_ROOT=`cd $ANDROID_NDK_ROOT && pwd`
if [ ! -f $NDK_ROOT/GNUmakefile ]; then
echo "Failed to locate Android NDK; is ANDROID_NDK_ROOT correctly set?"
exit 1
fi
HOST_ENV=`uname -s`
case "$HOST_ENV" in
Darwin)
HOST_ENV=darwin-x86
;;
Linux)
HOST_ENV=linux-x86
;;
CYGWIN*|*_NT-*)
HOST_ENV=windows
;;
*)
echo "Failed to locate supported host environment; HOST_ENV = $HOST_ENV ..."
exit 1
;;
esac
PLATFORM_ROOT=$NDK_ROOT/platforms/$ANDROID_PLATFORM/arch-x86
TOOLCHAIN=$NDK_ROOT/toolchains/x86-$GCC_VERSION/prebuilt/$HOST_ENV
if [ ! -a $TOOLCHAIN -o ! -a $PLATFORM_ROOT ]; then
NDK_NAME=`basename $NDK_ROOT`
echo "Failed to locate toolchain/platform; $NDK_NAME | $HOST_ENV | $GCC_VERSION | $ANDROID_PLATFORM"
echo "Toolchain = $TOOLCHAIN"
echo "Platform = $PLATFORM_ROOT"
exit 1
fi
PATH="$TOOLCHAIN/bin:$PATH"
CC="$TOOLCHAIN/bin/i686-android-linux-gcc --sysroot=$PLATFORM_ROOT"
CXX="$TOOLCHAIN/bin/i686-android-linux-g++ --sysroot=$PLATFORM_ROOT"
CPP="$TOOLCHAIN/bin/i686-android-linux-cpp"
CXXCPP="$TOOLCHAIN/bin/i686-android-linux-cpp"
CPATH="$PLATFORM_ROOT/usr/include"
LD=$TOOLCHAIN/bin/i686-android-linux-ld
AS=$TOOLCHAIN/bin/i686-android-linux-as
AR=$TOOLCHAIN/bin/i686-android-linux-ar
RANLIB=$TOOLCHAIN/bin/i686-android-linux-ranlib
STRIP=$TOOLCHAIN/bin/i686-android-linux-strip
CFLAGS="\
-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ \
-DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 \
-D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR \
-DHAVE_PTHREAD_MUTEX_TIMEDLOCK \
-fpic -g \
-ffunction-sections -fdata-sections"
CXXFLAGS=$CFLAGS
LDFLAGS="\
-Wl,--no-undefined \
-ldl -lm -llog -lc -lgcc"
CONFIG_OPTS="\
--prefix=$PREFIX \
--cache-file=android_cross.cache \
--host=i686-unknown-linux \
--disable-mcs-build \
--disable-parallel-mark \
--with-sigaltstack=no \
--with-tls=pthread \
--with-glib=embedded \
--with-sgen=no \
--enable-nls=no \
mono_cv_uscore=yes"
function clean_build
{
pushd "$ROOT/../Mono"
make clean && make distclean
rm android_cross.cache
pushd eglib
autoreconf -i
popd
autoreconf -i
./configure $CONFIG_OPTS \
PATH="$PATH" CC="$CC" CXX="$CXX" CPP="$CPP" CXXCPP="$CXXCPP" \
CFLAGS="$CFLAGS $1" CXXFLAGS="$CXXFLAGS $1" LDFLAGS="$LDFLAGS $2" \
LD=$LD AR=$AR AS=$AS RANLIB=$RANLIB STRIP=$STRIP CPATH="$CPATH"
if [ "$?" -ne "0" ]; then
echo "Configure FAILED!"
exit 1
fi
make && echo "Build SUCCESS!" || exit 1
mkdir -p $3
cp mono/mini/.libs/libmono-2.0.a $3
cp mono/mini/.libs/libmono-2.0.so $3
popd
}
if [ x$1 != x"dontclean" ]; then
rm -rf $OUTDIR
fi
clean_build "" "" "$OUTDIR/x86"
if [ x$1 != x"dontclean" ]; then
NUM_LIBS_BUILT=`ls -AlR $OUTDIR | grep libmono | wc -l`
if [ $NUM_LIBS_BUILT -eq 2 ]; then
echo "Android STATIC/SHARED libraries are found here: $OUTDIR"
else
echo "Build failed? Android STATIC/SHARED library cannot be found... Found $NUM_LIBS_BUILT libs under $OUTDIR"
ls -AlR $OUTDIR
exit 1
fi
fi