• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Copyright (C) 2015 The Android Open Source Project
2#
3#  Licensed under the Apache License, Version 2.0 (the "License");
4#  you may not use this file except in compliance with the License.
5#  You may obtain a copy of the License at
6#
7#       http://www.apache.org/licenses/LICENSE-2.0
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14
15# Android lint checks for common code/resource errors specific to Android
16
17# Lint tool expects the intermediates dir to match the project name Bugle rather
18# than $(LOCAL_PACKAGE_NAME) which is messaging
19# Create a symbolic link to redirect the tool
20$(LOCAL_PACKAGE_NAME)BUGLE_RENAME := $(subst $(LOCAL_PACKAGE_NAME)_intermediates,Bugle_intermediates,$(intermediates.COMMON))
21$($(LOCAL_PACKAGE_NAME)BUGLE_RENAME): SOURCE_PATH := $(abspath $(intermediates.COMMON)/)
22$($(LOCAL_PACKAGE_NAME)BUGLE_RENAME): DST_PATH := $($(LOCAL_PACKAGE_NAME)BUGLE_RENAME)
23$($(LOCAL_PACKAGE_NAME)BUGLE_RENAME) :
24	ln -f -s $(SOURCE_PATH) $(DST_PATH)
25
26# Lint tool expects api-versions.xml from the SDK to be in development/sdk but
27# it's not.  Create a symbolic link to the android SDK to fix it
28API_VERSIONS_XML := $(abspath development/sdk/api-versions.xml)
29$(API_VERSIONS_XML):
30	ln -f -s $(abspath prebuilts/fullsdk/linux/platform-tools/api/api-versions.xml) $(API_VERSIONS_XML)
31
32# The output xml file from the lint tool
33$(LOCAL_PACKAGE_NAME)LINT_XML := $(intermediates.COMMON)/$(LOCAL_PACKAGE_NAME)_android_lint.xml
34
35# The transformed text file from the output xml
36$(LOCAL_PACKAGE_NAME)LINT_TXT := $(intermediates.COMMON)/$(LOCAL_PACKAGE_NAME)_android_lint.txt
37
38# Creates the output xml from the lint tool by running the linting tool if the
39# package has been updated
40$($(LOCAL_PACKAGE_NAME)LINT_XML): PRIVATE_PATH := $(LOCAL_PATH)
41$($(LOCAL_PACKAGE_NAME)LINT_XML): LINT_CMD = $(LINT) --quiet -Wall --disable UnusedIds,UnusedResources,MissingTranslation $(PRIVATE_PATH)
42$($(LOCAL_PACKAGE_NAME)LINT_XML) : $(LOCAL_BUILT_MODULE) $($(LOCAL_PACKAGE_NAME)BUGLE_RENAME) $(API_VERSIONS_XML)
43	$(LINT_CMD) --xml $@ > /dev/null
44
45# Creates the transformed text file from the output xml by running an xslt on it
46# which filters out issues from the support library and formats it for console
47# output
48$($(LOCAL_PACKAGE_NAME)LINT_TXT): PRIVATE_PATH := $(LOCAL_PATH)
49$($(LOCAL_PACKAGE_NAME)LINT_TXT): INPUT := $($(LOCAL_PACKAGE_NAME)LINT_XML)
50$($(LOCAL_PACKAGE_NAME)LINT_TXT): XSLT_CMD = xsltproc $(PRIVATE_PATH)/build/android_lint.xslt $(INPUT)
51$($(LOCAL_PACKAGE_NAME)LINT_TXT) : $($(LOCAL_PACKAGE_NAME)LINT_XML)
52	$(hide) $(XSLT_CMD) > $@
53
54# The root of the lint rule which just prints the lint errors txt file to the
55# console
56$(LOCAL_PACKAGE_NAME)lint: PRIVATE_PATH := $(LOCAL_PATH)
57$(LOCAL_PACKAGE_NAME)lint :: $($(LOCAL_PACKAGE_NAME)LINT_TXT)
58	$(hide) $(PRIVATE_PATH)/build/colorize_errors.py < $<
59
60