1# 2# Copyright (C) 2008 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 17## 18## 19## Common to both droiddoc and javadoc 20## 21## 22 23LOCAL_IS_HOST_MODULE := $(call true-or-empty,$(LOCAL_IS_HOST_MODULE)) 24ifeq ($(LOCAL_IS_HOST_MODULE),true) 25my_prefix := HOST_ 26else 27my_prefix := TARGET_ 28endif 29 30LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS)) 31ifndef LOCAL_MODULE_CLASS 32$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined) 33endif 34 35full_src_files := $(patsubst %,$(LOCAL_PATH)/%,$(LOCAL_SRC_FILES)) 36out_dir := $(OUT_DOCS)/$(LOCAL_MODULE) 37full_target := $(call doc-timestamp-for,$(LOCAL_MODULE)) 38 39ifeq ($(LOCAL_DROIDDOC_SOURCE_PATH),) 40LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH) 41endif 42 43ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),) 44LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/$(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) 45endif 46 47ifeq ($(LOCAL_DROIDDOC_ASSET_DIR),) 48LOCAL_DROIDDOC_ASSET_DIR := assets 49endif 50ifeq ($(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR),) 51LOCAL_DROIDDOC_CUSTOM_ASSET_DIR := assets 52endif 53 54ifeq ($(LOCAL_IS_HOST_MODULE),true) 55$(full_target): PRIVATE_BOOTCLASSPATH := 56full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\ 57 $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES))) 58full_java_lib_deps := $(full_java_libs) 59 60else 61 62ifneq ($(LOCAL_SDK_VERSION),) 63 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) 64 # Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. 65 LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES) 66 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_stubs_current) 67 else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current) 68 LOCAL_JAVA_LIBRARIES := android_system_stubs_current $(LOCAL_JAVA_LIBRARIES) 69 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_system_stubs_current) 70 else 71 LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) 72 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION)) 73 endif 74else 75 LOCAL_JAVA_LIBRARIES := core-libart ext framework $(LOCAL_JAVA_LIBRARIES) 76 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core-libart) 77endif # LOCAL_SDK_VERSION 78LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES)) 79 80full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH) 81full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH) 82endif # !LOCAL_IS_HOST_MODULE 83 84$(full_target): PRIVATE_CLASSPATH := $(subst $(space),:,$(full_java_libs)) 85 86 87intermediates.COMMON := $(call local-intermediates-dir,COMMON) 88 89$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH)) 90$(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files)) 91$(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES))) 92$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src 93$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list 94 95ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),) 96$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR) 97endif 98 99$(full_target): PRIVATE_OUT_DIR := $(out_dir) 100$(full_target): PRIVATE_DROIDDOC_OPTIONS := $(LOCAL_DROIDDOC_OPTIONS) 101 102# Lists the input files for the doc build into a text file 103# suitable for the @ syntax of javadoc. 104# $(1): the file to create 105# $(2): files to include 106# $(3): list of directories to search for java files in 107define prepare-doc-source-list 108$(hide) mkdir -p $(dir $(1)) 109$(call dump-words-to-file, $(2), $(1)) 110$(hide) for d in $(3) ; do find $$d -name '*.java' >> $(1) 2> /dev/null ; done ; true 111endef 112 113ifeq (a,b) 114$(full_target): PRIVATE_PROFILING_OPTIONS := \ 115 -J-agentlib:jprofilerti=port=8849 -J-Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar 116endif 117 118 119ifneq ($(strip $(LOCAL_DROIDDOC_USE_STANDARD_DOCLET)),true) 120## 121## 122## droiddoc only 123## 124## 125 126droiddoc_templates := \ 127 $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f) 128 129droiddoc := \ 130 $(HOST_JDK_TOOLS_JAR) \ 131 $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) 132 133$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) 134$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER) 135$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$(shell date "+%d %b %Y %k:%M")" 136$(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) 137$(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR) 138$(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR) 139$(full_target): PRIVATE_OUT_CUSTOM_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR) 140 141html_dir_files := 142ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),) 143$(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) 144html_dir_files := $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f) 145else 146$(full_target): PRIVATE_DROIDDOC_HTML_DIR := 147endif 148ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),) 149$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR) 150else 151$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := 152endif 153 154# TODO: not clear if this is used any more 155$(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) 156 157$(full_target): \ 158 $(full_src_files) \ 159 $(droiddoc_templates) \ 160 $(droiddoc) \ 161 $(html_dir_files) \ 162 $(full_java_lib_deps) \ 163 $(LOCAL_MODULE_MAKEFILE) \ 164 $(LOCAL_ADDITIONAL_DEPENDENCIES) 165 @echo Docs droiddoc: $(PRIVATE_OUT_DIR) 166 $(hide) mkdir -p $(dir $@) 167 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ 168 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) 169 $(hide) ( \ 170 javadoc \ 171 -encoding UTF-8 \ 172 \@$(PRIVATE_SRC_LIST_FILE) \ 173 -J-Xmx1280m \ 174 -XDignore.symbol.file \ 175 $(PRIVATE_PROFILING_OPTIONS) \ 176 -quiet \ 177 -doclet com.google.doclava.Doclava \ 178 -docletpath $(PRIVATE_DOCLETPATH) \ 179 -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \ 180 $(PRIVATE_DROIDDOC_HTML_DIR) \ 181 $(PRIVATE_ADDITIONAL_HTML_DIR) \ 182 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ 183 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ 184 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \ 185 -d $(PRIVATE_OUT_DIR) \ 186 $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) \ 187 $(PRIVATE_DROIDDOC_OPTIONS) \ 188 && touch -f $@ \ 189 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) 190 191 192 193else 194## 195## 196## standard doclet only 197## 198## 199$(full_target): $(full_src_files) $(full_java_lib_deps) 200 @echo Docs javadoc: $(PRIVATE_OUT_DIR) 201 @mkdir -p $(dir $@) 202 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ 203 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) 204 $(hide) ( \ 205 javadoc \ 206 -encoding UTF-8 \ 207 $(PRIVATE_DROIDDOC_OPTIONS) \ 208 \@$(PRIVATE_SRC_LIST_FILE) \ 209 -J-Xmx1024m \ 210 -XDignore.symbol.file \ 211 $(PRIVATE_PROFILING_OPTIONS) \ 212 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ 213 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ 214 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \ 215 -d $(PRIVATE_OUT_DIR) \ 216 -quiet \ 217 && touch -f $@ \ 218 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) 219 220 221endif 222## 223## 224## Common to both droiddoc and javadoc 225## 226## 227 228 229ALL_DOCS += $(full_target) 230 231.PHONY: $(LOCAL_MODULE)-docs 232$(LOCAL_MODULE)-docs : $(full_target) 233 234ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),) 235 236# Define a rule to create a zip of these docs. 237out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip 238$(out_zip): PRIVATE_DOCS_DIR := $(out_dir) 239$(out_zip): $(full_target) 240 @echo Package docs: $@ 241 @rm -f $@ 242 @mkdir -p $(dir $@) 243 $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * ) 244 245$(LOCAL_MODULE)-docs.zip : $(out_zip) 246 247$(call dist-for-goals,docs,$(out_zip)) 248 249endif 250