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