Move check-api to definition.mk
1) Move check-api to definition.mk, so it can be used in other places.
2) Add additional dependency to the api-stub module to consolidate the
apicheck dependency. Previously you have to run 2 "make"s in a row and
only in the 2nd run apicheck is run, due to a gnu-make optimization.
Bug: 7540265
Change-Id: Ib24ed87d9330027a9f95ed7b16dd4002cc0e3198
diff --git a/core/definitions.mk b/core/definitions.mk
index 06db960..4f4e583 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2064,6 +2064,29 @@
endef
###########################################################
+## API Check
+###########################################################
+
+# eval this to define a rule that runs apicheck.
+#
+# Args:
+# $(1) target
+# $(2) stable api file
+# $(3) api file to be tested
+# $(4) arguments for apicheck
+# $(5) command to run if apicheck failed
+# $(6) target dependent on this api check
+# $(7) additional dependencies
+define check-api
+$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK) $(7)
+ @echo "Checking API:" $(1)
+ $(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
+ $(hide) mkdir -p $$(dir $$@)
+ $(hide) touch $$@
+$(6): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
+endef
+
+###########################################################
## Other includes
###########################################################