update-workspaces.sh 5.0 KB

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