• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2
3if [[ $# -ne 2 ]]; then
4    echo "Error: Incorrect number of arguments" >&2
5    echo "Usage: ./run_lint.sh <repo_root> <CL_SHA>" >&2
6    exit 100
7fi
8
9git show --name-only --pretty=format: $2 | grep packages/SystemUI/ > /dev/null
10exitcode=$?
11if [[ exitcode -eq 1 ]];  then
12    exit 0
13fi
14
15if [[ -z $ANDROID_BUILD_TOP ]]; then
16    echo "Error: ANDROID_BUILD_TOP must be set" >&2
17    echo "Try setting up your environment first:" >&2
18    echo "    source build/envsetup.sh && lunch <target>" >&2
19    exit 101
20fi
21
22# TODO: Run lint as part of the build so we can specify the dependency properly
23systemuijarpath="out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/combined/SystemUI-core.jar"
24if [[ ! -f $ANDROID_BUILD_TOP/$systemuijarpath ]]; then
25    echo "Error: Classes.jar file not found" >&2
26    echo "Try building that jar file manually:" >&2
27    echo "    m -j16 out/soong/.intermediates/frameworks/base/packages/SystemUI/SystemUI-core/android_common/combined/SystemUI-core.jar" >&2
28    exit 102
29fi
30
31REPO_ROOT=$1
32${REPO_ROOT}/prebuilts/devtools/tools/lint \
33       . \
34       --exitcode \
35       -Werror \
36       --config ${REPO_ROOT}/frameworks/base/packages/SystemUI/tools/lint/lint.xml \
37       --html ${REPO_ROOT}/out/lint_output.html \
38       --baseline ${REPO_ROOT}/frameworks/base/packages/SystemUI/tools/lint/baseline.xml \
39       --remove-fixed
40exitcode=$?
41if [[ exitcode -eq 1 ]];  then
42    cat >&2 <<EOF
43
44Please check the HTML results file and fix the errors.
45If the error cannot be fixed immediately, there are 3 possible resolutions:
461. Use tools:ignore or @SuppressLint annotation. This is preferred
47   for cases where the lint violation is intended, so that reviewers
48   can review whether the suppression is appropriate.
492. Use tools/lint.xml to ignore a lint check which we don't care
50   about for any file, or checks that are not actionable by the
51   CL author (e.g. translation issues)
523. If there are lint errors that should be fixed, but cannot be done
53   immediately for some reason, run ./tools/lint/update_baseline.sh to
54   add them to baseline.xml.
55
56EOF
57fi
58
59exit $exitcode
60