Skip to content

Commit e95fa6b

Browse files
Merge pull request #7 from andyque/testScripts
write scripts for various platform
2 parents ae0e60e + 3d85eda commit e95fa6b

28 files changed

+1368
-217
lines changed

build/android/build.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/sh
2+
set -e
3+
4+
info()
5+
{
6+
local green="\033[1;32m"
7+
local normal="\033[0m"
8+
echo "[${green}build${normal}] $1"
9+
}
10+
11+
# TODO: You must set your ANDROID_NDK path in .bash_profile
12+
source ~/.bash_profile
13+
ANDROID_ABI="armeabi-v7a"
14+
ANDROID_API="android-19"
15+
ANDROID_GCC_VERSION=4.8
16+
ANDROID_ARCH=arm
17+
18+
# TODO: configure to compile specify 3rd party libraries
19+
OPTIONS="
20+
--disable-lua
21+
--disable-freetype2
22+
--enable-png
23+
--disable-zlib
24+
"
25+
26+
usage()
27+
{
28+
cat << EOF
29+
usage: $0 [options]
30+
Build cocos2d-x 3rd party libraries for Android
31+
OPTIONS:
32+
-h Show some help
33+
-q Be quiet
34+
-k <sdk> Use the specified Android API level (default: $ANDROID_API)
35+
-a <arch> Use the specified arch (default: $ANDROID_ABI)
36+
-n <version> Use the gcc version(default: $ANDROID_GCC_VERSION)
37+
EOF
38+
}
39+
40+
spushd()
41+
{
42+
pushd "$1" > /dev/null
43+
}
44+
45+
spopd()
46+
{
47+
popd > /dev/null
48+
}
49+
50+
while getopts "hvk:a:" OPTION
51+
do
52+
case $OPTION in
53+
h)
54+
usage
55+
exit 1
56+
;;
57+
q)
58+
set +x
59+
QUIET="yes"
60+
;;
61+
a)
62+
ANDROID_ABI=$OPTARG
63+
;;
64+
k)
65+
ANDROID_API=$OPTARG
66+
;;
67+
n)
68+
ANDROID_GCC_VERSION=$OPTARG
69+
;;
70+
esac
71+
done
72+
73+
if [ "${ANDROID_ABI}" != "x86" ] && [ "${ANDROID_ABI}" != "armeabi-v7a" ] && [ "${ANDROID_ABI}" != "armeabi" ]; then
74+
echo "You must specify the right Android Arch within {armeabi, armeabi-v7a, x86}"
75+
exit 1
76+
fi
77+
78+
79+
# FIXME: we need a way to determine the toolchina address automatically
80+
toolchain_bin=
81+
82+
if [ "${ANDROID_ABI}" = "x86" ]; then
83+
TARGET="i686-linux-android"
84+
toolchain_bin=${ANDROID_NDK}/toolchains/x86-${ANDROID_GCC_VERSION}/prebuilt/darwin-x86_64/bin
85+
ANDROID_ARCH=x86
86+
else
87+
TARGET="arm-linux-androideabi"
88+
toolchain_bin=${ANDROID_NDK}/toolchains/${TARGET}-${ANDROID_GCC_VERSION}/prebuilt/darwin-x86_64/bin
89+
fi
90+
91+
shift $(($OPTIND - 1))
92+
if [ "x$1" != "x" ]; then
93+
usage
94+
exit 1
95+
fi
96+
#
97+
# Various initialization
98+
#
99+
out="/dev/stdout"
100+
if [ "$QUIET" = "yes" ]; then
101+
out="/dev/null"
102+
fi
103+
104+
info "Building 3rd party libraries for the Android"
105+
cocos_root=`pwd`/../..
106+
107+
export ANDROID_ABI
108+
export ANDROID_API
109+
export LDFLAGS="-L${ANDROID_NDK}/platforms/${ANDROID_API}/arch-${ANDROID_ARCH}/usr/lib"
110+
info "LD FLAGS SELECTED = '${LDFLAGS}'"
111+
112+
export PATH="${toolchain_bin}:${cocos_root}/extras/tools/bin:$PATH"
113+
#
114+
# build 3rd party libraries
115+
#
116+
info "Building static libraries"
117+
spushd "${cocos_root}/contrib"
118+
mkdir -p "Android-${ANDROID_ABI}" && cd "Android-${ANDROID_ABI}"
119+
120+
../bootstrap ${OPTIONS} \
121+
--host=${TARGET} \
122+
--prefix=${cocos_root}/contrib/${TARGET}-${ANDROID_ABI}> $out
123+
#
124+
# make
125+
#
126+
make fetch
127+
make list
128+
make
Lines changed: 28 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
#!/bin/sh
22
set -e
3+
set -x
34

45
PLATFORM=OS
56
VERBOSE=no
6-
SDK_VERSION=8.1
7-
SDK_MIN=5.1.1
7+
SDK_VERSION=$(xcodebuild -showsdks | grep iphoneos | sort | tail -n 1 | awk '{print substr($NF,9)}')
8+
# FIXME: why min deploy target can't use 5.1.1
9+
SDK_MIN=6.0
810
ARCH=armv7
911

12+
# TODO: configure to compile speficy 3rd party libraries
13+
OPTIONS="
14+
--enable-lua
15+
--enable-freetype2
16+
--enable-png
17+
"
18+
19+
1020
usage()
1121
{
1222
cat << EOF
13-
usage: $0 [-s] [-k sdk]
23+
usage: $0 [-s] [-k sdk] [-a arch] [-l libname]
1424
1525
OPTIONS
1626
-k <sdk version> Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
1727
-s Build for simulator
1828
-a <arch> Specify which arch to use (current: ${ARCH})
29+
-l <libname> Specify which static library to build
1930
EOF
2031
}
2132

@@ -37,7 +48,7 @@ info()
3748
}
3849

3950

40-
while getopts "hvsk:a:" OPTION
51+
while getopts "hvsk:a:l:" OPTION
4152
do
4253
case $OPTION in
4354
h)
@@ -56,6 +67,9 @@ do
5667
a)
5768
ARCH=$OPTARG
5869
;;
70+
l)
71+
OPTIONS=--enable-$OPTARG
72+
;;
5973
?)
6074
usage
6175
exit 1
@@ -80,20 +94,18 @@ fi
8094
info "Building cocos2d-x third party libraries for iOS"
8195

8296
if [ "$PLATFORM" = "Simulator" ]; then
83-
TARGET="${ARCH}-apple-darwin14"
97+
TARGET="${ARCH}-apple-darwin"
8498
OPTIM="-O3 -g"
8599
else
86-
TARGET="arm-apple-darwin14"
100+
TARGET="arm-apple-darwin"
87101
OPTIM="-O3 -g"
88102
fi
89103

90104
info "Using ${ARCH} with SDK version ${SDK_VERSION}"
91105

92-
THIS_SCRIPT_PATH=`pwd`/$0
106+
THIS_SCRIPT_PATH=`pwd`
93107

94-
# spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
95-
COCOSROOT=`pwd` # Let's make sure COCOSROOT is an absolute path
96-
# spopd
108+
COCOSROOT=`pwd`/../..
97109

98110
if test -z "$SDKROOT"
99111
then
@@ -113,11 +125,6 @@ PREFIX="${COCOSROOT}/install-ios-${PLATFORM}/${ARCH}"
113125

114126
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
115127

116-
# info "Building tools"
117-
# spushd "${COCOSROOT}/contrib/ios"
118-
# ./bootstrap
119-
# make
120-
# spopd
121128

122129
info "Building contrib for iOS in '${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}'"
123130

@@ -175,7 +182,7 @@ spushd ${COCOSROOT}
175182

176183
echo ${COCOSROOT}
177184
mkdir -p "${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
178-
cd "${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
185+
spushd "${COCOSROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
179186

180187
## FIXME: do we need to replace Apple's gas?
181188
if [ "$PLATFORM" = "OS" ]; then
@@ -189,120 +196,14 @@ else
189196
export ASCPP="xcrun as"
190197
fi
191198

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}
199+
../bootstrap ${OPTIONS} \
200+
--build=x86_64-apple-darwin14 \
201+
--host=${TARGET} \
202+
--prefix=${COCOSROOT}/contrib/${TARGET}-${ARCH} > ${out}
197203

198204
echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
199205
echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
200206
make fetch
207+
make list
201208
make
202209
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

0 commit comments

Comments
 (0)