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_TEMPLATE_DIR),) 44LOCAL_DROIDDOC_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/templates 45endif 46ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),) 47LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/templates 48endif 49 50ifeq ($(LOCAL_DROIDDOC_ASSET_DIR),) 51LOCAL_DROIDDOC_ASSET_DIR := assets 52endif 53ifeq ($(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR),) 54LOCAL_DROIDDOC_CUSTOM_ASSET_DIR := assets 55endif 56 57$(full_target): PRIVATE_CLASSPATH:=$(LOCAL_CLASSPATH) 58full_java_lib_deps := 59 60$(full_target): PRIVATE_BOOTCLASSPATH := 61ifeq ($(BUILD_OS),linux) 62# You have to set bootclasspath for javadoc manually on linux since Java 6. 63host_jdk_rt_jar := $(dir $(HOST_JDK_TOOLS_JAR))../jre/lib/rt.jar 64$(full_target): PRIVATE_BOOTCLASSPATH := $(host_jdk_rt_jar) 65endif 66 67ifneq ($(LOCAL_IS_HOST_MODULE),true) 68 69ifeq ($(LOCAL_JAVA_LIBRARIES),) 70LOCAL_JAVA_LIBRARIES := core ext framework 71endif 72full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 73full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 74 75# we're not going to generate docs from any of these classes, but we need them 76# to build properly. 77ifneq ($(strip $(LOCAL_STATIC_JAVA_LIBRARIES)),) 78full_java_libs += $(addprefix $(LOCAL_PATH)/,$(LOCAL_STATIC_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH) 79full_java_lib_deps += $(addprefix $(LOCAL_PATH)/,$(LOCAL_STATIC_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH) 80endif 81 82empty := 83space := $(empty) $(empty) 84$(full_target): PRIVATE_CLASSPATH := $(subst $(space),:,$(full_java_libs)) 85 86endif # !LOCAL_IS_HOST_MODULE 87 88intermediates := $(call local-intermediates-dir) 89 90$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH)) 91$(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files)) 92$(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES))) 93$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src 94$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates)/droiddoc-src-list 95 96ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),) 97$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR) 98endif 99 100$(full_target): PRIVATE_OUT_DIR := $(out_dir) 101$(full_target): PRIVATE_DROIDDOC_OPTIONS := $(LOCAL_DROIDDOC_OPTIONS) 102 103# Lists the input files for the doc build into a text file 104# suitable for the @ syntax of javadoc. 105# $(1): the file to create 106# $(2): files to include 107# $(3): list of directories to search for java files in 108define prepare-doc-source-list 109$(hide) mkdir -p $(dir $(1)) 110$(call dump-words-to-file, $(2), $(1)) 111$(hide) for d in $(3) ; do find $$d -name '*.java' >> $(1) 2> /dev/null ; done ; true 112endef 113 114ifeq (a,b) 115$(full_target): PRIVATE_PROFILING_OPTIONS := \ 116 -J-agentlib:jprofilerti=port=8849 -J-Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar 117endif 118 119 120ifneq ($(strip $(LOCAL_DROIDDOC_USE_STANDARD_DOCLET)),true) 121## 122## 123## droiddoc only 124## 125## 126 127droiddoc_templates := \ 128 $(shell find $(LOCAL_DROIDDOC_TEMPLATE_DIR) -type f) \ 129 $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f) 130 131droiddoc := \ 132 $(HOST_JDK_TOOLS_JAR) \ 133 $(HOST_OUT_JAVA_LIBRARIES)/droiddoc$(COMMON_JAVA_PACKAGE_SUFFIX) \ 134 $(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX) \ 135 $(HOST_OUT_SHARED_LIBRARIES)/libclearsilver-jni$(HOST_JNILIB_SUFFIX) 136 137$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/droiddoc$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/apicheck$(COMMON_JAVA_PACKAGE_SUFFIX) 138$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER) 139$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$(shell date "+%d %b %Y %k:%M")" 140$(full_target): PRIVATE_TEMPLATE_DIR := $(LOCAL_DROIDDOC_TEMPLATE_DIR) 141$(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) 142$(full_target): PRIVATE_IN_ASSET_DIR := $(LOCAL_DROIDDOC_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_ASSET_DIR) 143$(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR) 144$(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR) 145$(full_target): PRIVATE_OUT_CUSTOM_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR) 146ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),) 147$(full_target): PRIVATE_DROIDDOC_HTML_DIR := $(foreach dir,$(LOCAL_DROIDDOC_HTML_DIR),-htmldir $(dir)) 148else 149$(full_target): PRIVATE_DROIDDOC_HTML_DIR := 150endif 151 152# TODO: not clear if this is used any more 153$(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) 154 155html_dir_files := $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f) 156 157$(full_target): $(full_src_files) $(droiddoc_templates) $(droiddoc) $(html_dir_files) $(full_java_lib_deps) $(LOCAL_ADDITIONAL_DEPENDENCIES) 158 @echo Docs droiddoc: $(PRIVATE_OUT_DIR) 159 $(hide) mkdir -p $(dir $(full_target)) 160 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ 161 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) 162 $(hide) ( \ 163 LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \ 164 javadoc \ 165 \@$(PRIVATE_SRC_LIST_FILE) \ 166 -J-Xmx768m \ 167 -J-Djava.library.path=$(HOST_OUT_SHARED_LIBRARIES) \ 168 $(PRIVATE_PROFILING_OPTIONS) \ 169 -quiet \ 170 -doclet DroidDoc \ 171 -docletpath $(PRIVATE_DOCLETPATH) \ 172 -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \ 173 -templatedir $(PRIVATE_TEMPLATE_DIR) \ 174 $(PRIVATE_DROIDDOC_HTML_DIR) \ 175 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ 176 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ 177 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \ 178 -d $(PRIVATE_OUT_DIR) \ 179 $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) \ 180 $(PRIVATE_DROIDDOC_OPTIONS) \ 181 && rm -rf $(PRIVATE_OUT_ASSET_DIR) \ 182 && rm -rf $(PRIVATE_OUT_CUSTOM_ASSET_DIR) \ 183 && mkdir -p $(PRIVATE_OUT_ASSET_DIR) \ 184 && mkdir -p $(PRIVATE_OUT_CUSTOM_ASSET_DIR) \ 185 && cp -fr $(PRIVATE_IN_ASSET_DIR)/* $(PRIVATE_OUT_ASSET_DIR)/ \ 186 && cp -fr $(PRIVATE_IN_CUSTOM_ASSET_DIR)/* $(PRIVATE_OUT_CUSTOM_ASSET_DIR)/ \ 187 && touch -f $@ \ 188 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) 189 190 191 192else 193## 194## 195## standard doclet only 196## 197## 198$(full_target): $(full_src_files) $(full_java_lib_deps) 199 @echo Docs javadoc: $(PRIVATE_OUT_DIR) 200 @mkdir -p $(dir $(full_target)) 201 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ 202 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) 203 $(hide) ( \ 204 javadoc \ 205 $(PRIVATE_DROIDDOC_OPTIONS) \ 206 \@$(PRIVATE_SRC_LIST_FILE) \ 207 -J-Xmx768m \ 208 $(PRIVATE_PROFILING_OPTIONS) \ 209 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ 210 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \ 211 -d $(PRIVATE_OUT_DIR) \ 212 -quiet \ 213 && touch -f $@ \ 214 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) 215 216 217endif 218## 219## 220## Common to both droiddoc and javadoc 221## 222## 223 224 225ALL_DOCS += $(full_target) 226 227.PHONY: $(LOCAL_MODULE)-docs 228$(LOCAL_MODULE)-docs : $(full_target) 229 230# Define a rule to create a zip of these docs. 231out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip 232$(out_zip): PRIVATE_DOCS_DIR := $(out_dir) 233$(out_zip): $(full_target) 234 @echo Package docs: $@ 235 @rm -f $@ 236 @mkdir -p $(dir $@) 237 $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * ) 238 239$(call dist-for-goals,docs,$(out_zip)) 240