forked from Unity-Technologies/monobuildtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_runtime_iphone.sh
executable file
·183 lines (158 loc) · 6.17 KB
/
build_runtime_iphone.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/sh
SDK_VERSION=5.0
MAC_SDK_VERSION=10.6
ASPEN_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
SIMULATOR_ASPEN_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
XCOMP_ASPEN_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${MAC_SDK_VERSION}.sdk
if [ ! -d $ASPEN_ROOT/SDKs/iPhoneOS${SDK_VERSION}.sdk ]; then
SDK_VERSION=5.1
fi
echo "Using SDK $SDK_VERSION"
ASPEN_SDK=$ASPEN_ROOT/SDKs/iPhoneOS${SDK_VERSION}.sdk/
SIMULATOR_ASPEN_SDK=$SIMULATOR_ASPEN_ROOT/SDKs/iPhoneSimulator${SDK_VERSION}.sdk
ORIG_PATH=$PATH
PRFX=$PWD/tmp
ROOT=$PWD
MONOROOT=$PWD/../Mono
if [ ${UNITY_THISISABUILDMACHINE:+1} ]; then
echo "Erasing builds folder to make sure we start with a clean slate"
rm -rf builds
fi
setenv () {
export PATH=$ASPEN_ROOT/usr/bin:$PATH
export C_INCLUDE_PATH="$ASPEN_SDK/usr/lib/gcc/arm-apple-darwin9/4.2.1/include:$ASPEN_SDK/usr/include"
export CPLUS_INCLUDE_PATH="$ASPEN_SDK/usr/lib/gcc/arm-apple-darwin9/4.2.1/include:$ASPEN_SDK/usr/include"
#export CFLAGS="-DZ_PREFIX -DPLATFORM_IPHONE -DARM_FPU_VFP=1 -miphoneos-version-min=3.0 -mno-thumb -fvisibility=hidden -g -O0"
export CFLAGS="-DHAVE_ARMV6=1 -DZ_PREFIX -DPLATFORM_IPHONE -DARM_FPU_VFP=1 -miphoneos-version-min=3.0 -mno-thumb -fvisibility=hidden -Os"
export CXXFLAGS="$CFLAGS"
export CC="gcc -arch $1"
export CXX="g++ -arch $1"
export CPP="cpp -nostdinc -U__powerpc__ -U__i386__ -D__arm__"
export CXXPP="cpp -nostdinc -U__powerpc__ -U__i386__ -D__arm__"
export LD=$CC
export LDFLAGS="-liconv -Wl,-syslibroot,$ASPEN_SDK"
}
unsetenv () {
export PATH=$ORIG_PATH
unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH
unset CC
unset CXX
unset CPP
unset CXXPP
unset LD
unset LDFLAGS
unset PLATFORM_IPHONE_XCOMP
unset CFLAGS
unset CXXFLAGS
}
export mono_cv_uscore=yes
export mono_cv_clang=no
export cv_mono_sizeof_sunpath=104
export ac_cv_func_posix_getpwuid_r=yes
export ac_cv_func_backtrace_symbols=no
build_arm_mono ()
{
setenv "$1"
cd "$MONOROOT"
make clean
rm config.h*
pushd eglib
./autogen.sh --host=arm-apple-darwin9 --prefix=$PRFX
make clean
popd
./autogen.sh --prefix=$PRFX --disable-mcs-build --host=arm-apple-darwin9 --disable-shared-handles --with-tls=pthread --with-sigaltstack=no --with-glib=embedded --enable-minimal=jit,profiler,com --disable-nls --with-sgen=yes || exit 1
perl -pi -e 's/MONO_SIZEOF_SUNPATH 0/MONO_SIZEOF_SUNPATH 104/' config.h
perl -pi -e 's/#define HAVE_FINITE 1//' config.h
#perl -pi -e 's/#define HAVE_MMAP 1//' config.h
perl -pi -e 's/#define HAVE_CURSES_H 1//' config.h
perl -pi -e 's/#define HAVE_STRNDUP 1//' eglib/config.h
make
make || exit 1
mkdir -p "$ROOT/builds/embedruntimes/iphone"
cp "$MONOROOT/mono/mini/.libs/libmono-2.0.a" "$ROOT/builds/embedruntimes/iphone/libmono-2.0-$1.a" || exit 1
cp "$MONOROOT/mono/mini/.libs/libmonosgen-2.0.a" "$ROOT/builds/embedruntimes/iphone/libmonosgen-2.0-$1.a" || exit 1
}
build_iphone_runtime ()
{
echo "Building iPhone runtime"
build_arm_mono "armv7" || exit 1
build_arm_mono "armv6" || exit 1
libtool -static -o "$ROOT/builds/embedruntimes/iphone/libmono-2.0.a" "$ROOT/builds/embedruntimes/iphone/libmono-2.0-armv6.a" "$ROOT/builds/embedruntimes/iphone/libmono-2.0-armv7.a" || exit 1
rm "$ROOT/builds/embedruntimes/iphone/libmono-2.0-armv6.a"
rm "$ROOT/builds/embedruntimes/iphone/libmono-2.0-armv7.a"
libtool -static -o "$ROOT/builds/embedruntimes/iphone/libmonosgen-2.0.a" "$ROOT/builds/embedruntimes/iphone/libmonosgen-2.0-armv6.a" "$ROOT/builds/embedruntimes/iphone/libmonosgen-2.0-armv7.a" || exit 1
rm "$ROOT/builds/embedruntimes/iphone/libmonosgen-2.0-armv6.a"
rm "$ROOT/builds/embedruntimes/iphone/libmonosgen-2.0-armv7.a"
unsetenv
echo "iPhone runtime build done"
}
build_iphone_crosscompiler ()
{
echo "Building iPhone cross compiler";
export CFLAGS="-DARM_FPU_VFP=1 -DUSE_MUNMAP -DPLATFORM_IPHONE_XCOMP"
export CC="gcc -arch i386"
export CXX="g++ -arch i386"
export CPP="$CC -E"
export LD=$CC
export MACSDKOPTIONS="-D_XOPEN_SOURCE -mmacosx-version-min=$MAC_SDK_VERSION -isysroot $XCOMP_ASPEN_ROOT"
export PLATFORM_IPHONE_XCOMP=1
cd $MONOROOT
pushd eglib
./autogen.sh --prefix=$PRFX || exit 1
make clean
popd
./autogen.sh --prefix=$PRFX --with-macversion=$MAC_SDK_VERSION --disable-mcs-build --disable-shared-handles --with-tls=pthread --with-signalstack=no --with-glib=embedded --target=arm-darwin --disable-nls || exit 1
perl -pi -e 's/#define HAVE_STRNDUP 1//' eglib/config.h
make clean || exit 1
make || exit 1
mkdir -p "$ROOT/builds/crosscompiler/iphone"
cp "$MONOROOT/mono/mini/mono" "$ROOT/builds/crosscompiler/iphone/mono-xcompiler"
cp "$MONOROOT/mono/mini/mono-sgen" "$ROOT/builds/crosscompiler/iphone/mono-sgen-xcompiler"
unsetenv
echo "iPhone cross compiler build done"
}
build_iphone_simulator ()
{
echo "Building iPhone simulator static lib";
export MACSYSROOT="-isysroot $SIMULATOR_ASPEN_SDK"
export MACSDKOPTIONS="-miphoneos-version-min=3.0 $MACSYSROOT"
export CC="$SIMULATOR_ASPEN_ROOT/usr/bin/gcc -arch i386"
export CPP="$CC -E"
export CXX="$SIMULATOR_ASPEN_ROOT/usr/bin/g++ -arch i386"
export LIBTOOLIZE=`which glibtoolize`
cd "$ROOT"
perl build_runtime_osx.pl -iphone_simulator=1 || exit 1
echo "Copying iPhone simulator static lib to final destination";
mkdir -p "$ROOT/builds/embedruntimes/iphone"
cp "$MONOROOT/mono/mini/.libs/libmono-2.0.a" "builds/embedruntimes/iphone/libmono-2.0-i386.a"
cp "$MONOROOT/mono/mini/.libs/libmonosgen-2.0.a" "builds/embedruntimes/iphone/libmonosgen-2.0-i386.a"
unsetenv
}
usage()
{
echo "available arguments: [--runtime-only|--xcomp-only|--simulator-only]";
}
if [ $# -gt 1 ]; then
usage
exit 1
fi
if [ $# -eq 1 ]; then
if [ "x$1" == "x--runtime-only" ]; then
build_iphone_runtime || exit 1
elif [ "x$1" == "x--xcomp-only" ]; then
build_iphone_crosscompiler || exit 1
elif [ "x$1" == "x--simulator-only" ]; then
build_iphone_simulator|| exit 1
else
usage
fi
fi
if [ $# -eq 0 ]; then
build_iphone_runtime || exit 1
build_iphone_crosscompiler || exit 1
build_iphone_simulator || exit 1
fi
if [ ${UNITY_THISISABUILDMACHINE:+1} ]; then
echo "mono-runtime-iphone = $BUILD_VCS_NUMBER_mono_unity_2_10_2" > $ROOT/builds/versions.txt
fi