1# Copyright (C) 2008 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# Rules for running apicheck to confirm that you haven't broken
17# api compatibility or added apis illegally.
18#
19
20# skip api check for PDK buid
21ifeq (,$(filter true, $(WITHOUT_CHECK_API) $(TARGET_BUILD_PDK)))
22
23.PHONY: checkapi
24
25# Run the checkapi rules by default.
26droidcore: checkapi
27
28last_released_sdk_version := $(lastword $(call numerically_sort, \
29            $(filter-out current, \
30                $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \
31             )\
32        ))
33
34.PHONY: check-public-api
35checkapi : check-public-api
36
37.PHONY: update-api
38
39# INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
40# Note that since INTERNAL_PLATFORM_API_FILE is the byproduct of api-stubs module,
41# (See frameworks/base/Android.mk)
42# we need to add api-stubs as additional dependency of the api check.
43
44# Check that the API we're building hasn't broken the last-released
45# SDK version.
46$(eval $(call check-api, \
47    checkpublicapi-last, \
48    $(SRC_API_DIR)/$(last_released_sdk_version).txt, \
49    $(INTERNAL_PLATFORM_API_FILE), \
50    frameworks/base/api/removed.txt, \
51    $(INTERNAL_PLATFORM_REMOVED_API_FILE), \
52    -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
53    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
54    -error 16 -error 17 -error 18 , \
55    cat $(BUILD_SYSTEM)/apicheck_msg_last.txt, \
56    check-public-api, \
57    $(call doc-timestamp-for,api-stubs) \
58    ))
59
60# Check that the API we're building hasn't changed from the not-yet-released
61# SDK version.
62$(eval $(call check-api, \
63    checkpublicapi-current, \
64    frameworks/base/api/current.txt, \
65    $(INTERNAL_PLATFORM_API_FILE), \
66    frameworks/base/api/removed.txt, \
67    $(INTERNAL_PLATFORM_REMOVED_API_FILE), \
68    -error 2 -error 3 -error 4 -error 5 -error 6 \
69    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
70    -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
71    -error 25 -error 26 -error 27, \
72    cat $(BUILD_SYSTEM)/apicheck_msg_current.txt, \
73    check-public-api, \
74    $(call doc-timestamp-for,api-stubs) \
75    ))
76
77.PHONY: update-public-api
78update-public-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
79	@echo Copying current.txt
80	$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) frameworks/base/api/current.txt
81	@echo Copying removed.txt
82	$(hide) $(ACP) $(INTERNAL_PLATFORM_REMOVED_API_FILE) frameworks/base/api/removed.txt
83
84update-api : update-public-api
85
86#####################Check System API#####################
87.PHONY: check-system-api
88checkapi : check-system-api
89
90# Check that the System API we're building hasn't broken the last-released
91# SDK version.
92$(eval $(call check-api, \
93    checksystemapi-last, \
94    $(SRC_SYSTEM_API_DIR)/$(last_released_sdk_version).txt, \
95    $(INTERNAL_PLATFORM_SYSTEM_API_FILE), \
96    frameworks/base/api/system-removed.txt, \
97    $(INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE), \
98    -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
99    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
100    -error 16 -error 17 -error 18 , \
101    cat $(BUILD_SYSTEM)/apicheck_msg_last.txt, \
102    check-system-api, \
103    $(call doc-timestamp-for,system-api-stubs) \
104    ))
105
106# Check that the System API we're building hasn't changed from the not-yet-released
107# SDK version.
108$(eval $(call check-api, \
109    checksystemapi-current, \
110    frameworks/base/api/system-current.txt, \
111    $(INTERNAL_PLATFORM_SYSTEM_API_FILE), \
112    frameworks/base/api/system-removed.txt, \
113    $(INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE), \
114    -error 2 -error 3 -error 4 -error 5 -error 6 \
115    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
116    -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
117    -error 25 -error 26 -error 27, \
118    cat $(BUILD_SYSTEM)/apicheck_msg_current.txt, \
119    check-system-api, \
120    $(call doc-timestamp-for,system-api-stubs) \
121    ))
122
123.PHONY: update-system-api
124update-api : update-system-api
125
126update-system-api: $(INTERNAL_PLATFORM_SYSTEM_API_FILE) | $(ACP)
127	@echo Copying system-current.txt
128	$(hide) $(ACP) $(INTERNAL_PLATFORM_SYSTEM_API_FILE) frameworks/base/api/system-current.txt
129	@echo Copying system-removed.txt
130	$(hide) $(ACP) $(INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE) frameworks/base/api/system-removed.txt
131
132endif
133