build-scripts/iosbuild.sh
author Ryan C. Gordon
Mon, 21 Aug 2017 00:42:06 -0400
changeset 11334 749cb40916f2
parent 10904 4dbd025c4eb9
child 13861 fe24019c4791
permissions -rwxr-xr-x
x11: specify event mask for buttons when grabbing pointer (thanks, Stas!).

This fixes a strange corner case (notes appended below), and should be
safe to do anyhow.

Fixes Bugzilla #3674.

"I did more tests.
It appears the bug only happens if there is
another window on the screen that has "always
on top" property. For me it is xawtv - it is
always opened in a screen corner. Closing
xawtv or removing "always on top" property
from it makes the problem to go away.
Plus, it doesn't appear like the buttons are
not delivered at all. It appears that instead
the button presses are delivered on some mouse
positions, but not delivered when you move the
mouse to other part of the window... So this is
really weird and is likely somewhere deep in the
Xorg.
Maybe somehow it happens that the cursor is
actually above the xawtv window, but, because
my app uses grab, it is not visible there, and
in that case the events are not delivered to
my app?
But with my patch the button events are
always delivered flawlessly, it seems.

Hmm, and that indeed seems to explain my problem:
if the mask is set properly and my app uses
grab, then, even if the mouse is above some
other window, the events would still be delivered
to the grabbing app, which is what actually wanted
because my app uses relative mouse mode, so it
doesn't know the pointer can cross some other window
(my app draws the pointer itself).
So my current theory is that my patch only enforces
the mouse grab, which otherwise can be tricked by
some other window preventing the button events
delivery (but motion events are still delivered
via xinput2, which makes it all look very obscure)."
     1 #!/bin/sh
     2 #
     3 # Build a fat binary for iOS
     4 
     5 # Number of CPUs (for make -j)
     6 NCPU=`sysctl -n hw.ncpu`
     7 if test x$NJOB = x; then
     8     NJOB=$NCPU
     9 fi
    10 
    11 SRC_DIR=$(cd `dirname $0`/..; pwd)
    12 if [ "$PWD" = "$SRC_DIR" ]; then
    13     PREFIX=$SRC_DIR/ios-build
    14     mkdir $PREFIX
    15 else
    16     PREFIX=$PWD
    17 fi
    18 
    19 BUILD_I386_IOSSIM=YES
    20 BUILD_X86_64_IOSSIM=YES
    21 
    22 BUILD_IOS_ARMV7=YES
    23 BUILD_IOS_ARMV7S=YES
    24 BUILD_IOS_ARM64=YES
    25 
    26 # 13.4.0 - Mavericks
    27 # 14.0.0 - Yosemite
    28 # 15.0.0 - El Capitan
    29 DARWIN=darwin15.0.0
    30 
    31 XCODEDIR=`xcode-select --print-path`
    32 IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
    33 MIN_SDK_VERSION=6.0
    34 
    35 IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
    36 IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
    37 
    38 IPHONESIMULATOR_PLATFORM=`xcrun --sdk iphonesimulator --show-sdk-platform-path`
    39 IPHONESIMULATOR_SYSROOT=`xcrun --sdk iphonesimulator --show-sdk-path`
    40 
    41 # Uncomment if you want to see more information about each invocation
    42 # of clang as the builds proceed.
    43 # CLANG_VERBOSE="--verbose"
    44 
    45 CC=clang
    46 CXX=clang
    47 
    48 SILENCED_WARNINGS="-Wno-unused-local-typedef -Wno-unused-function"
    49 
    50 CFLAGS="${CLANG_VERBOSE} ${SILENCED_WARNINGS} -DNDEBUG -g -O0 -pipe -fPIC -fobjc-arc"
    51 
    52 echo "PREFIX ..................... ${PREFIX}"
    53 echo "BUILD_MACOSX_X86_64 ........ ${BUILD_MACOSX_X86_64}"
    54 echo "BUILD_I386_IOSSIM .......... ${BUILD_I386_IOSSIM}"
    55 echo "BUILD_X86_64_IOSSIM ........ ${BUILD_X86_64_IOSSIM}"
    56 echo "BUILD_IOS_ARMV7 ............ ${BUILD_IOS_ARMV7}"
    57 echo "BUILD_IOS_ARMV7S ........... ${BUILD_IOS_ARMV7S}"
    58 echo "BUILD_IOS_ARM64 ............ ${BUILD_IOS_ARM64}"
    59 echo "DARWIN ..................... ${DARWIN}"
    60 echo "XCODEDIR ................... ${XCODEDIR}"
    61 echo "IOS_SDK_VERSION ............ ${IOS_SDK_VERSION}"
    62 echo "MIN_SDK_VERSION ............ ${MIN_SDK_VERSION}"
    63 echo "IPHONEOS_PLATFORM .......... ${IPHONEOS_PLATFORM}"
    64 echo "IPHONEOS_SYSROOT ........... ${IPHONEOS_SYSROOT}"
    65 echo "IPHONESIMULATOR_PLATFORM ... ${IPHONESIMULATOR_PLATFORM}"
    66 echo "IPHONESIMULATOR_SYSROOT .... ${IPHONESIMULATOR_SYSROOT}"
    67 echo "CC ......................... ${CC}"
    68 echo "CFLAGS ..................... ${CFLAGS}"
    69 echo "CXX ........................ ${CXX}"
    70 echo "CXXFLAGS ................... ${CXXFLAGS}"
    71 echo "LDFLAGS .................... ${LDFLAGS}"
    72 
    73 ###################################################################
    74 # This section contains the build commands for each of the 
    75 # architectures that will be included in the universal binaries.
    76 ###################################################################
    77 
    78 echo "$(tput setaf 2)"
    79 echo "###########################"
    80 echo "# i386 for iPhone Simulator"
    81 echo "###########################"
    82 echo "$(tput sgr0)"
    83 
    84 if [ "${BUILD_I386_IOSSIM}" == "YES" ]
    85 then
    86     (
    87         cd ${PREFIX}
    88         make clean
    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
    90 	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
    91         make -j10 || exit 3
    92         make install
    93     ) || exit $?
    94 fi
    95 
    96 echo "$(tput setaf 2)"
    97 echo "#############################"
    98 echo "# x86_64 for iPhone Simulator"
    99 echo "#############################"
   100 echo "$(tput sgr0)"
   101 
   102 if [ "${BUILD_X86_64_IOSSIM}" == "YES" ]
   103 then
   104     (
   105         cd ${PREFIX}
   106         make clean
   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
   108 	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   109         make -j$NJOB || exit 3
   110         make install
   111     ) || exit $?
   112 fi
   113 
   114 echo "$(tput setaf 2)"
   115 echo "##################"
   116 echo "# armv7 for iPhone"
   117 echo "##################"
   118 echo "$(tput sgr0)"
   119 
   120 if [ "${BUILD_IOS_ARMV7}" == "YES" ]
   121 then
   122     (
   123         cd ${PREFIX}
   124         make clean
   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
   126 	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   127         make -j$NJOB || exit 3
   128         make install
   129     ) || exit $?
   130 fi
   131 
   132 echo "$(tput setaf 2)"
   133 echo "###################"
   134 echo "# armv7s for iPhone"
   135 echo "###################"
   136 echo "$(tput sgr0)"
   137 
   138 if [ "${BUILD_IOS_ARMV7S}" == "YES" ]
   139 then
   140     (
   141         cd ${PREFIX}
   142         make clean
   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
   144 	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   145         make -j$NJOB || exit 3
   146         make install
   147     ) || exit $?
   148 fi
   149 
   150 echo "$(tput setaf 2)"
   151 echo "##################"
   152 echo "# arm64 for iPhone"
   153 echo "##################"
   154 echo "$(tput sgr0)"
   155 
   156 if [ "${BUILD_IOS_ARM64}" == "YES" ]
   157 then
   158     (
   159         cd ${PREFIX}
   160         make clean
   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
   162 	cp $SRC_DIR/include/SDL_config_iphoneos.h include/SDL_config.h
   163         make -j$NJOB || exit 3
   164         make install
   165     ) || exit $?
   166 fi
   167 
   168 echo "$(tput setaf 2)"
   169 echo "###################################################################"
   170 echo "# Create Universal Libraries and Finalize the packaging"
   171 echo "###################################################################"
   172 echo "$(tput sgr0)"
   173 
   174 (
   175     cd ${PREFIX}/platform
   176     mkdir -p universal
   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
   178 )
   179 
   180 (
   181     cd ${PREFIX}
   182     mkdir -p lib
   183     cp -r platform/universal/* lib
   184     #rm -rf platform
   185     lipo -info lib/libSDL2.a
   186 )
   187 
   188 echo Done!