1#
2# Copyright (C) 2012 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH:= $(call my-dir)
18
19uiautomator.core_src_files := $(call all-java-files-under, core-src) \
20	$(call all-java-files-under, testrunner-src)
21uiautomator.core_java_libraries := android.test.runner core-junit
22
23uiautomator_internal_api_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/uiautomator_api.txt
24uiautomator_internal_removed_api_file := \
25    $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/uiautomator_removed_api.txt
26
27###############################################
28include $(CLEAR_VARS)
29LOCAL_SRC_FILES := $(uiautomator.core_src_files)
30LOCAL_MODULE := uiautomator.core
31LOCAL_JAVA_LIBRARIES := android.test.runner
32include $(BUILD_STATIC_JAVA_LIBRARY)
33
34###############################################
35# Generate the stub source files
36include $(CLEAR_VARS)
37LOCAL_SRC_FILES := $(uiautomator.core_src_files)
38LOCAL_JAVA_LIBRARIES := $(uiautomator.core_java_libraries)
39LOCAL_MODULE_CLASS := JAVA_LIBRARIES
40LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)/core-src \
41	$(LOCAL_PATH)/testrunner-src
42LOCAL_DROIDDOC_HTML_DIR :=
43
44LOCAL_DROIDDOC_OPTIONS:= \
45    -stubs $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/android_uiautomator_intermediates/src \
46    -stubpackages com.android.uiautomator.core:com.android.uiautomator.testrunner \
47    -api $(uiautomator_internal_api_file) \
48    -removedApi $(uiautomator_internal_removed_api_file)
49
50LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := build/tools/droiddoc/templates-sdk
51LOCAL_UNINSTALLABLE_MODULE := true
52
53LOCAL_MODULE := uiautomator-stubs
54
55include $(BUILD_DROIDDOC)
56uiautomator_stubs_stamp := $(full_target)
57$(uiautomator_internal_api_file) : $(full_target)
58
59###############################################
60# Build the stub source files into a jar.
61include $(CLEAR_VARS)
62LOCAL_MODULE := android_uiautomator
63LOCAL_JAVA_LIBRARIES := $(uiautomator.core_java_libraries)
64LOCAL_SOURCE_FILES_ALL_GENERATED := true
65include $(BUILD_STATIC_JAVA_LIBRARY)
66# Make sure to run droiddoc first to generate the stub source files.
67$(full_classes_compiled_jar) : $(uiautomator_stubs_stamp)
68uiautomator_stubs_jar := $(full_classes_compiled_jar)
69
70###############################################
71# API check
72# Please refer to build/core/tasks/apicheck.mk.
73uiautomator_api_dir := frameworks/base/cmds/uiautomator/api
74last_released_sdk_version := $(lastword $(call numerically_sort, \
75    $(filter-out current, \
76        $(patsubst $(uiautomator_api_dir)/%.txt,%, $(wildcard $(uiautomator_api_dir)/*.txt)) \
77    )))
78
79checkapi_last_error_level_flags := \
80    -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
81    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
82    -error 16 -error 17 -error 18
83
84# Check that the API we're building hasn't broken the last-released SDK version.
85$(eval $(call check-api, \
86    uiautomator-checkapi-last, \
87    $(uiautomator_api_dir)/$(last_released_sdk_version).txt, \
88    $(uiautomator_internal_api_file), \
89    $(uiautomator_api_dir)/removed.txt, \
90    $(uiautomator_internal_removed_api_file), \
91    $(checkapi_last_error_level_flags), \
92    cat $(LOCAL_PATH)/apicheck_msg_last.txt, \
93    $(uiautomator_stubs_jar), \
94    $(uiautomator_stubs_stamp)))
95
96checkapi_current_error_level_flags := \
97    -error 2 -error 3 -error 4 -error 5 -error 6 \
98    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
99    -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
100    -error 25
101
102# Check that the API we're building hasn't changed from the not-yet-released
103# SDK version.
104$(eval $(call check-api, \
105    uiautomator-checkapi-current, \
106    $(uiautomator_api_dir)/current.txt, \
107    $(uiautomator_internal_api_file), \
108    $(uiautomator_api_dir)/removed.txt, \
109    $(uiautomator_internal_removed_api_file), \
110    $(checkapi_current_error_level_flags), \
111    cat $(LOCAL_PATH)/apicheck_msg_current.txt, \
112    $(uiautomator_stubs_jar), \
113    $(uiautomator_stubs_stamp)))
114
115.PHONY: update-uiautomator-api
116update-uiautomator-api: PRIVATE_API_DIR := $(uiautomator_api_dir)
117update-uiautomator-api: PRIVATE_REMOVED_API_FILE := $(uiautomator_internal_removed_api_file)
118update-uiautomator-api: $(uiautomator_internal_api_file) | $(ACP)
119	@echo Copying uiautomator current.txt
120	$(hide) $(ACP) $< $(PRIVATE_API_DIR)/current.txt
121	@echo Copying uiautomator removed.txt
122	$(hide) $(ACP) $(PRIVATE_REMOVED_API_FILE) $(PRIVATE_API_DIR)/removed.txt
123###############################################
124# clean up temp vars
125uiautomator.core_src_files :=
126uiautomator.core_java_libraries :=
127uiautomator_stubs_stamp :=
128uiautomator_internal_api_file :=
129uiautomator_stubs_jar :=
130uiautomator_api_dir :=
131checkapi_last_error_level_flags :=
132checkapi_current_error_level_flags :=
133