blob: 8d9928eef153cf3c90e50614d66e6d13446ea65f [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# 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
Keun young Park7fc7aad2012-02-27 15:49:23 -080020# skip api check for TINY_ANDROID and PDK buid
Brian Swetland7a596052012-03-23 16:04:13 -070021ifeq (,$(filter true, $(BUILD_TINY_ANDROID) $(TARGET_BUILD_PDK)))
The Android Open Source Project88b60792009-03-03 19:28:42 -080022
23.PHONY: checkapi
24
25# eval this to define a rule that runs apicheck.
26#
27# Args:
28# $(1) target
Joe Onorato15ee93b2011-04-08 15:03:48 -070029# $(2) stable api file
30# $(3) api file to be tested
The Android Open Source Project88b60792009-03-03 19:28:42 -080031# $(4) arguments for apicheck
32# $(5) command to run if apicheck failed
33define check-api
34$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK)
35 @echo "Checking API:" $(1)
Joe Onorato2a6e0522011-04-08 17:32:52 -070036 $(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
The Android Open Source Project88b60792009-03-03 19:28:42 -080037 $(hide) mkdir -p $$(dir $$@)
38 $(hide) touch $$@
39checkapi: $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
40endef
41
42# Run the checkapi rules by default.
43droidcore: checkapi
44
Joe Onorato15ee93b2011-04-08 15:03:48 -070045last_released_sdk_version := $(lastword $(call numerically_sort, \
46 $(filter-out $(SRC_API_DIR)/current, \
47 $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \
48 )\
49 ))
Ying Wang0f6f4ca2010-06-09 10:26:26 -070050
The Android Open Source Project88b60792009-03-03 19:28:42 -080051# INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
52
53# Check that the API we're building hasn't broken the last-released
54# SDK version.
55$(eval $(call check-api, \
56 checkapi-last, \
Joe Onorato15ee93b2011-04-08 15:03:48 -070057 $(SRC_API_DIR)/$(last_released_sdk_version).txt, \
The Android Open Source Project88b60792009-03-03 19:28:42 -080058 $(INTERNAL_PLATFORM_API_FILE), \
59 -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
60 -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
61 -error 16 -error 17 -error 18 , \
62 cat $(BUILD_SYSTEM)/apicheck_msg_last.txt \
63 ))
64
65# Check that the API we're building hasn't changed from the not-yet-released
66# SDK version.
67$(eval $(call check-api, \
68 checkapi-current, \
Joe Onorato15ee93b2011-04-08 15:03:48 -070069 $(SRC_API_DIR)/current.txt, \
The Android Open Source Project88b60792009-03-03 19:28:42 -080070 $(INTERNAL_PLATFORM_API_FILE), \
71 -error 2 -error 3 -error 4 -error 5 -error 6 \
72 -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
73 -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
74 -error 25 , \
75 cat $(BUILD_SYSTEM)/apicheck_msg_current.txt \
76 ))
77
78.PHONY: update-api
79update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
Joe Onorato15ee93b2011-04-08 15:03:48 -070080 @echo Copying current.txt
81 $(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -080082
83endif