1# Copyright (C) 2015 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# We define this in a subdir so that it won't pick up the parent's Android.xml by default.
16
17LOCAL_PATH := $(call my-dir)
18
19# $(1) name of the xml file to be created
20# $(2) path to the api text file
21define build_xml_api_file
22include $(CLEAR_VARS)
23LOCAL_MODULE := cts-$(subst .,-,$(1))
24LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
25LOCAL_LICENSE_CONDITIONS := notice
26LOCAL_MODULE_STEM := $(1)
27LOCAL_MODULE_CLASS := ETC
28LOCAL_COMPATIBILITY_SUITE := arcts cts vts general-tests sts
29include $(BUILD_SYSTEM)/base_rules.mk
30$$(LOCAL_BUILT_MODULE): $(2) | $(APICHECK)
31	@echo "Convert API file $$< -> $$@"
32	@mkdir -p $$(dir $$@)
33	$(hide) $(APICHECK_COMMAND) --compatible-output=no -convert2xmlnostrip $$< $$@
34endef
35
36$(foreach ver,$(PLATFORM_SYSTEMSDK_VERSIONS),\
37  $(if $(call math_is_number,$(ver)),\
38    $(if $(wildcard prebuilts/sdk/$(ver)/system/api/android.txt),\
39      $(eval $(call build_xml_api_file,system-$(ver).api,prebuilts/sdk/$(ver)/system/api/android.txt))\
40    )\
41  )\
42)
43
44$(foreach ver,$(call int_range_list,28,$(PLATFORM_SDK_VERSION)),\
45  $(foreach api_level,public system,\
46    $(foreach lib,$(filter-out android,$(filter-out %removed,$(filter-out %incompatibilities,\
47      $(basename $(notdir $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/$(ver)/$(api_level)/api/*.txt)))))),\
48        $(eval $(call build_xml_api_file,$(lib)-$(ver)-$(api_level).api,prebuilts/sdk/$(ver)/$(api_level)/api/$(lib).txt)) \
49    )\
50  )\
51)
52