forked from Unity-Technologies/mono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_runtime_android.sh
executable file
·138 lines (116 loc) · 3.84 KB
/
build_runtime_android.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
127
128
129
130
131
132
133
134
135
136
137
138
#!/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-5
GCC_PREFIX=arm-linux-androideabi-
GCC_VERSION=4.4.3
OUTDIR=builds/embedruntimes/android
PREFIX=`pwd`/builds/android
perl PrepareAndroidSDK.pl -ndk=r8 -env=envsetup.sh && source envsetup.sh
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-arm
TOOLCHAIN=$NDK_ROOT/toolchains/$GCC_PREFIX$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_PREFIX$GCC_VERSION | $ANDROID_PLATFORM"
exit 1
fi
PATH="$TOOLCHAIN/bin:$PATH"
CC="$TOOLCHAIN/bin/${GCC_PREFIX}gcc --sysroot=$PLATFORM_ROOT"
CXX="$TOOLCHAIN/bin/${GCC_PREFIX}g++ --sysroot=$PLATFORM_ROOT"
CPP="$TOOLCHAIN/bin/${GCC_PREFIX}cpp"
CXXCPP="$TOOLCHAIN/bin/${GCC_PREFIX}cpp"
CPATH="$PLATFORM_ROOT/usr/include"
LD=$TOOLCHAIN/bin/${GCC_PREFIX}ld
AS=$TOOLCHAIN/bin/${GCC_PREFIX}as
AR=$TOOLCHAIN/bin/${GCC_PREFIX}ar
RANLIB=$TOOLCHAIN/bin/${GCC_PREFIX}ranlib
STRIP=$TOOLCHAIN/bin/${GCC_PREFIX}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 -funwind-tables \
-ffunction-sections -fdata-sections"
CXXFLAGS=$CFLAGS
LDFLAGS="\
-Wl,--no-undefined \
-Wl,-rpath-link=$PLATFORM_ROOT/usr/lib \
-ldl -lm -llog -lc"
CONFIG_OPTS="\
--prefix=$PREFIX \
--cache-file=android_cross.cache \
--host=arm-eabi-linux \
--disable-mcs-build \
--disable-parallel-mark \
--disable-shared-handles \
--with-sigaltstack=no \
--with-tls=pthread \
--with-glib=embedded \
--enable-nls=no \
mono_cv_uscore=yes"
if [ ${UNITY_THISISABUILDMACHINE:+1} ]; then
echo "Erasing builds folder to make sure we start with a clean slate"
rm -rf builds
fi
function clean_build
{
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.a $3
cp mono/mini/.libs/libmono.so $3
}
CCFLAGS_ARMv5_CPU="-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"
CCFLAGS_ARMv6_VFP="-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"
CCFLAGS_ARMv7_VFP="-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"
LDFLAGS_ARMv5=""
LDFLAGS_ARMv7="-Wl,--fix-cortex-a8"
rm -rf $OUTDIR
clean_build "$CCFLAGS_ARMv5_CPU" "$LDFLAGS_ARMv5" "$OUTDIR/armv5"
clean_build "$CCFLAGS_ARMv6_VFP" "$LDFLAGS_ARMv5" "$OUTDIR/armv6_vfp"
clean_build "$CCFLAGS_ARMv7_VFP" "$LDFLAGS_ARMv7" "$OUTDIR/armv7a"
# works only with ndk-r6b and later
source build_runtime_android_x86.sh dontclean
NUM_LIBS_BUILT=`ls -AlR $OUTDIR | grep libmono | wc -l`
if [ $NUM_LIBS_BUILT -eq 8 ]; 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 -Al $OUTDIR
exit 1
fi