build-scripts/naclbuild.sh
author Sam Lantinga <slouken@libsdl.org>
Sun, 17 Aug 2014 14:57:52 -0700
changeset 9086 c5e33f9a0d03
parent 8880 ee5117b56b93
permissions -rwxr-xr-x
Fixed bug 2655 - OSX: Window position and global mouse coord spaces are different

Tim McDaniel

On OSX, with revision 8729, the coordinate space for window position and the coordinate space for global mouse position don't match. For a non-fullscreen window, the window position is global relative to the bottom of the menubar. The global mouse position is relative to the top of the screen. This affects Cocoa_WarpMouse and potentially other things as well. Further, the coordinate system for window position is now affected by what screen it is on. For example, if I have two equal size screens oriented side by side such that the tops of the screens are equal in global space, with the menubar on one screen, and a window straddles the two screens, the window's y position makes no sense. The window's y position depends on what screen "most" of the window is on. So if I move the window horizontally just a bit, the y position of my window is now different by the size of the menubar, even though the window was not moved vertically.

I'd like to reiterate that this was a fairly fundamental change (and a breaking change for us). If SDL OSX is to really support multi-display configurations, this is especially problematic.

If the real concern is preventing windows from going under the menubar, then perhaps a solution involving something like overriding [NSWindow constrainFrameRect] would be less problematic than redefining the global window coord space for the main display.
     1 #!/bin/bash
     2 if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then
     3     echo "Usage: ./naclbuild ~/nacl/pepper_35"
     4     echo "This will build SDL for Native Client, and testgles2.c as a demo"
     5     echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used"
     6     echo "You can set env var SOURCES to select a different source file than testgles2.c"
     7     exit 1
     8 fi
     9 
    10 if [ -n "$1" ]; then
    11     NACL_SDK_ROOT="$1"
    12 fi
    13 
    14 CC=""
    15 
    16 if [ -n "$2" ]; then
    17     CC="$2"
    18 fi
    19 
    20 echo "Using SDK at $NACL_SDK_ROOT"
    21 
    22 export NACL_SDK_ROOT="$NACL_SDK_ROOT"
    23 export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
    24 
    25 NCPUS="1"
    26 case "$OSTYPE" in
    27     darwin*)
    28         NCPU=`sysctl -n hw.ncpu`
    29         ;; 
    30     linux*)
    31         if [ -n `which nproc` ]; then
    32             NCPUS=`nproc`
    33         fi  
    34         ;;
    35   *);;
    36 esac
    37 
    38 CURDIR=`pwd -P`
    39 SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
    40 BUILDPATH="$SDLPATH/build/nacl"
    41 TESTBUILDPATH="$BUILDPATH/test"
    42 SDL2_STATIC="$BUILDPATH/build/.libs/libSDL2.a"
    43 mkdir -p $BUILDPATH
    44 mkdir -p $TESTBUILDPATH
    45 
    46 if [ -z "$CC" ]; then
    47     export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
    48 fi
    49 if [ -z "$AR" ]; then
    50     export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
    51 fi
    52 if [ -z "$LD" ]; then
    53     export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
    54 fi
    55 if [ -z "$RANLIB" ]; then
    56     export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
    57 fi
    58 
    59 if [ -z "$SOURCES" ]; then
    60     export SOURCES="$SDLPATH/test/testgles2.c"
    61 fi
    62 
    63 if [ ! -f "$CC" ]; then
    64     echo "Could not find compiler at $CC"
    65     exit 1
    66 fi
    67 
    68 
    69 
    70 
    71 cd $BUILDPATH
    72 $SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH
    73 make -j$NCPUS CFLAGS="$CFLAGS -I./include"
    74 make install
    75 
    76 if [ ! -f "$SDL2_STATIC" ]; then
    77     echo "Build failed! $SDL2_STATIC"
    78     exit 1
    79 fi
    80 
    81 echo "Building test"
    82 cp -f $SDLPATH/test/nacl/* $TESTBUILDPATH
    83 # Some tests need these resource files
    84 cp -f $SDLPATH/test/*.bmp $TESTBUILDPATH
    85 cp -f $SDLPATH/test/*.wav $TESTBUILDPATH
    86 cp -f $SDL2_STATIC $TESTBUILDPATH
    87 
    88 # Copy user sources
    89 _SOURCES=($SOURCES)
    90 for src in "${_SOURCES[@]}"
    91 do
    92     cp $src $TESTBUILDPATH
    93 done
    94 export SOURCES="$SOURCES"
    95 
    96 cd $TESTBUILDPATH
    97 make -j$NCPUS CONFIG="Release" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
    98 make -j$NCPUS CONFIG="Debug" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
    99 
   100 echo
   101 echo "Run the test with: "
   102 echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer"
   103 echo "Then visit http://localhost:8000 with Chrome"
   104 
   105 cd $CURDIR