build.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/sh
  2. basedir="$(dirname "$0")"
  3. [ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"
  4. awlsim_base="$basedir/.."
  5. set -e
  6. if ! [ -x "$awlsim_base/awlsim-test" -a -x "$awlsim_base/setup.py" ]; then
  7. echo "basedir sanity check failed"
  8. exit 1
  9. fi
  10. die()
  11. {
  12. echo "$*" >&2
  13. exit 1
  14. }
  15. usage()
  16. {
  17. echo "build.sh [OPTIONS]"
  18. echo
  19. echo " -h|--help Show help"
  20. echo " -v|--verbose Verbose build"
  21. echo " -f|--full Full build; Cython2 and Cython3"
  22. echo " -r|--rebuild Clean the tree before starting build"
  23. }
  24. opt_verbose=0
  25. opt_full=0
  26. opt_rebuild=0
  27. while [ $# -ge 1 ]; do
  28. case "$1" in
  29. -h|--help)
  30. usage
  31. exit 0
  32. ;;
  33. -v|--verbose)
  34. opt_verbose=1
  35. ;;
  36. -f|--full)
  37. opt_full=1
  38. ;;
  39. -r|--rebuild)
  40. opt_rebuild=1
  41. ;;
  42. esac
  43. shift
  44. done
  45. do_build()
  46. {
  47. nice -n 10 "$1" ./setup.py build &
  48. RET=$!
  49. }
  50. build()
  51. {
  52. local name="$1"
  53. local interpreter="$2"
  54. echo "Running $name build..."
  55. if [ $opt_verbose -eq 0 ]; then
  56. do_build "$interpreter" >/dev/null
  57. else
  58. do_build "$interpreter"
  59. fi
  60. }
  61. cd "$awlsim_base"
  62. if [ $opt_rebuild -ne 0 ]; then
  63. echo "Cleaning tree..."
  64. "$basedir"/cleantree.sh || die "Failed to clean tree."
  65. fi
  66. export AWLSIM_CYTHON_BUILD=1
  67. if [ $opt_full -ne 0 ]; then
  68. build Cython2 python2
  69. python2_build_pid=$RET
  70. fi
  71. build Cython3 python3
  72. python3_build_pid=$RET
  73. if [ $opt_full -ne 0 ]; then
  74. if ! wait $python2_build_pid; then
  75. echo "Cython2 build FAILED!"
  76. exit 1
  77. fi
  78. fi
  79. if ! wait $python3_build_pid; then
  80. echo "Cython3 build FAILED!"
  81. exit 1
  82. fi
  83. echo
  84. echo "build done."
  85. exit 0