build-haz-linux.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash -ex
  2. function usage() {
  3. echo "Usage: $0 [--project <shell|browser>] <workspace-dir> flags..."
  4. echo "flags are treated the same way as a commit message would be"
  5. echo "(as in, they are scanned for directives just like a try: ... line)"
  6. }
  7. PROJECT=shell
  8. WORKSPACE=
  9. DO_TOOLTOOL=1
  10. while [[ $# -gt 0 ]]; do
  11. if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
  12. usage
  13. exit 0
  14. elif [[ "$1" == "--project" ]]; then
  15. shift
  16. PROJECT="$1"
  17. shift
  18. elif [[ "$1" == "--no-tooltool" ]]; then
  19. shift
  20. DO_TOOLTOOL=
  21. elif [[ -z "$WORKSPACE" ]]; then
  22. WORKSPACE=$( cd "$1" && pwd )
  23. shift
  24. break
  25. fi
  26. done
  27. SCRIPT_FLAGS="$@"
  28. # Ensure all the scripts in this dir are on the path....
  29. DIRNAME=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
  30. PATH=$DIRNAME:$PATH
  31. # Use GECKO_BASE_REPOSITORY as a signal for whether we are running in automation.
  32. export AUTOMATION=${GECKO_BASE_REPOSITORY:+1}
  33. : ${GECKO_DIR:=$WORKSPACE/gecko}
  34. : ${TOOLTOOL_MANIFEST:=browser/config/tooltool-manifests/linux64/hazard.manifest}
  35. : ${TOOLTOOL_CACHE:=$WORKSPACE/tt-cache}
  36. if ! [ -d $GECKO_DIR ]; then
  37. echo "GECKO_DIR must be set to a directory containing a gecko source checkout" >&2
  38. exit 1
  39. fi
  40. GECKO_DIR=$( cd "$GECKO_DIR" && pwd )
  41. # Directory to populate with tooltool-installed tools
  42. export TOOLTOOL_DIR="$WORKSPACE"
  43. # Directory to hold the (useless) object files generated by the analysis.
  44. export MOZ_OBJDIR="$WORKSPACE/obj-analyzed"
  45. mkdir -p "$MOZ_OBJDIR"
  46. if [ -n "$DO_TOOLTOOL" ]; then
  47. ( cd $TOOLTOOL_DIR; python $GECKO_DIR/testing/docker/recipes/tooltool.py --url https://api.pub.build.mozilla.org/tooltool/ -m $GECKO_DIR/$TOOLTOOL_MANIFEST fetch -c $TOOLTOOL_CACHE )
  48. fi
  49. export NO_MERCURIAL_SETUP_CHECK=1
  50. if [[ "$PROJECT" = "browser" ]]; then (
  51. cd "$WORKSPACE"
  52. set "$WORKSPACE"
  53. . setup-ccache.sh
  54. # Mozbuild config:
  55. export MOZBUILD_STATE_PATH=$WORKSPACE/mozbuild/
  56. # Create .mozbuild so mach doesn't complain about this
  57. mkdir -p $MOZBUILD_STATE_PATH
  58. ) fi
  59. . hazard-analysis.sh
  60. build_js_shell
  61. # Artifacts folder is outside of the cache.
  62. mkdir -p $HOME/artifacts/ || true
  63. function onexit () {
  64. grab_artifacts "$WORKSPACE/analysis" "$HOME/artifacts"
  65. }
  66. trap onexit EXIT
  67. configure_analysis "$WORKSPACE/analysis"
  68. run_analysis "$WORKSPACE/analysis" "$PROJECT"
  69. check_hazards "$WORKSPACE/analysis"
  70. ################################### script end ###################################