build.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 " -r|--rebuild Clean the tree before starting build"
  22. }
  23. opt_verbose=0
  24. opt_rebuild=0
  25. while [ $# -ge 1 ]; do
  26. case "$1" in
  27. -h|--help)
  28. usage
  29. exit 0
  30. ;;
  31. -v|--verbose)
  32. opt_verbose=1
  33. ;;
  34. -r|--rebuild)
  35. opt_rebuild=1
  36. ;;
  37. esac
  38. shift
  39. done
  40. do_build()
  41. {
  42. nice -n 10 "$1" ./setup.py build &
  43. RET=$!
  44. }
  45. build()
  46. {
  47. local name="$1"
  48. local interpreter="$2"
  49. echo "Running $name build..."
  50. if [ $opt_verbose -eq 0 ]; then
  51. do_build "$interpreter" >/dev/null
  52. else
  53. do_build "$interpreter"
  54. fi
  55. }
  56. cd "$awlsim_base"
  57. if [ $opt_rebuild -ne 0 ]; then
  58. echo "Cleaning tree..."
  59. "$basedir"/cleantree.sh || die "Failed to clean tree."
  60. fi
  61. export AWLSIM_CYTHON_BUILD=1
  62. build Cython3 python3
  63. python3_build_pid=$RET
  64. if ! wait $python3_build_pid; then
  65. echo "Cython3 build FAILED!"
  66. exit 1
  67. fi
  68. echo
  69. echo "build done."
  70. exit 0