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"
20 echo "Using SDK at $NACL_SDK_ROOT"
22 export NACL_SDK_ROOT="$NACL_SDK_ROOT"
23 export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
28 NCPU=`sysctl -n hw.ncpu`
31 if [ -n `which nproc` ]; then
39 SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
40 BUILDPATH="$SDLPATH/build/nacl"
41 TESTBUILDPATH="$BUILDPATH/test"
42 SDL2_STATIC="$BUILDPATH/build/.libs/libSDL2.a"
44 mkdir -p $TESTBUILDPATH
47 export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
50 export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
53 export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
55 if [ -z "$RANLIB" ]; then
56 export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
59 if [ -z "$SOURCES" ]; then
60 export SOURCES="$SDLPATH/test/testgles2.c"
63 if [ ! -f "$CC" ]; then
64 echo "Could not find compiler at $CC"
72 $SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH
73 make -j$NCPUS CFLAGS="$CFLAGS -I./include"
76 if [ ! -f "$SDL2_STATIC" ]; then
77 echo "Build failed! $SDL2_STATIC"
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
90 for src in "${_SOURCES[@]}"
92 cp $src $TESTBUILDPATH
94 export SOURCES="$SOURCES"
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"
101 echo "Run the test with: "
102 echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer"
103 echo "Then visit http://localhost:8000 with Chrome"