Chrome's Native Client backend implementation

This commit is contained in:
Gabriel Jacobo 2014-06-06 15:45:59 -03:00
parent 04a0836b1a
commit 1e352d7929
37 changed files with 2265 additions and 10 deletions

View file

@ -359,6 +359,19 @@ case $basic_machine in
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
nacl64*)
basic_machine=x86_64-pc
os=-nacl
;;
nacl*)
basic_machine=i686-pc
os=-nacl
;;
pnacl*)
# le32-unknown-pnacl comes from http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
basic_machine=le32-unknown
os=-pnacl
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
@ -843,6 +856,10 @@ case $basic_machine in
basic_machine=le32-unknown
os=-nacl
;;
pnacl)
basic_machine=le32-unknown
os=-pnacl
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
@ -1384,6 +1401,12 @@ case $os in
;;
esac
;;
-nacl*)
os=-nacl
;;
-pnacl*)
os=-pnacl
;;
-nto-qnx*)
;;
-nto*)
@ -1506,6 +1529,10 @@ case $os in
os=-dicos
;;
-nacl*)
os=-nacl
;;
-pnacl*)
os=-pnacl
;;
-none)
;;

105
build-scripts/naclbuild.sh Normal file
View file

@ -0,0 +1,105 @@
#!/bin/bash
if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then
echo "Usage: ./naclbuild ~/nacl/pepper_33"
echo "This will build SDL for Native Client, and testgles2.c as a demo"
echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used"
echo "You can set env var SOURCES to select a different source file than testgles2.c"
exit 1
fi
if [ -n "$1" ]; then
NACL_SDK_ROOT="$1"
fi
CC=""
if [ -n "$2" ]; then
CC="$2"
fi
echo "Using SDK at $NACL_SDK_ROOT"
export NACL_SDK_ROOT="$NACL_SDK_ROOT"
export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include"
NCPUS="1"
case "$OSTYPE" in
darwin*)
NCPU=`sysctl -n hw.ncpu`
;;
linux*)
if [ -n `which nproc` ]; then
NCPUS=`nproc`
fi
;;
*);;
esac
CURDIR=`pwd -P`
SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
BUILDPATH="$SDLPATH/build/nacl"
TESTBUILDPATH="$BUILDPATH/test"
SDL2_STATIC="$BUILDPATH/build/.libs/libSDL2.a"
mkdir -p $BUILDPATH
mkdir -p $TESTBUILDPATH
if [ -z "$CC" ]; then
export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
fi
if [ -z "$AR" ]; then
export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
fi
if [ -z "$LD" ]; then
export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
fi
if [ -z "$RANLIB" ]; then
export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
fi
if [ -z "$SOURCES" ]; then
export SOURCES="$SDLPATH/test/testgles2.c"
fi
if [ ! -f "$CC" ]; then
echo "Could not find compiler at $CC"
exit 1
fi
cd $BUILDPATH
$SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH
make -j$NCPUS CFLAGS="$CFLAGS -I./include"
make install
if [ ! -f "$SDL2_STATIC" ]; then
echo "Build failed! $SDL2_STATIC"
exit 1
fi
echo "Building test"
cp -f $SDLPATH/test/nacl/* $TESTBUILDPATH
# Some tests need these resource files
cp -f $SDLPATH/test/*.bmp $TESTBUILDPATH
cp -f $SDLPATH/test/*.wav $TESTBUILDPATH
cp -f $SDL2_STATIC $TESTBUILDPATH
# Copy user sources
_SOURCES=($SOURCES)
for src in "${_SOURCES[@]}"
do
cp $src $TESTBUILDPATH
done
export SOURCES="$SOURCES"
cd $TESTBUILDPATH
make -j$NCPUS CONFIG="Release" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
make -j$NCPUS CONFIG="Debug" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
echo
echo "Run the test with: "
echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer"
echo "Then visit http://localhost:8000 with Chrome"
cd $CURDIR