compileVLCforiOS.sh 5.83 KB
Newer Older
Felix Paul Kühne's avatar
Felix Paul Kühne committed
1 2 3 4 5 6
#!/bin/sh
# Copyright (C) Pierre d'Herbemont, 2010
# Copyright (C) Felix Paul Kühne, 2012-2013

set -e

7
PLATFORM=iphoneos
8
SDK=`xcrun --sdk iphoneos --show-sdk-version`
9
SDK_MIN=6.1
Felix Paul Kühne's avatar
Felix Paul Kühne committed
10
VERBOSE=no
11
CONFIGURATION="Release"
12
NONETWORK=no
13
SKIPLIBVLCCOMPILATION=no
14
UNSTABLEVLCKIT=yes
15

Felix Paul Kühne's avatar
Felix Paul Kühne committed
16
TESTEDVLCKITHASH=4c79a817e
17
TESTEDUNSTABLEVLCKITHASH=fbaf10813
Carola Nitz's avatar
Carola Nitz committed
18
TESTEDMEDIALIBRARYKITHASH=2d98d90aa
Felix Paul Kühne's avatar
Felix Paul Kühne committed
19 20 21 22

usage()
{
cat << EOF
23
usage: $0 [-s] [-v] [-k sdk] [-d] [-n] [-l] [-u]
Felix Paul Kühne's avatar
Felix Paul Kühne committed
24 25 26 27 28 29

OPTIONS
   -k       Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
   -v       Be more verbose
   -s       Build for simulator
   -d       Enable Debug
30
   -n       Skip script steps requiring network interaction
31
   -l       Skip libvlc compilation
32
   -p       Compile stable version of MobileVLCKit (default unstable)
Felix Paul Kühne's avatar
Felix Paul Kühne committed
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
EOF
}

spushd()
{
     pushd "$1" 2>&1> /dev/null
}

spopd()
{
     popd 2>&1> /dev/null
}

info()
{
     local green="\033[1;32m"
     local normal="\033[0m"
     echo "[${green}info${normal}] $1"
}

buildxcodeproj()
{
    local target="$2"
    if [ "x$target" = "x" ]; then
        target="$1"
    fi

    info "Building $1 ($target, ${CONFIGURATION})"

    local extra=""
    if [ "$PLATFORM" = "Simulator" ]; then
        extra="ARCHS=i386"
    fi

    xcodebuild -project "$1.xcodeproj" \
               -target "$target" \
69
               -sdk $PLATFORM$SDK \
Felix Paul Kühne's avatar
Felix Paul Kühne committed
70 71 72 73
               -configuration ${CONFIGURATION} ${extra} \
               IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} > ${out}
}

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
buildxcworkspace()
{
    local target="$2"
    if [ "x$target" = "x" ]; then
    target="$1"
    fi

    info "Building the workspace $1 ($target, ${CONFIGURATION})"

    local extra=""
    if [ "$PLATFORM" = "Simulator" ]; then
    extra="ARCHS=i386"
    fi

    xcodebuild -workspace "$1.xcworkspace" \
89
    -scheme "Pods-vlc-ios" \
90 91 92 93 94
    -sdk $PLATFORM$SDK \
    -configuration ${CONFIGURATION} ${extra} \
    IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} > ${out}
}

95
while getopts "hvsdnluk:" OPTION
Felix Paul Kühne's avatar
Felix Paul Kühne committed
96 97 98 99 100 101 102 103 104 105
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         s)
106
             PLATFORM=iphonesimulator
Felix Paul Kühne's avatar
Felix Paul Kühne committed
107 108 109
             ;;
         d)  CONFIGURATION="Debug"
             ;;
110 111 112
         n)
             NONETWORK=yes
             ;;
113 114 115
         l)
             SKIPLIBVLCCOMPILATION=yes
             ;;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
116 117 118
         k)
             SDK=$OPTARG
             ;;
119
         p)
120
             UNSTABLEVLCKIT=no
121
             ;;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
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
         ?)
             usage
             exit 1
             ;;
     esac
done
shift $(($OPTIND - 1))

out="/dev/null"
if [ "$VERBOSE" = "yes" ]; then
   out="/dev/stdout"
fi

if [ "x$1" != "x" ]; then
    usage
    exit 1
fi

# Get root dir
spushd .
aspen_root_dir=`pwd`
spopd

info "Preparing build dirs"

mkdir -p ImportedSources

Felix Paul Kühne's avatar
Felix Paul Kühne committed
149 150 151
rm -rf External
mkdir -p External

Felix Paul Kühne's avatar
Felix Paul Kühne committed
152 153
spushd ImportedSources

154
if [ "$NONETWORK" != "yes" ]; then
Felix Paul Kühne's avatar
Felix Paul Kühne committed
155
if ! [ -e MediaLibraryKit ]; then
156
git clone git://git.videolan.org/MediaLibraryKit.git
157
cd MediaLibraryKit
158
git checkout -B localAspenBranch ${TESTEDMEDIALIBRARYKITHASH}
159 160 161 162 163
git branch --set-upstream-to=origin/master localAspenBranch
cd ..
else
cd MediaLibraryKit
git reset --hard ${TESTEDMEDIALIBRARYKITHASH}
164
cd ..
Felix Paul Kühne's avatar
Felix Paul Kühne committed
165
fi
166
if [ "$UNSTABLEVLCKIT" = "no" ]; then
Felix Paul Kühne's avatar
Felix Paul Kühne committed
167 168
if ! [ -e VLCKit ]; then
git clone git://git.videolan.org/vlc-bindings/VLCKit.git
169
cd VLCKit
Felix Paul Kühne's avatar
Felix Paul Kühne committed
170 171
git checkout 2.1-stable
git reset --hard ${TESTEDVLCKITHASH}
172 173 174 175
cd ..
else
cd VLCKit
git reset --hard ${TESTEDVLCKITHASH}
176
cd ..
Felix Paul Kühne's avatar
Felix Paul Kühne committed
177
fi
178 179 180
else
if ! [ -e VLCKit ]; then
git clone git://git.videolan.org/vlc-bindings/VLCKit.git
181 182 183
cd VLCKit
git reset --hard ${TESTEDUNSTABLEVLCKITHASH}
cd ..
184
else
185 186 187
cd VLCKit
git reset --hard ${TESTEDUNSTABLEVLCKITHASH}
cd ..
188 189
fi
fi
Felix Paul Kühne's avatar
Felix Paul Kühne committed
190 191
if ! [ -e DAVKit ]; then
git clone git://github.com/mattrajca/DAVKit.git
192 193
else
cd DAVKit && git pull --rebase && cd ..
Felix Paul Kühne's avatar
Felix Paul Kühne committed
194
fi
195 196
if ! [ -e GDrive ]; then
svn checkout http://google-api-objectivec-client.googlecode.com/svn/trunk/Source GDrive
197
cd GDrive && patch -p0 < ../../patches/gdrive/upgrade-default-target.patch && cd ..
198 199
else
cd GDrive && svn up && cd ..
200
fi
201
if ! [ -e LXReorderableCollectionViewFlowLayout ]; then
202
git clone git://github.com/fkuehne/LXReorderableCollectionViewFlowLayout.git
203 204 205
else
cd LXReorderableCollectionViewFlowLayout && git pull --rebase && cd ..
fi
206
if ! [ -e WhiteRaccoon ]; then
207
git clone git://github.com/fkuehne/WhiteRaccoon.git
208 209
else
cd WhiteRaccoon && git pull --rebase && cd ..
210
fi
211
if ! [ -e CocoaHTTPServer ]; then
212
git clone git://github.com/fkuehne/CocoaHTTPServer.git
213 214
else
cd CocoaHTTPServer && git pull --rebase && cd ..
215
fi
216
fi
217

Felix Paul Kühne's avatar
Felix Paul Kühne committed
218 219
info "Setup 'External' folders"

220
if [ "$PLATFORM" = "iphonesimulator" ]; then
221
    xcbuilddir="build/${CONFIGURATION}-iphonesimulator"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
222
else
223
    xcbuilddir="build/${CONFIGURATION}-iphoneos"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
224 225 226
fi
framework_build="${aspen_root_dir}/ImportedSources/VLCKit/${xcbuilddir}"
mlkit_build="${aspen_root_dir}/ImportedSources/MediaLibraryKit/${xcbuilddir}"
Carola Nitz's avatar
Carola Nitz committed
227
gtl_build="${aspen_root_dir}/ImportedSources/GDrive/${xcbuilddir}"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
228 229 230 231 232

spopd #ImportedSources

ln -sf ${framework_build} External/MobileVLCKit
ln -sf ${mlkit_build} External/MediaLibraryKit
Carola Nitz's avatar
Carola Nitz committed
233
ln -sf ${gtl_build} External/gtl
Felix Paul Kühne's avatar
Felix Paul Kühne committed
234 235 236 237 238 239 240 241 242

#
# Build time
#

info "Building"

spushd ImportedSources

243 244
spushd VLCKit
echo `pwd`
Felix Paul Kühne's avatar
Felix Paul Kühne committed
245 246 247 248
args=""
if [ "$VERBOSE" = "yes" ]; then
    args="${args} -v"
fi
249
if [ "$PLATFORM" = "iphonesimulator" ]; then
250 251
    args="${args} -s"
fi
252 253
if [ "$NONETWORK" = "yes" ]; then
    args="${args} -n"
254
fi
255 256 257 258
if [ "$SKIPLIBVLCCOMPILATION" = "yes" ]; then
    args="${args} -l"
fi
./buildMobileVLCKit.sh ${args} -k "${SDK}"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
259 260 261 262 263
buildxcodeproj MobileVLCKit "Aggregate static plugins"
buildxcodeproj MobileVLCKit "MobileVLCKit"
spopd

spushd MediaLibraryKit
Felix Paul Kühne's avatar
Felix Paul Kühne committed
264 265
rm -f External/MobileVLCKit
ln -sf ${framework_build} External/MobileVLCKit
266
buildxcodeproj MediaLibraryKit
Felix Paul Kühne's avatar
Felix Paul Kühne committed
267 268
spopd

269 270 271 272
spushd GDrive
buildxcodeproj GTL "GTLTouchStaticLib"
spopd

Felix Paul Kühne's avatar
Felix Paul Kühne committed
273 274
spopd # ImportedSources

275 276 277
#install pods
info "installing pods"
pod install
Felix Paul Kühne's avatar
Felix Paul Kühne committed
278 279

# Build the Aspen Project now
Felix Paul Kühne's avatar
Felix Paul Kühne committed
280
buildxcworkspace "VLC for iOS" "VLC for iOS"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
281 282

info "Build completed"