update-workspaces.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/sh
  2. # Check for whitespace in absolute path; this will cause problems in the
  3. # SpiderMonkey build (https://bugzilla.mozilla.org/show_bug.cgi?id=459089)
  4. # and maybe elsewhere, so we just forbid it
  5. # Use perl as an alternative to readlink -f, which isn't available on BSD or OS X
  6. SCRIPTPATH=`perl -MCwd -e 'print Cwd::abs_path shift' "$0"`
  7. case "$SCRIPTPATH" in
  8. *\ * )
  9. die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;;
  10. esac
  11. JOBS=${JOBS:="-j2"}
  12. # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE
  13. # is not set.
  14. case "`uname -s`" in
  15. "FreeBSD" | "OpenBSD" )
  16. MAKE=${MAKE:="gmake"}
  17. ;;
  18. * )
  19. MAKE=${MAKE:="make"}
  20. ;;
  21. esac
  22. # Parse command-line options:
  23. premake_args=""
  24. without_nvtt=false
  25. with_system_nvtt=false
  26. with_system_mozjs38=false
  27. enable_atlas=true
  28. for i in "$@"
  29. do
  30. case $i in
  31. --without-nvtt ) without_nvtt=true; premake_args="${premake_args} --without-nvtt" ;;
  32. --with-system-nvtt ) with_system_nvtt=true; premake_args="${premake_args} --with-system-nvtt" ;;
  33. --with-system-mozjs38 ) with_system_mozjs38=true; premake_args="${premake_args} --with-system-mozjs38" ;;
  34. --enable-atlas ) enable_atlas=true ;;
  35. --disable-atlas ) enable_atlas=false ;;
  36. -j* ) JOBS=$i ;;
  37. # Assume any other --options are for Premake
  38. --* ) premake_args="${premake_args} $i" ;;
  39. esac
  40. done
  41. premake_args="${premake_args} --collada"
  42. if [ "$enable_atlas" = "true" ]; then
  43. premake_args="${premake_args} --atlas"
  44. fi
  45. cd "$(dirname $0)"
  46. # Now in build/workspaces/ (where we assume this script resides)
  47. if [ "`uname -s`" = "Darwin" ]; then
  48. # Set *_CONFIG variables on OS X, to override the path to e.g. sdl2-config
  49. export GLOOX_CONFIG=${GLOOX_CONFIG:="$(pwd)/../../libraries/osx/gloox/bin/gloox-config"}
  50. export ICU_CONFIG=${ICU_CONFIG:="$(pwd)/../../libraries/osx/icu/bin/icu-config"}
  51. export SDL2_CONFIG=${SDL2_CONFIG:="$(pwd)/../../libraries/osx/sdl2/bin/sdl2-config"}
  52. export WX_CONFIG=${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"}
  53. export XML2_CONFIG=${XML2_CONFIG:="$(pwd)/../../libraries/osx/libxml2/bin/xml2-config"}
  54. fi
  55. # Don't want to build bundled libs on OS X
  56. # (build-osx-libs.sh is used instead)
  57. if [ "`uname -s`" != "Darwin" ]; then
  58. echo "Updating bundled third-party dependencies..."
  59. echo
  60. # Build/update bundled external libraries
  61. (cd ../../libraries/source/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed"
  62. echo
  63. if [ "$with_system_mozjs38" = "false" ]; then
  64. (cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed"
  65. fi
  66. echo
  67. if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then
  68. (cd ../../libraries/source/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed"
  69. fi
  70. echo
  71. fi
  72. # Now build premake and run it to create the makefiles
  73. cd ../premake/premake4
  74. PREMAKE_BUILD_DIR=build/gmake.unix
  75. # BSD and OS X need different Makefiles
  76. case "`uname -s`" in
  77. "GNU/kFreeBSD" )
  78. # use default gmake.unix (needs -ldl as we have a GNU userland and libc)
  79. ;;
  80. *"BSD" )
  81. PREMAKE_BUILD_DIR=build/gmake.bsd
  82. ;;
  83. "Darwin" )
  84. PREMAKE_BUILD_DIR=build/gmake.macosx
  85. ;;
  86. esac
  87. ${MAKE} -C $PREMAKE_BUILD_DIR ${JOBS} || die "Premake build failed"
  88. echo
  89. cd ..
  90. # If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection
  91. export HOSTTYPE="$HOSTTYPE"
  92. echo "Premake args: ${premake_args}"
  93. premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed"
  94. premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed"
  95. # Also generate xcode workspaces if on OS X
  96. if [ "`uname -s`" = "Darwin" ]; then
  97. premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode3" ${premake_args} xcode3 || die "Premake failed"
  98. premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode4" ${premake_args} xcode4 || die "Premake failed"
  99. fi
  100. # test_root.cpp gets generated by cxxtestgen and passing different arguments to premake could require a regeneration of this file.
  101. # It doesn't depend on anything in the makefiles, so make won't notice that the prebuild command for creating test_root.cpp needs to be triggered.
  102. # We force this by deleting the file.
  103. rm -f ../../source/test_root.cpp