| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 # | |
| 3 # Runs the clang static analyzer on trunk and stores its results in a directory | |
| 4 # in Skia's Google Storage. | |
| 5 # By default the results are stored here: | |
| 6 # https://storage.cloud.google.com/chromium-skia-gm/static_analyzers/clang_stati
c_analyzer/index.html | |
| 7 # | |
| 8 # Sample Usage: | |
| 9 # STATIC_ANALYZER_TEMPDIR=/tmp/clang-static-analyzer \ | |
| 10 # SKIA_GOOGLE_STORAGE_BASE=gs://chromium-skia-gm \ | |
| 11 # bash update-buildbot-pydoc.sh | |
| 12 | |
| 13 | |
| 14 # Initialize and validate environment variables. | |
| 15 STATIC_ANALYZER_TEMPDIR=${STATIC_ANALYZER_TEMPDIR:-/tmp/clang-static-analyzer} | |
| 16 SKIA_GOOGLE_STORAGE_BASE=${SKIA_GOOGLE_STORAGE_BASE:-gs://chromium-skia-gm} | |
| 17 GOOGLE_STORAGE_CLANG_URL="https://storage.cloud.google.com/chromium-skia-gm/stat
ic_analyzers/clang_static_analyzer/" | |
| 18 | |
| 19 if [[ $SKIA_GOOGLE_STORAGE_BASE =~ ^gs://.* ]]; then | |
| 20 if [[ "$SKIA_GOOGLE_STORAGE_BASE" =~ ^gs://.+/.+ ]]; then | |
| 21 echo -e "\n\nPlease only specify the Google Storage base to use. Eg: gs://ch
romium-skia-gm. Provided value: $SKIA_GOOGLE_STORAGE_BASE" | |
| 22 exit 1 | |
| 23 fi | |
| 24 else | |
| 25 echo -e "\n\nSKIA_GOOGLE_STORAGE_BASE must start with gs://. Provided value: $
SKIA_GOOGLE_STORAGE_BASE" | |
| 26 exit 1 | |
| 27 fi | |
| 28 | |
| 29 SKIA_GOOGLE_STORAGE_STATIC_ANALYSIS_DIR=${SKIA_GOOGLE_STORAGE_BASE}/static_analy
zers/clang_static_analyzer | |
| 30 | |
| 31 | |
| 32 # Clean and create the temporary directory. | |
| 33 if [ -d "$STATIC_ANALYZER_TEMPDIR" ]; then | |
| 34 rm -rf $STATIC_ANALYZER_TEMPDIR | |
| 35 fi | |
| 36 mkdir -p $STATIC_ANALYZER_TEMPDIR | |
| 37 | |
| 38 make clean | |
| 39 | |
| 40 # Run the clang static analyzer. | |
| 41 # Details about the analyzer are here: http://clang-analyzer.llvm.org/. | |
| 42 CXX=`which clang++` CC=`which clang` scan-build -o $STATIC_ANALYZER_TEMPDIR make
-j30 | |
| 43 | |
| 44 ret_code=$? | |
| 45 if [ $ret_code != 0 ]; then | |
| 46 echo "Error while executing the scan-build command" | |
| 47 exit $ret_code | |
| 48 fi | |
| 49 | |
| 50 | |
| 51 # Fix static file paths to point to storage.cloud.google.com else the files will
not be found. | |
| 52 INDEX_FILES=$STATIC_ANALYZER_TEMPDIR/*/index.html | |
| 53 sed -i 's|href=\"|href=\"'$GOOGLE_STORAGE_CLANG_URL'|g' $INDEX_FILES | |
| 54 sed -i 's|src=\"|src=\"'$GOOGLE_STORAGE_CLANG_URL'|g' $INDEX_FILES | |
| 55 | |
| 56 | |
| 57 # Clean the SKIA_GOOGLE_STORAGE_STATIC_ANALYSIS_DIR. | |
| 58 gsutil rm ${SKIA_GOOGLE_STORAGE_STATIC_ANALYSIS_DIR}/* | |
| 59 # Copy analysis results to SKIA_GOOGLE_STORAGE_STATIC_ANALYSIS_DIR. | |
| 60 gsutil cp -a public-read $STATIC_ANALYZER_TEMPDIR/*/* $SKIA_GOOGLE_STORAGE_STATI
C_ANALYSIS_DIR/ | |
| 61 | |
| 62 | |
| 63 echo -e "\n\nThe scan-build results are available to view here: https://storage.
cloud.google.com/${SKIA_GOOGLE_STORAGE_STATIC_ANALYSIS_DIR:5}/index.html" | |
| 64 | |
| OLD | NEW |