meson_builder.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env sh
  2. # This script can be used on the command line directly to configure several
  3. # different build environments.
  4. # This is called by `.travis.yml` via Travis CI.
  5. # Travis supplies $TRAVIS_OS_NAME.
  6. # http://docs.travis-ci.com/user/multi-os/
  7. # Our .travis.yml also defines:
  8. # - BUILD_TYPE=release/debug
  9. # - LIB_TYPE=static/shared
  10. env_set=1
  11. if ${BUILD_TYPE+false}; then
  12. echo "BUILD_TYPE not set in environment."
  13. env_set=0
  14. fi
  15. if ${LIB_TYPE+false}; then
  16. echo "LIB_TYPE not set in environment."
  17. env_set=0
  18. fi
  19. if ${CXX+false}; then
  20. echo "CXX not set in environment."
  21. env_set=0
  22. fi
  23. if [ ${env_set} -eq 0 ]; then
  24. echo "USAGE: CXX=$(which clang++) BUILD_TYPE=[release|debug] LIB_TYPE=[static|shared] $0"
  25. echo ""
  26. echo "Examples:"
  27. echo " CXX=$(which clang++) BUILD_TYPE=release LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0"
  28. echo " CXX=$(which clang++) BUILD_TYPE=debug LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0"
  29. echo " CXX=$(which clang++) BUILD_TYPE=release LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0"
  30. echo " CXX=$(which clang++) BUILD_TYPE=debug LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0"
  31. echo " CXX=$(which g++) BUILD_TYPE=release LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0"
  32. echo " CXX=$(which g++) BUILD_TYPE=debug LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0"
  33. echo " CXX=$(which g++) BUILD_TYPE=release LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0"
  34. echo " CXX=$(which g++) BUILD_TYPE=debug LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0"
  35. exit -1
  36. fi
  37. if ${DESTDIR+false}; then
  38. DESTDIR="/usr/local"
  39. fi
  40. # -e: fail on error
  41. # -v: show commands
  42. # -x: show expanded commands
  43. set -vex
  44. env | sort
  45. which python3
  46. which meson
  47. which ninja
  48. echo ${CXX}
  49. ${CXX} --version
  50. python3 --version
  51. meson --version
  52. ninja --version
  53. _COMPILER_NAME=`basename ${CXX}`
  54. _BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}"
  55. ./.travis_scripts/run-clang-format.sh
  56. meson --fatal-meson-warnings --werror --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
  57. ninja -v -j 2 -C "${_BUILD_DIR_NAME}"
  58. cd "${_BUILD_DIR_NAME}"
  59. meson test --no-rebuild --print-errorlogs
  60. if [ "${DESTDIR}" != "/usr/local" ]; then
  61. ninja install
  62. fi
  63. cd -
  64. if ${CLEANUP+false}; then
  65. echo "Skipping cleanup: build directory will persist."
  66. else
  67. rm -r "${_BUILD_DIR_NAME}"
  68. fi