build.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. usage()
  11. {
  12. echo "build.sh [OPTIONS]"
  13. echo
  14. echo " -h|--help Show help"
  15. echo " -v|--verbose Verbose build"
  16. echo " -f|--full Full build; Cython2 and Cython3"
  17. }
  18. opt_verbose=0
  19. opt_full=0
  20. while [ $# -ge 1 ]; do
  21. case "$1" in
  22. -h|--help)
  23. usage
  24. exit 0
  25. ;;
  26. -v|--verbose)
  27. opt_verbose=1
  28. ;;
  29. -f|--full)
  30. opt_full=1
  31. ;;
  32. esac
  33. shift
  34. done
  35. do_build()
  36. {
  37. nice -n 10 "$1" ./setup.py build &
  38. RET=$!
  39. }
  40. build()
  41. {
  42. local name="$1"
  43. local interpreter="$2"
  44. echo "Running $name build..."
  45. if [ $opt_verbose -eq 0 ]; then
  46. do_build "$interpreter" >/dev/null
  47. else
  48. do_build "$interpreter"
  49. fi
  50. }
  51. cd "$awlsim_base"
  52. export AWLSIM_CYTHON_BUILD=1
  53. if [ $opt_full -ne 0 ]; then
  54. build Cython2 python2
  55. python2_build_pid=$RET
  56. fi
  57. build Cython3 python3
  58. python3_build_pid=$RET
  59. if [ $opt_full -ne 0 ]; then
  60. if ! wait $python2_build_pid; then
  61. echo "Cython2 build FAILED!"
  62. exit 1
  63. fi
  64. fi
  65. if ! wait $python3_build_pid; then
  66. echo "Cython3 build FAILED!"
  67. exit 1
  68. fi
  69. echo
  70. echo "build done."
  71. exit 0