buildMobileVLCKit.sh 4.75 KB
Newer Older
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 8 9
BUILD_DEVICE=yes
BUILD_SIMULATOR=no
BUILD_FRAMEWORK=no
10
SDK=`xcrun --sdk iphoneos --show-sdk-version`
11 12 13 14 15
SDK_MIN=6.1
VERBOSE=no
CONFIGURATION="Release"
NONETWORK=no
SKIPLIBVLCCOMPILATION=no
16
SCARY=yes
17

Felix Paul Kühne's avatar
Felix Paul Kühne committed
18
TESTEDHASH=6259d80d
19 20 21 22 23 24 25 26 27 28

usage()
{
cat << EOF
usage: $0 [-s] [-v] [-k sdk]

OPTIONS
   -k       Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
   -v       Be more verbose
   -s       Build for simulator
29
   -f       Build framework for device and simulator
30 31 32
   -d       Enable Debug
   -n       Skip script steps requiring network interaction
   -l       Skip libvlc compilation
33
   -w       Build a limited stack of non-scary libraries only
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
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})"

63 64 65 66
    local defs="$GCC_PREPROCESSOR_DEFINITIONS"
    if [ "$SCARY" = "no" ]; then
        defs="$defs NOSCARYCODECS"
    fi
67 68 69
    xcodebuild -project "$1.xcodeproj" \
               -target "$target" \
               -sdk $PLATFORM$SDK \
70
               -configuration ${CONFIGURATION} \
71 72 73
               IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
               GCC_PREPROCESSOR_DEFINITIONS="$defs" \
               > ${out}
74 75
}

76
while getopts "hvwsfdnlk:" OPTION
77 78 79 80 81 82 83 84 85 86
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         s)
87 88 89
             BUILD_DEVICE=no
             BUILD_SIMULATOR=yes
             BUILD_FRAMEWORK=no
90 91
             ;;
         f)
92 93 94
             BUILD_DEVICE=yes
             BUILD_SIMULATOR=yes
             BUILD_FRAMEWORK=yes
95 96 97
             ;;
         d)  CONFIGURATION="Debug"
             ;;
98 99
         w)  SCARY="no"
             ;;
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
         n)
             NONETWORK=yes
             ;;
         l)
             SKIPLIBVLCCOMPILATION=yes
             ;;
         k)
             SDK=$OPTARG
             ;;
         ?)
             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 MobileVLCKit/ImportedSources

spushd MobileVLCKit/ImportedSources

if [ "$NONETWORK" != "yes" ]; then
if ! [ -e vlc ]; then
140 141
git clone git://git.videolan.org/vlc/vlc-2.2.git vlc
info "Applying patches to vlc-2.2.git"
142
cd vlc
Felix Paul Kühne's avatar
Felix Paul Kühne committed
143 144
git checkout -B localBranch ${TESTEDHASH}
git branch --set-upstream-to=origin/master localBranch
145 146 147 148 149 150 151 152 153
git am ../../patches/*.patch
if [ $? -ne 0 ]; then
git am --abort
info "Applying the patches failed, aborting git-am"
exit 1
fi
cd ..
else
cd vlc
154
git pull --rebase
Rafaël Carré's avatar
Rafaël Carré committed
155
git reset --hard ${TESTEDHASH}
156
git am ../../patches/*.patch
157 158 159 160 161 162 163 164 165 166
cd ..
fi
fi

spopd

#
# Build time
#

167 168
buildMobileKit() {
    PLATFORM="$1"
169

170
    info "Building for $PLATFORM"
171

172
    spushd MobileVLCKit/ImportedSources
173

174 175 176 177 178 179 180
    if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
    spushd vlc/extras/package/ios
    info "Building vlc"
    args=""
    if [ "$VERBOSE" = "yes" ]; then
        args="${args} -v"
    fi
181 182 183
    if [ "$CONFIGURATION" = "Debug" ]; then
        args="${args} -d"
    fi
184 185 186
    if [ "$SCARY" = "no" ]; then
        args="${args} -w"
    fi
187 188 189 190 191 192
    if [ "$PLATFORM" = "iphonesimulator" ]; then
        args="${args} -s"
        ./build.sh -a i386 ${args} -k "${SDK}" && ./build.sh -a x86_64 ${args} -k "${SDK}"
    else
        ./build.sh -a armv7 ${args} -k "${SDK}" && ./build.sh -a armv7s ${args} -k "${SDK}" && ./build.sh -a arm64 ${args} -k "${SDK}"
    fi
193

194 195
    spopd
    fi
196

197
    spopd # MobileVLCKit/ImportedSources
198

199 200 201 202 203 204
    buildxcodeproj MobileVLCKit "Aggregate static plugins"
    buildxcodeproj MobileVLCKit "MobileVLCKit"

    info "Build for $PLATFORM completed"
}

205
if [ "$BUILD_DEVICE" != "no" ]; then
206 207
    buildMobileKit iphoneos
fi
208
if [ "$BUILD_SIMULATOR" != "no" ]; then
209 210
    buildMobileKit iphonesimulator
fi
211
if [ "$BUILD_FRAMEWORK" != "no" ]; then
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
    info "Building MobileVLCKit.framework"

    # Assumes both platforms were built currently
    spushd build
    rm -rf MobileVLCKit.framework && \
    mkdir MobileVLCKit.framework && \
    lipo -create Release-iphoneos/libMobileVLCKit.a \
                 Release-iphonesimulator/libMobileVLCKit.a \
              -o MobileVLCKit.framework/MobileVLCKit && \
    chmod a+x MobileVLCKit.framework/MobileVLCKit && \
    cp -pr Release-iphoneos/include/MobileVLCKit MobileVLCKit.framework/Headers
    spopd # build

    info "Build of MobileVLCKit.framework completed"
fi