<commit_before>#!/bin/sh
set -e

PLATFORM=OS
VERBOSE=no
SDK_VERSION=5.0

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

OPTIONS
   -k       Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK})
   -s       Build for simulator
EOF
}

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

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

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

while getopts "hvsk:" OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         s)
             PLATFORM=Simulator
             SDK=5.0
             ;;
         k)
             SDK=$OPTARG
             ;;
         ?)
             usage
             exit 1
             ;;
     esac
done
shift $(($OPTIND - 1))

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

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

info "Building libvlc for the iOS"

if [ "$PLATFORM" = "Simulator" ]; then
    TARGET="i686-apple-darwin10"
    ARCH="i386"
else
    TARGET="arm-apple-darwin11"
    ARCH="armv7"
    OPTIM="-mno-thumb"
fi

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

THIS_SCRIPT_PATH=`pwd`/$0

spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
spopd

if test -z "$SDKROOT"
then
    SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
    echo "SDKROOT not specified, assuming $SDKROOT"
fi

if [ ! -d "${SDKROOT}" ]
then
    echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
    exit 1
fi

BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}"

PREFIX="${VLCROOT}/install-ios-${PLATFORM}"

IOS_GAS_PREPROCESSOR="${VLCROOT}/extras/package/ios/resources/gas-preprocessor.pl"

export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

# contains gas-processor.pl
export PATH=$PATH:${VLCROOT}/extras/package/ios/resources

info "Building tools"
spushd "${VLCROOT}/extras/tools"
./bootstrap
make
spopd

info "Building contrib for iOS in '${VLCROOT}/contrib/iPhone${PLATFORM}'"

# The contrib will read the following
export AR="xcrun ar"

export RANLIB="xcrun ranlib"
export CC="xcrun clang"
export OBJC="xcrun clang"
export CXX="xcrun clang++"
export LD="xcrun ld"
export STRIP="xcrun strip"


export SDKROOT
export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS}"
export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=5.0 ${OPTIM}"
export OBJCFLAGS="${CFLAGS}"

export CPP="xcrun cc -E"
export CXXCPP="xcrun c++ -E"

if [ "$PLATFORM" = "Simulator" ]; then
    # Use the new ABI on simulator, else we can't build
    export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
fi

if [ "$PLATFORM" = "OS" ]; then
  export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH}  -isysroot ${SDKROOT}  -miphoneos-version-min=5.0 "
else
  export LDFLAGS="-syslibroot=${SDKROOT}/ -arch ${ARCH} "
fi

info "LD FLAGS SELECTED = '${LDFLAGS}'"

spushd ${VLCROOT}/contrib

echo ${VLCROOT}
mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}"
cd "${VLCROOT}/contrib/iPhone${PLATFORM}"

if [ "$PLATFORM" = "OS" ]; then
  export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
  export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
else
  export AS="xcrun as"
  export ASCPP="xcrun as"
fi

../bootstrap --host=${TARGET} --build="i686-apple-darwin10" --disable-disc --disable-sout  > ${out}
make
spopd


if [ "$PLATFORM" = "OS" ]; then
  export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
  export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
else
  export AS="xcrun as"
  export ASCPP="xcrun as"
fi


info "Bootstraping vlc"
pwd
info "VLCROOT = ${VLCROOT}"
if ! [ -e ${VLCROOT}/configure ]; then
    ${VLCROOT}/bootstrap  > ${out}
fi

info "Bootstraping vlc finished"

if [ ".$PLATFORM" != ".Simulator" ]; then
    # FIXME - Do we still need this?
    export AVCODEC_CFLAGS="-I${PREFIX}/include "
    export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
    export AVFORMAT_CFLAGS="-I${PREFIX}/include"
    export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
fi

export DVBPSI_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
export DVBPSI_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "

export SWSCALE_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
export SWSCALE_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "



mkdir -p ${BUILDDIR}
spushd ${BUILDDIR}

info ">> --prefix=${PREFIX} --host=${TARGET}"

# Run configure only upon changes.
if [ "${VLCROOT}/configure" -nt config.log -o \
     "${THIS_SCRIPT_PATH}" -nt config.log ]; then
CONTRIB_DIR=${VLCROOT}/contrib-ios-${TARGET} \
${VLCROOT}/configure \
    --prefix="${PREFIX}" \
    --host="${TARGET}" \
    --enable-debug \
    --enable-static-modules \
    --disable-macosx \
    --disable-macosx-defaults \
    --disable-macosx-vout \
    --disable-macosx-dialog-provider \
    --disable-macosx-qtkit \
    --disable-macosx-eyetv \
    --disable-macosx-vlc-app \
    --with-macosx-sdk=${SDKROOT} \
    --enable-audioqueue \
    --enable-ios-vout \
    --disable-shared \
    --disable-macosx-quartztext \
    --enable-avcodec \
    --disable-avio \
    --disable-dummy \
    --disable-mkv \
    --enable-ffmpeg \
    --enable-dvbpsi \
    --enable-swscale \
    --disable-projectm \
    --disable-sout \
    --disable-faad \
    --disable-mad \
    --disable-a52 \
    --disable-fribidi \
    --disable-jpeg \
    --disable-macosx-audio \
    --disable-qtcapture \
    --disable-qtsound \
    --disable-qt4 --disable-skins2 \
    --disable-libgcrypt \
    --disable-remoteosd \
    --disable-vcd \
    --disable-postproc \
    --disable-vlc \
    --disable-audio_filter \
    --disable-spatializer \
    --disable-vlm \
    --disable-httpd \
    --disable-nls \
    --disable-glx \
    --enable-visual \
    --disable-lua \
    --disable-sse \
    --disable-neon \
    --disable-notify \
    --disable-mmx > ${out} # MMX and SSE support requires llvm which is broken on Simulator
fi

CORE_COUNT=`sysctl -n machdep.cpu.core_count`
let MAKE_JOBS=$CORE_COUNT+1

info "Building libvlc"
make -j$MAKE_JOBS > ${out}

info "Installing libvlc"
make install > ${out}
popd
<commit_msg>ios/build.sh: added contrib options taken from the Android port<commit_after>#!/bin/sh
set -e

PLATFORM=OS
VERBOSE=no
SDK_VERSION=5.0

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

OPTIONS
   -k       Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK})
   -s       Build for simulator
EOF
}

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

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

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

while getopts "hvsk:" OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         s)
             PLATFORM=Simulator
             SDK=5.0
             ;;
         k)
             SDK=$OPTARG
             ;;
         ?)
             usage
             exit 1
             ;;
     esac
done
shift $(($OPTIND - 1))

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

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

info "Building libvlc for the iOS"

if [ "$PLATFORM" = "Simulator" ]; then
    TARGET="i686-apple-darwin10"
    ARCH="i386"
else
    TARGET="arm-apple-darwin11"
    ARCH="armv7"
    OPTIM="-mno-thumb"
fi

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

THIS_SCRIPT_PATH=`pwd`/$0

spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
spopd

if test -z "$SDKROOT"
then
    SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
    echo "SDKROOT not specified, assuming $SDKROOT"
fi

if [ ! -d "${SDKROOT}" ]
then
    echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
    exit 1
fi

BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}"

PREFIX="${VLCROOT}/install-ios-${PLATFORM}"

IOS_GAS_PREPROCESSOR="${VLCROOT}/extras/package/ios/resources/gas-preprocessor.pl"

export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

# contains gas-processor.pl
export PATH=$PATH:${VLCROOT}/extras/package/ios/resources

info "Building tools"
spushd "${VLCROOT}/extras/tools"
./bootstrap
make
spopd

info "Building contrib for iOS in '${VLCROOT}/contrib/iPhone${PLATFORM}'"

# The contrib will read the following
export AR="xcrun ar"

export RANLIB="xcrun ranlib"
export CC="xcrun clang"
export OBJC="xcrun clang"
export CXX="xcrun clang++"
export LD="xcrun ld"
export STRIP="xcrun strip"


export SDKROOT
export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS}"
export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=5.0 ${OPTIM}"
export OBJCFLAGS="${CFLAGS}"

export CPP="xcrun cc -E"
export CXXCPP="xcrun c++ -E"

if [ "$PLATFORM" = "Simulator" ]; then
    # Use the new ABI on simulator, else we can't build
    export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
fi

if [ "$PLATFORM" = "OS" ]; then
  export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH}  -isysroot ${SDKROOT}  -miphoneos-version-min=5.0 "
else
  export LDFLAGS="-syslibroot=${SDKROOT}/ -arch ${ARCH} "
fi

info "LD FLAGS SELECTED = '${LDFLAGS}'"

spushd ${VLCROOT}/contrib

echo ${VLCROOT}
mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}"
cd "${VLCROOT}/contrib/iPhone${PLATFORM}"

if [ "$PLATFORM" = "OS" ]; then
  export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
  export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
else
  export AS="xcrun as"
  export ASCPP="xcrun as"
fi

../bootstrap --host=${TARGET} --build="i686-apple-darwin10" --disable-disc --disable-sout \
    --enable-small \
    --disable-sdl \
    --disable-SDL_image \
    --disable-fontconfig \
    --disable-ass \
    --disable-freetype2 \
    --disable-fribidi \
    --disable-zvbi \
    --disable-kate \
    --disable-caca \
    --disable-gettext \
    --disable-mpcdec \
    --disable-upnp \
    --disable-gme \
    --disable-tremor \
    --disable-vorbis \
    --disable-sidplay2 \
    --disable-samplerate > ${out}
make
spopd


if [ "$PLATFORM" = "OS" ]; then
  export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
  export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
else
  export AS="xcrun as"
  export ASCPP="xcrun as"
fi


info "Bootstraping vlc"
pwd
info "VLCROOT = ${VLCROOT}"
if ! [ -e ${VLCROOT}/configure ]; then
    ${VLCROOT}/bootstrap  > ${out}
fi

info "Bootstraping vlc finished"

if [ ".$PLATFORM" != ".Simulator" ]; then
    # FIXME - Do we still need this?
    export AVCODEC_CFLAGS="-I${PREFIX}/include "
    export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
    export AVFORMAT_CFLAGS="-I${PREFIX}/include"
    export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
fi

export DVBPSI_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
export DVBPSI_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "

export SWSCALE_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
export SWSCALE_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "



mkdir -p ${BUILDDIR}
spushd ${BUILDDIR}

info ">> --prefix=${PREFIX} --host=${TARGET}"

# Run configure only upon changes.
if [ "${VLCROOT}/configure" -nt config.log -o \
     "${THIS_SCRIPT_PATH}" -nt config.log ]; then
CONTRIB_DIR=${VLCROOT}/contrib-ios-${TARGET} \
${VLCROOT}/configure \
    --prefix="${PREFIX}" \
    --host="${TARGET}" \
    --enable-debug \
    --enable-static-modules \
    --disable-macosx \
    --disable-macosx-defaults \
    --disable-macosx-vout \
    --disable-macosx-dialog-provider \
    --disable-macosx-qtkit \
    --disable-macosx-eyetv \
    --disable-macosx-vlc-app \
    --with-macosx-sdk=${SDKROOT} \
    --enable-audioqueue \
    --enable-ios-vout \
    --disable-shared \
    --disable-macosx-quartztext \
    --enable-avcodec \
    --disable-avio \
    --disable-dummy \
    --disable-mkv \
    --enable-ffmpeg \
    --enable-dvbpsi \
    --enable-swscale \
    --disable-projectm \
    --disable-sout \
    --disable-faad \
    --disable-mad \
    --disable-a52 \
    --disable-fribidi \
    --disable-jpeg \
    --disable-macosx-audio \
    --disable-qtcapture \
    --disable-qtsound \
    --disable-qt4 --disable-skins2 \
    --disable-libgcrypt \
    --disable-remoteosd \
    --disable-vcd \
    --disable-postproc \
    --disable-vlc \
    --disable-audio_filter \
    --disable-spatializer \
    --disable-vlm \
    --disable-httpd \
    --disable-nls \
    --disable-glx \
    --enable-visual \
    --disable-lua \
    --disable-sse \
    --disable-neon \
    --disable-notify \
    --disable-mmx > ${out} # MMX and SSE support requires llvm which is broken on Simulator
fi

CORE_COUNT=`sysctl -n machdep.cpu.core_count`
let MAKE_JOBS=$CORE_COUNT+1

info "Building libvlc"
make -j$MAKE_JOBS > ${out}

info "Installing libvlc"
make install > ${out}
popd

{'fraction_non_alphanumeric': 0.17341348348805358, 'fraction_numerical': 0.008674478770354589, 'mean_word_length': 2.7423120728929384, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1433475', 'n_tokens_mistral': 5114, 'n_tokens_neox': 4879, 'n_words': 1002}