Add a phony target aidl-freeze-api

aidl-freeze-api is a phony target that executes <modulename>-freeze-api
for all aidl_interface modules found in the source tree. We use it when
doing the API dump to make sure that all changes in AIDL interfaces are
frozen and checked for backwards compatibility.

Test: m aidl-freeze-api
Change-Id: I6a326b100506e4e0b74692132592384c62eaad3d
diff --git a/build/Android.mk b/build/Android.mk
new file mode 100644
index 0000000..e50f702
--- /dev/null
+++ b/build/Android.mk
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 2019 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.
+#
+
+.PHONY: aidl-freeze-api
+aidl-freeze-api: $(addsuffix -freeze-api, $(SOONG_ALL_AIDL_INTERFACES))
diff --git a/build/aidl_interface.go b/build/aidl_interface.go
index b33e98f..1fa0966 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -107,6 +107,7 @@
 	pctx.SourcePathVariable("aidlToJniCmd", "system/tools/aidl/build/aidl_to_jni.py")
 	android.RegisterModuleType("aidl_interface", aidlInterfaceFactory)
 	android.RegisterModuleType("aidl_mapping", aidlMappingFactory)
+	android.RegisterMakeVarsProvider(pctx, allAidlInterfacesMakeVars)
 }
 
 // wrap(p, a, s) = [p + v + s for v in a]
@@ -1007,3 +1008,13 @@
 		},
 	}
 }
+
+func allAidlInterfacesMakeVars(ctx android.MakeVarsContext) {
+	names := []string{}
+	ctx.VisitAllModules(func(module android.Module) {
+		if ai, ok := module.(*aidlInterface); ok {
+			names = append(names, ai.Name())
+		}
+	})
+	ctx.Strict("ALL_AIDL_INTERFACES", strings.Join(names, " "))
+}