🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.5 KiB

  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. if [ -n "$1" ]; then
  10. NACL_SDK_ROOT="$1"
  11. fi
  12. CC=""
  13. if [ -n "$2" ]; then
  14. CC="$2"
  15. fi
  16. echo "Using SDK at $NACL_SDK_ROOT"
  17. export NACL_SDK_ROOT="$NACL_SDK_ROOT"
  18. export CFLAGS="$CFLAGS -I$NACL_SDK_ROOT/include -I$NACL_SDK_ROOT/include/pnacl"
  19. NCPUS="1"
  20. case "$OSTYPE" in
  21. darwin*)
  22. NCPU=`sysctl -n hw.ncpu`
  23. ;;
  24. linux*)
  25. if [ -n `which nproc` ]; then
  26. NCPUS=`nproc`
  27. fi
  28. ;;
  29. *);;
  30. esac
  31. CURDIR=`pwd -P`
  32. SDLPATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
  33. BUILDPATH="$SDLPATH/build/nacl"
  34. TESTBUILDPATH="$BUILDPATH/test"
  35. SDL2_STATIC="$BUILDPATH/build/.libs/libSDL2.a"
  36. mkdir -p $BUILDPATH
  37. mkdir -p $TESTBUILDPATH
  38. if [ -z "$CC" ]; then
  39. export CC="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-clang"
  40. fi
  41. if [ -z "$AR" ]; then
  42. export AR="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
  43. fi
  44. if [ -z "$LD" ]; then
  45. export LD="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ar"
  46. fi
  47. if [ -z "$RANLIB" ]; then
  48. export RANLIB="$NACL_SDK_ROOT/toolchain/linux_pnacl/bin/pnacl-ranlib"
  49. fi
  50. if [ -z "$SOURCES" ]; then
  51. export SOURCES="$SDLPATH/test/testgles2.c"
  52. fi
  53. if [ ! -f "$CC" ]; then
  54. echo "Could not find compiler at $CC"
  55. exit 1
  56. fi
  57. cd $BUILDPATH
  58. $SDLPATH/configure --host=pnacl --prefix $TESTBUILDPATH
  59. make -j$NCPUS CFLAGS="$CFLAGS -I./include"
  60. make install
  61. if [ ! -f "$SDL2_STATIC" ]; then
  62. echo "Build failed! $SDL2_STATIC"
  63. exit 1
  64. fi
  65. echo "Building test"
  66. cp -f $SDLPATH/test/nacl/* $TESTBUILDPATH
  67. # Some tests need these resource files
  68. cp -f $SDLPATH/test/*.bmp $TESTBUILDPATH
  69. cp -f $SDLPATH/test/*.wav $TESTBUILDPATH
  70. cp -f $SDL2_STATIC $TESTBUILDPATH
  71. # Copy user sources
  72. _SOURCES=($SOURCES)
  73. for src in "${_SOURCES[@]}"
  74. do
  75. cp $src $TESTBUILDPATH
  76. done
  77. export SOURCES="$SOURCES"
  78. cd $TESTBUILDPATH
  79. make -j$NCPUS CONFIG="Release" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
  80. make -j$NCPUS CONFIG="Debug" CFLAGS="$CFLAGS -I$TESTBUILDPATH/include/SDL2 -I$SDLPATH/include"
  81. echo
  82. echo "Run the test with: "
  83. echo "cd $TESTBUILDPATH;python -m SimpleHTTPServer"
  84. echo "Then visit http://localhost:8000 with Chrome"
  85. cd $CURDIR