build-scripts/iosbuild.sh
author Sam Lantinga <slouken@libsdl.org>
Thu, 12 Oct 2017 14:25:07 -0700
changeset 11615 f5b657276413
parent 10904 4dbd025c4eb9
permissions -rwxr-xr-x
Fixed bug 3877 - missing SDLCALL in SDLTest_ExampleHitTestCallback

Ozkan Sezer

Following trivial patch adds missing SDLCALL to SDLTest_ExampleHitTestCallback()
gabomdq@6333
     1
#!/bin/sh
gabomdq@6333
     2
#
gabomdq@6333
     3
# Build a fat binary for iOS
gabomdq@6333
     4
gabomdq@6333
     5
# Number of CPUs (for make -j)
gabomdq@6333
     6
NCPU=`sysctl -n hw.ncpu`
gabomdq@6333
     7
if test x$NJOB = x; then
gabomdq@6333
     8
    NJOB=$NCPU
gabomdq@6333
     9
fi
gabomdq@6333
    10
slouken@10904
    11
SRC_DIR=$(cd `dirname $0`/..; pwd)
slouken@10904
    12
if [ "$PWD" = "$SRC_DIR" ]; then
slouken@10904
    13
    PREFIX=$SRC_DIR/ios-build
slouken@10904
    14
    mkdir $PREFIX
slouken@10904
    15
else
slouken@10904
    16
    PREFIX=$PWD
gabomdq@6333
    17
fi
gabomdq@6333
    18
slouken@10904
    19
BUILD_I386_IOSSIM=YES
slouken@10904
    20
BUILD_X86_64_IOSSIM=YES
gabomdq@6333
    21
slouken@10904
    22
BUILD_IOS_ARMV7=YES
slouken@10904
    23
BUILD_IOS_ARMV7S=YES
slouken@10904
    24
BUILD_IOS_ARM64=YES
gabomdq@6333
    25
slouken@10904
    26
# 13.4.0 - Mavericks
slouken@10904
    27
# 14.0.0 - Yosemite
slouken@10904
    28
# 15.0.0 - El Capitan
slouken@10904
    29
DARWIN=darwin15.0.0
gabomdq@6333
    30
slouken@10904
    31
XCODEDIR=`xcode-select --print-path`
slouken@10904
    32
IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
slouken@10904
    33
MIN_SDK_VERSION=6.0
gabomdq@6333
    34
slouken@10904
    35
IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
slouken@10904
    36
IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
gabomdq@6333
    37
slouken@10904
    38
IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
slouken@10904
    39
IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
gabomdq@6333
    40
slouken@10904
    41
# Uncomment if you want to see more information about each invocation
slouken@10904
    42
# of clang as the builds proceed.
slouken@10904
    43
# CLANG_VERBOSE="--verbose"
gabomdq@6333
    44
slouken@10904
    45
CC=clang
slouken@10904
    46
CXX=clang
slouken@10904
    47
slouken@10904
    48
SILENCED_WARNINGS="-Wno-unused-local-typedef -Wno-unused-function"
slouken@10904
    49
slouken@10904
    50
CFLAGS="${CLANG_VERBOSE} ${SILENCED_WARNINGS} -DNDEBUG -g -O0 -pipe -fPIC -fobjc-arc"
slouken@10904
    51
slouken@10904
    52
echo "PREFIX ..................... ${PREFIX}"
slouken@10904
    53
echo "BUILD_MACOSX_X86_64 ........ ${BUILD_MACOSX_X86_64}"
slouken@10904
    54
echo "BUILD_I386_IOSSIM .......... ${BUILD_I386_IOSSIM}"
slouken@10904
    55
echo "BUILD_X86_64_IOSSIM ........ ${BUILD_X86_64_IOSSIM}"
slouken@10904
    56
echo "BUILD_IOS_ARMV7 ............ ${BUILD_IOS_ARMV7}"
slouken@10904
    57
echo "BUILD_IOS_ARMV7S ........... ${BUILD_IOS_ARMV7S}"
slouken@10904
    58
echo "BUILD_IOS_ARM64 ............ ${BUILD_IOS_ARM64}"
slouken@10904
    59
echo "DARWIN ..................... ${DARWIN}"
slouken@10904
    60
echo "XCODEDIR ................... ${XCODEDIR}"
slouken@10904
    61
echo "IOS_SDK_VERSION ............ ${IOS_SDK_VERSION}"
slouken@10904
    62
echo "MIN_SDK_VERSION ............ ${MIN_SDK_VERSION}"
slouken@10904
    63
echo "IPHONEOS_PLATFORM .......... ${IPHONEOS_PLATFORM}"
slouken@10904
    64
echo "IPHONEOS_SYSROOT ........... ${IPHONEOS_SYSROOT}"
slouken@10904
    65
echo "IPHONESIMULATOR_PLATFORM ... ${IPHONESIMULATOR_PLATFORM}"
slouken@10904
    66
echo "IPHONESIMULATOR_SYSROOT .... ${IPHONESIMULATOR_SYSROOT}"
slouken@10904
    67
echo "CC ......................... ${CC}"
slouken@10904
    68
echo "CFLAGS ..................... ${CFLAGS}"
slouken@10904
    69
echo "CXX ........................ ${CXX}"
slouken@10904
    70
echo "CXXFLAGS ................... ${CXXFLAGS}"
slouken@10904
    71
echo "LDFLAGS .................... ${LDFLAGS}"
slouken@10904
    72
slouken@10904
    73
###################################################################
slouken@10904
    74
# This section contains the build commands for each of the 
slouken@10904
    75
# architectures that will be included in the universal binaries.
slouken@10904
    76
###################################################################
slouken@10904
    77
slouken@10904
    78
echo "$(tput setaf 2)"
slouken@10904
    79
echo "###########################"
slouken@10904
    80
echo "# i386 for iPhone Simulator"
slouken@10904
    81
echo "###########################"
slouken@10904
    82
echo "$(tput sgr0)"
slouken@10904
    83
slouken@10904
    84
if [ "${BUILD_I386_IOSSIM}" == "YES" ]
slouken@10904
    85
then
slouken@10904
    86
    (
slouken@10904
    87
        cd ${PREFIX}
slouken@10904
    88
        make clean
slouken@10904
    89
        ../configure --build=x86_64-apple-${DARWIN} --host=i386-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/i386-sim "CC=${CC}" "CFLAGS=${CFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch i386 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch i386 -mios-simulator-version-min=${MIN_SDK_VERSION} ${LDFLAGS} -L${IPHONESIMULATOR_SYSROOT}/usr/lib/ -L${IPHONESIMULATOR_SYSROOT}/usr/lib/system" || exit 2
slouken@10904
    90
	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
slouken@10904
    91
        make -j10 || exit 3
slouken@10904
    92
        make install
slouken@10904
    93
    ) || exit $?
gabomdq@6333
    94
fi
gabomdq@6333
    95
slouken@10904
    96
echo "$(tput setaf 2)"
slouken@10904
    97
echo "#############################"
slouken@10904
    98
echo "# x86_64 for iPhone Simulator"
slouken@10904
    99
echo "#############################"
slouken@10904
   100
echo "$(tput sgr0)"
slouken@10904
   101
slouken@10904
   102
if [ "${BUILD_X86_64_IOSSIM}" == "YES" ]
slouken@10904
   103
then
slouken@10904
   104
    (
slouken@10904
   105
        cd ${PREFIX}
slouken@10904
   106
        make clean
slouken@10904
   107
        ../configure --build=x86_64-apple-${DARWIN} --host=x86_64-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/x86_64-sim "CC=${CC}" "CFLAGS=${CFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch x86_64 -isysroot ${IPHONESIMULATOR_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -mios-simulator-version-min=${MIN_SDK_VERSION} -arch x86_64 -isysroot ${IPHONESIMULATOR_SYSROOT}" LDFLAGS="-arch x86_64 -mios-simulator-version-min=${MIN_SDK_VERSION} ${LDFLAGS} -L${IPHONESIMULATOR_SYSROOT}/usr/lib/ -L${IPHONESIMULATOR_SYSROOT}/usr/lib/system" || exit 2
slouken@10904
   108
	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
slouken@10904
   109
        make -j$NJOB || exit 3
slouken@10904
   110
        make install
slouken@10904
   111
    ) || exit $?
gabomdq@6333
   112
fi
gabomdq@6333
   113
slouken@10904
   114
echo "$(tput setaf 2)"
slouken@10904
   115
echo "##################"
slouken@10904
   116
echo "# armv7 for iPhone"
slouken@10904
   117
echo "##################"
slouken@10904
   118
echo "$(tput sgr0)"
slouken@10904
   119
slouken@10904
   120
if [ "${BUILD_IOS_ARMV7}" == "YES" ]
slouken@10904
   121
then
slouken@10904
   122
    (
slouken@10904
   123
        cd ${PREFIX}
slouken@10904
   124
        make clean
slouken@10904
   125
        ../configure --build=x86_64-apple-${DARWIN} --host=armv7-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/armv7-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -arch armv7 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" || exit 2
slouken@10904
   126
	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
slouken@10904
   127
        make -j$NJOB || exit 3
slouken@10904
   128
        make install
slouken@10904
   129
    ) || exit $?
gabomdq@6333
   130
fi
slouken@10904
   131
slouken@10904
   132
echo "$(tput setaf 2)"
slouken@10904
   133
echo "###################"
slouken@10904
   134
echo "# armv7s for iPhone"
slouken@10904
   135
echo "###################"
slouken@10904
   136
echo "$(tput sgr0)"
slouken@10904
   137
slouken@10904
   138
if [ "${BUILD_IOS_ARMV7S}" == "YES" ]
slouken@10904
   139
then
slouken@10904
   140
    (
slouken@10904
   141
        cd ${PREFIX}
slouken@10904
   142
        make clean
slouken@10904
   143
        ../configure --build=x86_64-apple-${DARWIN} --host=armv7s-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/armv7s-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch armv7s -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch armv7s -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" || exit 2
slouken@10904
   144
	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
slouken@10904
   145
        make -j$NJOB || exit 3
slouken@10904
   146
        make install
slouken@10904
   147
    ) || exit $?
gabomdq@6333
   148
fi
slouken@10904
   149
slouken@10904
   150
echo "$(tput setaf 2)"
slouken@10904
   151
echo "##################"
slouken@10904
   152
echo "# arm64 for iPhone"
slouken@10904
   153
echo "##################"
slouken@10904
   154
echo "$(tput sgr0)"
slouken@10904
   155
slouken@10904
   156
if [ "${BUILD_IOS_ARM64}" == "YES" ]
slouken@10904
   157
then
slouken@10904
   158
    (
slouken@10904
   159
        cd ${PREFIX}
slouken@10904
   160
        make clean
slouken@10904
   161
        ../configure --build=x86_64-apple-${DARWIN} --host=arm-ios-${DARWIN} --disable-shared --prefix=${PREFIX}/platform/arm64-ios "CC=${CC}" "CFLAGS=${CFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch arm64 -isysroot ${IPHONEOS_SYSROOT}" "CXX=${CXX}" "CXXFLAGS=${CXXFLAGS} -miphoneos-version-min=${MIN_SDK_VERSION} -arch arm64 -isysroot ${IPHONEOS_SYSROOT}" LDFLAGS="-arch arm64 -miphoneos-version-min=${MIN_SDK_VERSION} ${LDFLAGS}" || exit 2
slouken@10904
   162
	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
slouken@10904
   163
        make -j$NJOB || exit 3
slouken@10904
   164
        make install
slouken@10904
   165
    ) || exit $?
gabomdq@6333
   166
fi
slouken@10904
   167
slouken@10904
   168
echo "$(tput setaf 2)"
slouken@10904
   169
echo "###################################################################"
slouken@10904
   170
echo "# Create Universal Libraries and Finalize the packaging"
slouken@10904
   171
echo "###################################################################"
slouken@10904
   172
echo "$(tput sgr0)"
slouken@10904
   173
slouken@10904
   174
(
slouken@10904
   175
    cd ${PREFIX}/platform
slouken@10904
   176
    mkdir -p universal
slouken@10904
   177
    lipo x86_64-sim/lib/libSDL2.a i386-sim/lib/libSDL2.a arm64-ios/lib/libSDL2.a armv7s-ios/lib/libSDL2.a armv7-ios/lib/libSDL2.a -create -output universal/libSDL2.a
slouken@10904
   178
)
slouken@10904
   179
slouken@10904
   180
(
slouken@10904
   181
    cd ${PREFIX}
slouken@10904
   182
    mkdir -p lib
slouken@10904
   183
    cp -r platform/universal/* lib
slouken@10904
   184
    #rm -rf platform
slouken@10904
   185
    lipo -info lib/libSDL2.a
slouken@10904
   186
)
slouken@10904
   187
slouken@10904
   188
echo Done!