1# 2# Copyright (C) 2011 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17include art/build/Android.common_build.mk 18 19# We need to be in art directory to properly initialize ART_CPPLINT_SRC variable. 20LOCAL_PATH := $(art_path) 21 22# Use upstream cpplint (toolpath from .repo/manifests/GLOBAL-PREUPLOAD.cfg). 23ART_CPPLINT := tools/repohooks/tools/cpplint.py 24 25# This file previously configured many cpplint settings. 26# Everything that could be moved to CPPLINT.cfg has moved there. 27# Please add new settings to CPPLINT.cfg over adding new flags in this file. 28 29# No output when there are no errors. 30ART_CPPLINT_FLAGS := --quiet 31 32# 1) Get list of all .h & .cc files in the art directory. 33# 2) Prepends 'art/' to each of them to make the full name. 34ART_CPPLINT_SRC := $(addprefix $(LOCAL_PATH)/, $(call all-subdir-named-files,*.h) $(call all-subdir-named-files,*$(ART_CPP_EXTENSION))) 35 36# 1) Get list of all CPPLINT.cfg files in the art directory. 37# 2) Prepends 'art/' to each of them to make the full name. 38ART_CPPLINT_CFG := $(addprefix $(LOCAL_PATH)/, $(call all-subdir-named-files,CPPLINT.cfg)) 39 40# "mm cpplint-art" to verify we aren't regressing 41# - files not touched since the last build are skipped (quite fast). 42.PHONY: cpplint-art 43cpplint-art: cpplint-art-phony 44 45# "mm cpplint-art-all" to manually execute cpplint.py on all files (very slow). 46.PHONY: cpplint-art-all 47cpplint-art-all: 48 $(ART_CPPLINT) $(ART_CPPLINT_FLAGS) $(ART_CPPLINT_SRC) 49 50OUT_CPPLINT := $(TARGET_COMMON_OUT_ROOT)/cpplint 51 52# Build up the list of all targets for linting the ART source files. 53ART_CPPLINT_TARGETS := 54 55define declare-art-cpplint-target 56art_cpplint_file := $(1) 57art_cpplint_touch := $$(OUT_CPPLINT)/$$(subst /,__,$$(art_cpplint_file)) 58 59$$(art_cpplint_touch): $$(art_cpplint_file) $(ART_CPPLINT) $(ART_CPPLINT_CFG) art/build/Android.cpplint.mk 60 $(hide) $(ART_CPPLINT) $(ART_CPPLINT_FLAGS) $$< 61 $(hide) mkdir -p $$(dir $$@) 62 $(hide) touch $$@ 63 64ART_CPPLINT_TARGETS += $$(art_cpplint_touch) 65endef 66 67$(foreach file, $(ART_CPPLINT_SRC), $(eval $(call declare-art-cpplint-target,$(file)))) 68#$(info $(call declare-art-cpplint-target,$(firstword $(ART_CPPLINT_SRC)))) 69 70include $(CLEAR_VARS) 71LOCAL_MODULE := cpplint-art-phony 72LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 73LOCAL_LICENSE_CONDITIONS := notice 74LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE 75LOCAL_MODULE_TAGS := optional 76LOCAL_ADDITIONAL_DEPENDENCIES := $(ART_CPPLINT_TARGETS) 77include $(BUILD_PHONY_PACKAGE) 78