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