Home | History | Annotate | Download | only in support
      1 # 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
     23 # $(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
     25 # ---------------------------------------------
     26 
     27 #
     28 # Generate the stub source files
     29 # ---------------------------------------------
     30 include $(CLEAR_VARS)
     31 
     32 support_module_api_file := \
     33     $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(support_module)_api.txt
     34 support_module_removed_file := \
     35     $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(support_module)_removed.txt
     36 
     37 LOCAL_MODULE := $(support_module)-stubs
     38 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
     39 LOCAL_MODULE_TAGS := optional
     40 
     41 LOCAL_SRC_FILES := $(support_module_src_files)
     42 LOCAL_JAVA_LIBRARIES := $(support_module_java_libraries)
     43 LOCAL_ADDITIONAL_JAVA_DIR := \
     44     $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(support_module),,COMMON)/src
     45 LOCAL_SDK_VERSION := current
     46 
     47 LOCAL_DROIDDOC_OPTIONS:= \
     48     -stubs $(TARGET_OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates/src \
     49     -stubpackages "$(subst $(space),:,$(support_module_java_packages))" \
     50     -api $(support_module_api_file) \
     51     -removedApi $(support_module_removed_file) \
     52     -nodocs
     53 
     54 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := build/tools/droiddoc/templates-sdk
     55 LOCAL_UNINSTALLABLE_MODULE := true
     56 
     57 include $(BUILD_DROIDDOC)
     58 support_stub_stamp := $(full_target)
     59 $(support_module_api_file) : $(full_target)
     60 
     61 #
     62 # Check API
     63 # ---------------------------------------------
     64 last_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
     71 ifneq ($(last_released_sdk_$(support_module)),)
     72 $(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)))
     84 endif
     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
    102 update-$(support_module)-api: PRIVATE_API_DIR := $(support_module_api_dir)
    103 update-$(support_module)-api: PRIVATE_MODULE := $(support_module)
    104 update-$(support_module)-api: PRIVATE_REMOVED_API_FILE := $(support_module_removed_file)
    105 update-$(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
    112 update-support-api: update-$(support_module)-api
    113 
    114 #
    115 # Clear variables
    116 # ---------------------------------------------
    117 support_module :=
    118 support_module_api_dir :=
    119 support_module_src_files :=
    120 support_module_java_libraries :=
    121 support_module_java_packages :=
    122 support_module_api_file :=
    123 support_module_removed_file :=
    124 support_stub_stamp :=
    125