Skip to content

Commit ae0e60e

Browse files
author
minggo
committed
Merge pull request #6 from andyque/testScripts
adding scripts to build iOS static libraries
2 parents feba73c + 450cfd5 commit ae0e60e

22 files changed

+1350
-344
lines changed

build_ios.sh

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
#!/bin/sh
2+
set -e
3+
4+
PLATFORM=OS
5+
VERBOSE=no
6+
SDK_VERSION=8.1
7+
SDK_MIN=5.1.1
8+
ARCH=armv7
9+
10+
usage()
11+
{
12+
cat << EOF
13+
usage: $0 [-s] [-k sdk]
14+
15+
OPTIONS
16+
-k <sdk version> Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
17+
-s Build for simulator
18+
-a <arch> Specify which arch to use (current: ${ARCH})
19+
EOF
20+
}
21+
22+
spushd()
23+
{
24+
pushd "$1" 2>&1> /dev/null
25+
}
26+
27+
spopd()
28+
{
29+
popd 2>&1> /dev/null
30+
}
31+
32+
info()
33+
{
34+
local blue="\033[1;34m"
35+
local normal="\033[0m"
36+
echo "[${blue}info${normal}] $1"
37+
}
38+
39+
40+
while getopts "hvsk:a:" OPTION
41+
do
42+
case $OPTION in
43+
h)
44+
usage
45+
exit 1
46+
;;
47+
v)
48+
VERBOSE=yes
49+
;;
50+
s)
51+
PLATFORM=Simulator
52+
;;
53+
k)
54+
SDK_VERSION=$OPTARG
55+
;;
56+
a)
57+
ARCH=$OPTARG
58+
;;
59+
?)
60+
usage
61+
exit 1
62+
;;
63+
esac
64+
done
65+
66+
shift $(($OPTIND - 1))
67+
68+
69+
if [ "x$1" != "x" ]; then
70+
usage
71+
exit 1
72+
fi
73+
74+
75+
out="/dev/null"
76+
if [ "$VERBOSE" = "yes" ]; then
77+
out="/dev/stdout"
78+
fi
79+
80+
info "Building cocos2d-x third party libraries for iOS"
81+
82+
if [ "$PLATFORM" = "Simulator" ]; then
83+
TARGET="${ARCH}-apple-darwin14"
84+
OPTIM="-O3 -g"
85+
else
86+
TARGET="arm-apple-darwin14"
87+
OPTIM="-O3 -g"
88+
fi
89+
90+
info "Using ${ARCH} with SDK version ${SDK_VERSION}"
91+
92+
THIS_SCRIPT_PATH=`pwd`/$0
93+
94+
# spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
95+
COCOSROOT=`pwd` # Let's make sure COCOSROOT is an absolute path
96+
# spopd
97+
98+
if test -z "$SDKROOT"
99+
then
100+
SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
101+
echo "SDKROOT not specified, assuming $SDKROOT"
102+
fi
103+
104+
if [ ! -d "${SDKROOT}" ]
105+
then
106+
echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
107+
exit 1
108+
fi
109+
110+
BUILDDIR="${COCOSROOT}/build-ios-${PLATFORM}/${ARCH}"
111+
112+
PREFIX="${COCOSROOT}/install-ios-${PLATFORM}/${ARCH}"
113+
114+
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
115+
116+
# info "Building tools"
117+
# spushd "${COCOSROOT}/contrib/ios"
118+
# ./bootstrap
119+
# make
120+
# spopd
121+
122+
info "Building contrib for iOS in '${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}'"
123+
124+
# The contrib will read the following
125+
export AR="xcrun ar"
126+
127+
export RANLIB="xcrun ranlib"
128+
export CC="xcrun clang"
129+
export OBJC="xcrun clang"
130+
export CXX="xcrun clang++"
131+
export LD="xcrun ld"
132+
export STRIP="xcrun strip"
133+
134+
export PLATFORM=$PLATFORM
135+
export SDK_VERSION=$SDK_VERSION
136+
137+
if [ "$PLATFORM" = "OS" ]; then
138+
export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
139+
if [ "$ARCH" != "arm64" ]; then
140+
export CFLAGS="${CFLAGS} -mcpu=cortex-a8"
141+
fi
142+
else
143+
export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
144+
fi
145+
146+
export CPP="xcrun cc -E"
147+
export CXXCPP="xcrun c++ -E"
148+
149+
export BUILDFORIOS="yes"
150+
151+
if [ "$PLATFORM" = "Simulator" ]; then
152+
# Use the new ABI on simulator, else we can't build
153+
export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
154+
fi
155+
156+
export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH} -isysroot ${SDKROOT} -miphoneos-version-min=${SDK_MIN}"
157+
158+
if [ "$PLATFORM" = "OS" ]; then
159+
EXTRA_CFLAGS="-arch ${ARCH}"
160+
if [ "$ARCH" != "arm64" ]; then
161+
EXTRA_CFLAGS+=" -mcpu=cortex-a8"
162+
fi
163+
EXTRA_LDFLAGS="-arch ${ARCH}"
164+
else
165+
EXTRA_CFLAGS="-arch ${ARCH}"
166+
EXTRA_LDFLAGS="-arch ${ARCH}"
167+
fi
168+
169+
EXTRA_CFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
170+
EXTRA_LDFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
171+
172+
info "LD FLAGS SELECTED = '${LDFLAGS}'"
173+
174+
spushd ${COCOSROOT}
175+
176+
echo ${COCOSROOT}
177+
mkdir -p "${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
178+
cd "${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
179+
180+
## FIXME: do we need to replace Apple's gas?
181+
if [ "$PLATFORM" = "OS" ]; then
182+
export AS="gas-preprocessor.pl ${CC}"
183+
export ASCPP="gas-preprocessor.pl ${CC}"
184+
export CCAS="gas-preprocessor.pl ${CC}"
185+
if [ "$ARCH" = "arm64" ]; then
186+
export GASPP_FIX_XCODE5=1
187+
fi
188+
else
189+
export ASCPP="xcrun as"
190+
fi
191+
192+
# # FIXME: add more convenient
193+
../bootstrap --build=x86_64-apple-darwin14 --host=${TARGET} --prefix=${COCOSROOT}/contrib/${TARGET}-${ARCH} \
194+
--disable-lua \
195+
--disable-freetype2 \
196+
--enable-png > ${out}
197+
198+
echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
199+
echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
200+
make fetch
201+
make
202+
spopd
203+
204+
# info "Bootstraping vlc"
205+
# pwd
206+
# info "VLCROOT = ${VLCROOT}"
207+
# if ! [ -e ${VLCROOT}/configure ]; then
208+
# ${VLCROOT}/bootstrap > ${out}
209+
# fi
210+
211+
# info "Bootstraping vlc finished"
212+
213+
# if [ ".$PLATFORM" != ".Simulator" ]; then
214+
# # FIXME - Do we still need this?
215+
# export AVCODEC_CFLAGS="-I${PREFIX}/include "
216+
# export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
217+
# export AVFORMAT_CFLAGS="-I${PREFIX}/include"
218+
# export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
219+
# fi
220+
221+
# mkdir -p ${BUILDDIR}
222+
# spushd ${BUILDDIR}
223+
224+
# info ">> --prefix=${PREFIX} --host=${TARGET}"
225+
226+
# # Run configure only upon changes.
227+
# if [ "${VLCROOT}/configure" -nt config.log -o \
228+
# "${THIS_SCRIPT_PATH}" -nt config.log ]; then
229+
# ${VLCROOT}/configure \
230+
# --prefix="${PREFIX}" \
231+
# --host="${TARGET}" \
232+
# --with-contrib="${VLCROOT}/contrib/${TARGET}-${ARCH}" \
233+
# --disable-debug \
234+
# --enable-static \
235+
# --disable-macosx \
236+
# --disable-macosx-dialog-provider \
237+
# --disable-macosx-qtkit \
238+
# --disable-macosx-eyetv \
239+
# --disable-macosx-vlc-app \
240+
# --disable-macosx-avfoundation \
241+
# --disable-audioqueue \
242+
# --disable-shared \
243+
# --enable-macosx-quartztext \
244+
# --enable-avcodec \
245+
# --enable-mkv \
246+
# --enable-opus \
247+
# --disable-sout \
248+
# --disable-faad \
249+
# --disable-lua \
250+
# --disable-a52 \
251+
# --enable-fribidi \
252+
# --disable-qt --disable-skins2 \
253+
# --disable-vcd \
254+
# --disable-vlc \
255+
# --disable-vlm \
256+
# --disable-httpd \
257+
# --disable-nls \
258+
# --disable-glx \
259+
# --disable-sse \
260+
# --enable-neon \
261+
# --disable-notify \
262+
# --enable-live555 \
263+
# --enable-realrtsp \
264+
# --enable-dvbpsi \
265+
# --enable-swscale \
266+
# --disable-projectm \
267+
# --enable-libass \
268+
# --enable-libxml2 \
269+
# --disable-goom \
270+
# --disable-dvdread \
271+
# --disable-dvdnav \
272+
# --disable-bluray \
273+
# --disable-linsys \
274+
# --disable-libva \
275+
# --disable-gme \
276+
# --disable-tremor \
277+
# --enable-vorbis \
278+
# --disable-fluidsynth \
279+
# --disable-jack \
280+
# --disable-pulse \
281+
# --disable-mtp \
282+
# --enable-ogg \
283+
# --enable-speex \
284+
# --enable-theora \
285+
# --enable-flac \
286+
# --disable-screen \
287+
# --enable-freetype \
288+
# --enable-taglib \
289+
# --disable-mmx \
290+
# --disable-addonmanagermodules \
291+
# --disable-mad > ${out} # MMX and SSE support requires llvm which is broken on Simulator
292+
# fi
293+
294+
# CORE_COUNT=`sysctl -n machdep.cpu.core_count`
295+
# let MAKE_JOBS=$CORE_COUNT+1
296+
297+
# info "Building libvlc"
298+
# make -j$MAKE_JOBS > ${out}
299+
300+
# info "Installing libvlc"
301+
# make install > ${out}
302+
303+
# find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
304+
# rm -rf "${PREFIX}/contribs"
305+
# cp -R "${VLCROOT}/contrib/${TARGET}-${ARCH}" "${PREFIX}/contribs"
306+
307+
308+
# popd

contrib/bootstrap

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ test -z "$GPL" || add_make_enabled "GPL"
231231
# Checks
232232
#
233233
OS="${HOST#*-}" # strip architecture
234+
echo $OS
234235
case "${OS}" in
235236
apple-darwin*)
236237
if test -z "$BUILDFORIOS"
@@ -239,13 +240,14 @@ case "${OS}" in
239240
add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
240241
else
241242
check_ios_sdk
242-
add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_NEON" "HAVE_ARMV7A"
243+
add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_ARMV7A" "HAVE_NEON"
243244
fi
244245
;;
245246
*bsd*)
246247
add_make_enabled "HAVE_BSD"
247248
;;
248249
*android*)
250+
echo "check android sdk"
249251
check_android_sdk
250252
add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
251253
case "${HOST}" in

contrib/src/change_prefix.sh

100644100755
File mode changed.

contrib/src/get-arch.sh

100644100755
File mode changed.

contrib/src/main.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ TOPDST ?= ..
1313
SRC := $(TOPSRC)/src
1414
TARBALLS := $(TOPSRC)/tarballs
1515

16-
PATH :=$(abspath ../../extras/tools/build/bin):$(PATH)
16+
PATH :=$(abspath ../../extras/tools/bin):$(PATH)
1717
export PATH
1818

1919
PKGS_ALL := $(patsubst $(SRC)/%/rules.mak,%,$(wildcard $(SRC)/*/rules.mak))
@@ -129,7 +129,7 @@ ifdef HAVE_IOS
129129
CC=xcrun clang
130130
CXX=xcrun clang++
131131
ifdef HAVE_NEON
132-
AS=perl $(abspath ../../extras/tools/build/bin/gas-preprocessor.pl) $(CC)
132+
AS=perl $(abspath ../../extras/tools/bin/gas-preprocessor.pl) $(CC)
133133
CCAS=gas-preprocessor.pl $(CC) -c
134134
else
135135
CCAS=$(CC) -c

contrib/src/ogg/SHA512SUMS

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)