build.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env bash
  2. if [[ -n "$(uname -s | grep -i 'MINGW\|CYGWIN\|MSYS')" ]]; then
  3. # We're using Bash on Windows!
  4. sevenzip=./tools/7za/7za.exe
  5. else
  6. sevenzip=7z
  7. fi
  8. if [[ -x "$(command -v git)" ]] && git rev-parse --git-dir > /dev/null 2>&1; then
  9. git=1
  10. else
  11. git=0
  12. fi
  13. cmthd='Deflate'
  14. updaterepo=1
  15. # Parse arguments
  16. while [[ $# > 0 ]]; do
  17. # Help
  18. if [[ "$1" == "-h" || "$1" == "--help" ]]; then
  19. cat <<HELP
  20. WolfenDoom sh.ake 'n baker - Linux/MacOS build script for
  21. Wolfenstein: Blade of Agony
  22. -h --help Show this help
  23. -n --no-update Do not update the repo with the latest changes.
  24. -r --release Use LZMA compression instead of Deflate compression
  25. Results in smaller pk3, but takes longer, and cannot be
  26. read or modified using SLADE.
  27. HELP
  28. exit 0
  29. fi
  30. # Release build or development build
  31. if [[ "$1" == "-r" || "$1" == "--release" ]]; then
  32. cmthd='LZMA'
  33. shift
  34. continue
  35. fi
  36. if [[ "$1" == "-n" || "$1" == "--no-update" ]]; then
  37. updaterepo=0
  38. shift
  39. continue
  40. fi
  41. # Unrecognized argument
  42. shift
  43. done
  44. if ((updaterepo && git)); then
  45. git checkout master
  46. git pull origin master
  47. fi
  48. # Regular pk3 filename
  49. zipprefix="wolf_boa"
  50. if ((git)); then
  51. zipcommit="$(git log -n 1 --format=%h)"
  52. zipname="$zipprefix-$zipcommit-$(git log -n 1 --date=short --format=%cd | sed 's/\([[:digit:]]\{4\}\)-\([[:digit:]]\{2\}\)-\([[:digit:]]\{1,2\}\)$/\1\2\3/').pk3"
  53. else
  54. zipname="$zipprefix-$(date +%Y%m%d).pk3"
  55. fi
  56. $sevenzip a -tzip -mmt=on -mm=$cmthd -mx=9 -ssc -xr@'tools/7za/7zExcludeList.txt' -x@'tools/7za/7zExcludeListDir.txt' $zipname *
  57. if [[ $? -eq 0 ]]; then mv $zipname ..; fi