blob: 739cfb34ca3af0d48c2bb6a5c20f217b6d8dce7d [file] [log] [blame]
Chris Banesf62fcde2015-02-25 10:42:47 +00001# 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#
16# Input variables
17#
18# $(support_module) - name of the support library module
19# $(support_module_api_dir) - dir to store API files
20# $(support_module_java_libraries) - dependent libraries
21# $(support_module_java_packages) - list of package names containing public classes
22# $(support_module_src_files) - list of source files
Chris Banes95ad49b2015-10-19 11:02:33 +010023# $(support_module_aidl_includes) - list of aidl files
Chris Banes63964052015-04-30 10:37:19 +010024# $(api_check_current_msg_file) - file containing error message for current API check
25# $(api_check_last_msg_file) - file containing error message for last SDK API check
Chris Banesf62fcde2015-02-25 10:42:47 +000026# ---------------------------------------------
27
28#
29# Generate the stub source files
30# ---------------------------------------------
31include $(CLEAR_VARS)
32
33support_module_api_file := \
34 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(support_module)_api.txt
35support_module_removed_file := \
36 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(support_module)_removed.txt
37
38LOCAL_MODULE := $(support_module)-stubs
39LOCAL_MODULE_CLASS := JAVA_LIBRARIES
40LOCAL_MODULE_TAGS := optional
41
42LOCAL_SRC_FILES := $(support_module_src_files)
Chris Banes95ad49b2015-10-19 11:02:33 +010043LOCAL_AIDL_INCLUDES := $(support_module_aidl_includes)
Chris Banesf62fcde2015-02-25 10:42:47 +000044LOCAL_JAVA_LIBRARIES := $(support_module_java_libraries)
45LOCAL_ADDITIONAL_JAVA_DIR := \
46 $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(support_module),,COMMON)/src
47LOCAL_SDK_VERSION := current
48
49LOCAL_DROIDDOC_OPTIONS:= \
50 -stubs $(TARGET_OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates/src \
Chris Banes63964052015-04-30 10:37:19 +010051 -stubpackages "$(subst $(space),:,$(support_module_java_packages))" \
Chris Banesf62fcde2015-02-25 10:42:47 +000052 -api $(support_module_api_file) \
53 -removedApi $(support_module_removed_file) \
54 -nodocs
55
56LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := build/tools/droiddoc/templates-sdk
57LOCAL_UNINSTALLABLE_MODULE := true
58
59include $(BUILD_DROIDDOC)
60support_stub_stamp := $(full_target)
61$(support_module_api_file) : $(full_target)
62
63#
64# Check API
65# ---------------------------------------------
66last_released_sdk_$(support_module) := $(lastword $(call numerically_sort, \
67 $(filter-out current, \
68 $(patsubst $(support_module_api_dir)/%.txt,%, $(wildcard $(support_module_api_dir)/*.txt)) \
69 )))
70
71# Check that the API we're building hasn't broken the last-released SDK version
72# if it exists
Chris Banesf3fac2d2015-03-28 18:55:31 +000073ifneq ($(last_released_sdk_$(support_module)),)
Chris Banesf62fcde2015-02-25 10:42:47 +000074$(eval $(call check-api, \
75 $(support_module)-checkapi-last, \
76 $(support_module_api_dir)/$(last_released_sdk_$(support_module)).txt, \
77 $(support_module_api_file), \
78 $(support_module_api_dir)/removed.txt, \
79 $(support_module_removed_file), \
80 -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
81 -warning 7 -warning 8 -warning 9 -warning 10 -warning 11 -warning 12 \
82 -warning 13 -warning 14 -warning 15 -warning 16 -warning 17 -warning 18, \
83 cat $(api_check_last_msg_file), \
84 check-support-api, \
85 $(support_stub_stamp)))
86endif
87
88# Check that the API we're building hasn't changed from the not-yet-released
89# SDK version.
90$(eval $(call check-api, \
91 $(support_module)-checkapi-current, \
92 $(support_module_api_dir)/current.txt, \
93 $(support_module_api_file), \
94 $(support_module_api_dir)/removed.txt, \
95 $(support_module_removed_file), \
96 -error 2 -error 3 -error 4 -error 5 -error 6 -error 7 -error 8 -error 9 -error 10 -error 11 \
97 -error 12 -error 13 -error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 \
98 -error 21 -error 23 -error 24 -error 25, \
99 cat $(api_check_current_msg_file), \
100 check-support-api, \
101 $(support_stub_stamp)))
102
103.PHONY: update-$(support_module)-api
104update-$(support_module)-api: PRIVATE_API_DIR := $(support_module_api_dir)
105update-$(support_module)-api: PRIVATE_MODULE := $(support_module)
106update-$(support_module)-api: PRIVATE_REMOVED_API_FILE := $(support_module_removed_file)
107update-$(support_module)-api: $(support_module_api_file) | $(ACP)
108 @echo Copying $(PRIVATE_MODULE) current.txt
109 $(hide) $(ACP) $< $(PRIVATE_API_DIR)/current.txt
110 @echo Copying $(PRIVATE_MODULE) removed.txt
111 $(hide) $(ACP) $(PRIVATE_REMOVED_API_FILE) $(PRIVATE_API_DIR)/removed.txt
112
113# Run this update API task on the update-support-api task
114update-support-api: update-$(support_module)-api
115
116#
117# Clear variables
118# ---------------------------------------------
119support_module :=
120support_module_api_dir :=
121support_module_src_files :=
Chris Banes95ad49b2015-10-19 11:02:33 +0100122support_module_aidl_includes :=
Chris Banesf62fcde2015-02-25 10:42:47 +0000123support_module_java_libraries :=
124support_module_java_packages :=
125support_module_api_file :=
126support_module_removed_file :=
127support_stub_stamp :=