The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | ifneq ($(BUILD_TINY_ANDROID), true) |
| 21 | |
Ben Dodson | 83019ba | 2010-08-10 16:01:23 -0700 | [diff] [blame] | 22 | APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR) |
| 23 | APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) |
| 24 | APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX) |
| 25 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 26 | .PHONY: checkapi |
| 27 | |
| 28 | # eval this to define a rule that runs apicheck. |
| 29 | # |
| 30 | # Args: |
| 31 | # $(1) target |
Joe Onorato | 15ee93b | 2011-04-08 15:03:48 -0700 | [diff] [blame^] | 32 | # $(2) stable api file |
| 33 | # $(3) api file to be tested |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 34 | # $(4) arguments for apicheck |
| 35 | # $(5) command to run if apicheck failed |
| 36 | define check-api |
| 37 | $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK) |
| 38 | @echo "Checking API:" $(1) |
Ben Dodson | 70748bb | 2010-08-11 14:08:28 -0700 | [diff] [blame] | 39 | $(hide) ( $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)" $(4) $(2) $(3) || ( $(5) ; exit 38 ) ) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 40 | $(hide) mkdir -p $$(dir $$@) |
| 41 | $(hide) touch $$@ |
| 42 | checkapi: $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp |
| 43 | endef |
| 44 | |
| 45 | # Run the checkapi rules by default. |
| 46 | droidcore: checkapi |
| 47 | |
Joe Onorato | 15ee93b | 2011-04-08 15:03:48 -0700 | [diff] [blame^] | 48 | last_released_sdk_version := $(lastword $(call numerically_sort, \ |
| 49 | $(filter-out $(SRC_API_DIR)/current, \ |
| 50 | $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \ |
| 51 | )\ |
| 52 | )) |
Ying Wang | 0f6f4ca | 2010-06-09 10:26:26 -0700 | [diff] [blame] | 53 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 54 | # INTERNAL_PLATFORM_API_FILE is the one build by droiddoc. |
| 55 | |
| 56 | # Check that the API we're building hasn't broken the last-released |
| 57 | # SDK version. |
| 58 | $(eval $(call check-api, \ |
| 59 | checkapi-last, \ |
Joe Onorato | 15ee93b | 2011-04-08 15:03:48 -0700 | [diff] [blame^] | 60 | $(SRC_API_DIR)/$(last_released_sdk_version).txt, \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 61 | $(INTERNAL_PLATFORM_API_FILE), \ |
| 62 | -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \ |
| 63 | -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \ |
| 64 | -error 16 -error 17 -error 18 , \ |
| 65 | cat $(BUILD_SYSTEM)/apicheck_msg_last.txt \ |
| 66 | )) |
| 67 | |
| 68 | # Check that the API we're building hasn't changed from the not-yet-released |
| 69 | # SDK version. |
| 70 | $(eval $(call check-api, \ |
| 71 | checkapi-current, \ |
Joe Onorato | 15ee93b | 2011-04-08 15:03:48 -0700 | [diff] [blame^] | 72 | $(SRC_API_DIR)/current.txt, \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 73 | $(INTERNAL_PLATFORM_API_FILE), \ |
| 74 | -error 2 -error 3 -error 4 -error 5 -error 6 \ |
| 75 | -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \ |
| 76 | -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \ |
| 77 | -error 25 , \ |
| 78 | cat $(BUILD_SYSTEM)/apicheck_msg_current.txt \ |
| 79 | )) |
| 80 | |
| 81 | .PHONY: update-api |
| 82 | update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP) |
Joe Onorato | 15ee93b | 2011-04-08 15:03:48 -0700 | [diff] [blame^] | 83 | @echo Copying current.txt |
| 84 | $(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.txt |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 85 | |
| 86 | endif |