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

PLATFORM=OS
VERBOSE=no
DEBUG=no
SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
SDK_MIN=7.0
SIXTYFOURBIT_SDK_MIN=7.0
ARCH=armv7
SCARY=yes
TVOS=no
OSSTYLE=iPhone
OSVERSIONMINCFLAG=miphoneos-version-min
OSVERSIONMINLDFLAG=ios_version_min

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

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

OPTIONS
   -k <sdk version>      Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
   -s            Build for simulator
   -a <arch>     Specify which arch to use (current: ${ARCH})
   -d            Enable debug
   -v            Enable verbose command-line output
   -t            Build for tvOS
   -w            Build a limited stack of non-scary libraries only
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 "hvwdstk:a:" OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         s)
             PLATFORM=Simulator
             ;;
         d)
             DEBUG=yes
             ;;
         w)
             SCARY=no
             ;;
         k)
             SDK_VERSION=$OPTARG
             ;;
         a)
             ARCH=$OPTARG
             ;;
         t)
             TVOS=yes
             SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
             OSVERSIONMINCFLAG=mtvos-version-min
             OSVERSIONMINLDFLAG=tvos_version_min
             SIXTYFOURBIT_SDK_MIN=9.0
             ;;
         ?)
             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 iOS"

TARGET="${ARCH}-apple-darwin11"

# apple doesn't call AArch64 that way, but arm64 (a contrario to all libraries)
# so we need to translate it..
if [ "$ARCH" = "aarch64" ]; then
	ACTUAL_ARCH="arm64"
else
	ACTUAL_ARCH="$ARCH"
fi

if [ "$DEBUG" = "yes" ]; then
    OPTIM="-O0 -g"
else
    OPTIM="-O3 -g"
fi

if [ "$TVOS" = "yes" ]; then
	OSSTYLE=AppleTV
	export BUILDFORTVOS="yes"
fi
export BUILDFORIOS="yes"

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/${OSSTYLE}${PLATFORM}.platform/Developer/SDKs/${OSSTYLE}${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-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
PREFIX="${VLCROOT}/install-ios-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"

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

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

info "Building contrib for iOS in '${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}'"

# 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 PLATFORM=$PLATFORM
export SDK_VERSION=$SDK_VERSION
export VLCSDKROOT=$SDKROOT

export CFLAGS="-isysroot ${SDKROOT} -arch ${ACTUAL_ARCH} ${OPTIM}"

if [ "$PLATFORM" = "OS" ]; then
if [ "$ARCH" != "aarch64" ]; then
export CFLAGS="${CFLAGS} -mcpu=cortex-a8 -${OSVERSIONMINCFLAG}=${SDK_MIN}"
else
export CFLAGS="${CFLAGS} -${OSVERSIONMINCFLAG}=${SIXTYFOURBIT_SDK_MIN}"
fi
else
export CFLAGS="${CFLAGS} -${OSVERSIONMINCFLAG}=${SIXTYFOURBIT_SDK_MIN}"
fi

export CXXFLAGS="${CFLAGS}"<commit_msg>iOS script: enforce bitcode for tvOS<commit_after>#!/bin/sh
set -e

PLATFORM=OS
VERBOSE=no
DEBUG=no
SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
SDK_MIN=7.0
SIXTYFOURBIT_SDK_MIN=7.0
ARCH=armv7
SCARY=yes
TVOS=no
OSSTYLE=iPhone
OSVERSIONMINCFLAG=miphoneos-version-min
OSVERSIONMINLDFLAG=ios_version_min

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

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

OPTIONS
   -k <sdk version>      Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
   -s            Build for simulator
   -a <arch>     Specify which arch to use (current: ${ARCH})
   -d            Enable debug
   -v            Enable verbose command-line output
   -t            Build for tvOS
   -w            Build a limited stack of non-scary libraries only
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 "hvwdstk:a:" OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         v)
             VERBOSE=yes
             ;;
         s)
             PLATFORM=Simulator
             ;;
         d)
             DEBUG=yes
             ;;
         w)
             SCARY=no
             ;;
         k)
             SDK_VERSION=$OPTARG
             ;;
         a)
             ARCH=$OPTARG
             ;;
         t)
             TVOS=yes
             SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
             OSVERSIONMINCFLAG=mtvos-version-min
             OSVERSIONMINLDFLAG=tvos_version_min
             SIXTYFOURBIT_SDK_MIN=9.0
             ;;
         ?)
             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 iOS"

TARGET="${ARCH}-apple-darwin11"

# apple doesn't call AArch64 that way, but arm64 (a contrario to all libraries)
# so we need to translate it..
if [ "$ARCH" = "aarch64" ]; then
	ACTUAL_ARCH="arm64"
else
	ACTUAL_ARCH="$ARCH"
fi

if [ "$DEBUG" = "yes" ]; then
    OPTIM="-O0 -g"
else
    OPTIM="-O3 -g"
fi

if [ "$TVOS" = "yes" ]; then
	OSSTYLE=AppleTV
	export BUILDFORTVOS="yes"
fi
export BUILDFORIOS="yes"

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/${OSSTYLE}${PLATFORM}.platform/Developer/SDKs/${OSSTYLE}${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-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
PREFIX="${VLCROOT}/install-ios-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"

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

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

info "Building contrib for iOS in '${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}'"

# 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 PLATFORM=$PLATFORM
export SDK_VERSION=$SDK_VERSION
export VLCSDKROOT=$SDKROOT

CFLAGS="-isysroot ${SDKROOT} -arch ${ACTUAL_ARCH} ${OPTIM}"

if [ "$PLATFORM" = "OS" ]; then
if [ "$ARCH" != "aarch64" ]; then
CFLAGS+=" -mcpu=cortex-a8 -${OSVERSIONMINCFLAG}=${SDK_MIN}"
else
CFLAGS+=" -${OSVERSIONMINCFLAG}=${SIXTYFOURBIT_SDK_MIN}"
fi
else
CFLAGS+=" -${OSVERSIONMINCFLAG}=${SIXTYFOURBIT_SDK_MIN}"
fi

if [ "$TVOS" = "yes" ]; then
CFLAGS+=" -fembed-bitcode"
fi

export CFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS}"
{'fraction_non_alphanumeric': 0.15096633037559257, 'fraction_numerical': 0.011911997082776224, 'mean_word_length': 2.7451069640418755, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5972889', 'n_tokens_mistral': 3208, 'n_tokens_neox': 3014, 'n_words': 701}