Revert "Remove don't bother checks"

This reverts commit 83761ed277fbffd5d4ff80f2ba71c05a8469cb6c.

Reason for revert: Broke aosp_x86_64-eng checkbuild

Change-Id: I692bb634ba5e0b6232a2cd51cc044da3d4856366
diff --git a/Android.mk b/Android.mk
index 0281b0b..361ceec 100644
--- a/Android.mk
+++ b/Android.mk
@@ -25,6 +25,18 @@
 include $(art_path)/build/Android.common_path.mk
 include $(art_path)/build/Android.oat.mk
 
+# Following the example of build's dont_bother for clean targets.
+art_dont_bother := false
+ifneq (,$(filter clean-oat%,$(MAKECMDGOALS)))
+  art_dont_bother := true
+endif
+
+# Don't bother with tests unless there is a test-art*, build-art*, or related target.
+art_test_bother := false
+ifneq (,$(filter tests test-art% valgrind-test-art% build-art% checkbuild,$(MAKECMDGOALS)))
+  art_test_bother := true
+endif
+
 .PHONY: clean-oat
 clean-oat: clean-oat-host clean-oat-target
 
@@ -54,6 +66,8 @@
 endif
 	adb shell rm -rf data/run-test/test-*/dalvik-cache/*
 
+ifneq ($(art_dont_bother),true)
+
 ########################################################################
 # cpplint rules to style check art source files
 
@@ -89,6 +103,8 @@
 ########################################################################
 # test rules
 
+ifeq ($(art_test_bother),true)
+
 # All the dependencies that must be built ahead of sync-ing them onto the target device.
 TEST_ART_TARGET_SYNC_DEPS :=
 
@@ -332,6 +348,7 @@
 valgrind-test-art-target64: valgrind-test-art-target-gtest64
 	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
 
+endif  # art_test_bother
 
 #######################
 # Fake packages for ART
@@ -586,7 +603,11 @@
 
 ########################################################################
 
+endif # !art_dont_bother
+
 # Clear locally used variables.
+art_dont_bother :=
+art_test_bother :=
 TEST_ART_TARGET_SYNC_DEPS :=
 
 # Helper target that depends on boot image creation.