Enable running cpplint.py on art C++ files when using mm and mmm

Change-Id: I945bfc37c1e95310ee52e171faeeafc224934215
diff --git a/Android.mk b/Android.mk
index 7c91396..2e29385 100644
--- a/Android.mk
+++ b/Android.mk
@@ -330,19 +330,7 @@
 ########################################################################
 # cpplint targets to style check art source files
 
-# "mm cpplint-art" to verify we aren't regressing
-.PHONY: cpplint-art
-cpplint-art:
-	./art/tools/cpplint.py \
-	    --filter=-,+build/header_guard,+whitespace/braces,+whitespace/comma,+runtime/explicit,+whitespace/newline,+whitespace/parens,+build/namespaces,+readability/fn_size,+whitespace/operators,+readability/braces,+whitespace/indent,+whitespace/blank_line,+whitespace/end_of_line,+whitespace/labels,+whitespace/semicolon,+legal/copyright,+readability/casting,+readability/check,+readability/constructors,+runtime/arrays,+runtime/int,+runtime/virtual \
-	    $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION) | grep -v art/compiler/llvm/generated/)
-
-# "mm cpplint-art-aspirational" to see warnings we would like to fix
-.PHONY: cpplint-art-aspirational
-cpplint-art-aspirational:
-	./art/tools/cpplint.py \
-	    --filter=-whitespace/comments,-whitespace/line_length,-build/include,-readability/function,-readability/streams,-readability/todo,-runtime/references,-runtime/threadsafe_fn \
-	    $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION) | grep -v art/compiler/llvm/generated/)
+include $(art_build_path)/Android.cpplint.mk
 
 ########################################################################
 # targets to switch back and forth from libdvm to libart
diff --git a/build/Android.cpplint.mk b/build/Android.cpplint.mk
new file mode 100644
index 0000000..eabaf31
--- /dev/null
+++ b/build/Android.cpplint.mk
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ART_CPPLINT := art/tools/cpplint.py
+ART_CPPLINT_FILTER := --filter=-whitespace/comments,-whitespace/line_length,-build/include,-readability/function,-readability/streams,-readability/todo,-runtime/references,-runtime/sizeof,-runtime/threadsafe_fn,-runtime/printf
+ART_CPPLINT_SRC := $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION) | grep -v art/compiler/llvm/generated/)
+
+# "mm cpplint-art" to verify we aren't regressing
+.PHONY: cpplint-art
+cpplint-art:
+	$(ART_CPPLINT) $(ART_CPPLINT_FILTER) $(ART_CPPLINT_SRC)
+
+# "mm cpplint-art-all" to see all warnings
+.PHONY: cpplint-art-all
+cpplint-art-all:
+	$(ART_CPPLINT) $(ART_CPPLINT_SRC)
+
+OUT_CPPLINT := $(TARGET_COMMON_OUT_ROOT)/cpplint
+
+ART_CPPLINT_TARGETS :=
+
+define declare-art-cpplint-target
+art_cpplint_file := $(1)
+art_cpplint_touch := $$(OUT_CPPLINT)/$$(subst /,__,$$(art_cpplint_file))
+
+$$(art_cpplint_touch): $$(art_cpplint_file) $(ART_CPPLINT) art/build/Android.cpplint.mk
+	$(hide) $(ART_CPPLINT) $(ART_CPPLINT_FILTER) $$<
+	@mkdir -p $$(dir $$@)
+	$(hide) touch $$@
+
+ART_CPPLINT_TARGETS += $$(art_cpplint_touch)
+endef
+
+$(foreach file, $(ART_CPPLINT_SRC), $(eval $(call declare-art-cpplint-target,$(file))))
+#$(info $(call declare-art-cpplint-target,$(firstword $(ART_CPPLINT_SRC))))
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := cpplint-art-phony
+LOCAL_MODULE_TAGS := optional
+LOCAL_ADDITIONAL_DEPENDENCIES := $(ART_CPPLINT_TARGETS)
+include $(BUILD_PHONY_PACKAGE)