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