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