blob: d5ddf0860f25ff839764802233250a41e4742e05 [file] [log] [blame]
Joe Onorato64d85d02009-04-09 19:31:12 -07001#
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 Project88b60792009-03-03 19:28:42 -080016
Joe Onorato64d85d02009-04-09 19:31:12 -070017##
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)
Ying Wang13d69502012-11-01 17:22:33 -070025my_prefix := HOST_
The Android Open Source Project88b60792009-03-03 19:28:42 -080026else
Ying Wang13d69502012-11-01 17:22:33 -070027my_prefix := TARGET_
The Android Open Source Project88b60792009-03-03 19:28:42 -080028endif
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)
Joe Onorato64d85d02009-04-09 19:31:12 -070037full_target := $(call doc-timestamp-for,$(LOCAL_MODULE))
The Android Open Source Project88b60792009-03-03 19:28:42 -080038
39ifeq ($(LOCAL_DROIDDOC_SOURCE_PATH),)
40LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)
41endif
42
The Android Open Source Project88b60792009-03-03 19:28:42 -080043ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),)
Dirk Doughertyd77248a2010-08-25 15:07:39 -070044LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/$(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
The Android Open Source Project88b60792009-03-03 19:28:42 -080045endif
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
Ying Wang584d8ad2014-04-07 15:14:50 -070054ifeq ($(LOCAL_IS_HOST_MODULE),true)
55$(full_target): PRIVATE_BOOTCLASSPATH :=
56else
The Android Open Source Project88b60792009-03-03 19:28:42 -080057
Ying Wang3f45b3c2012-04-02 18:21:36 -070058ifneq ($(LOCAL_SDK_VERSION),)
Ying Wang0ec188f2012-05-10 17:25:51 -070059 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
60 # Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
Ying Wang3f45b3c2012-04-02 18:21:36 -070061 LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES)
Ying Wang584d8ad2014-04-07 15:14:50 -070062 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_stubs_current)
Ying Wang3f45b3c2012-04-02 18:21:36 -070063 else
64 LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
Ying Wang584d8ad2014-04-07 15:14:50 -070065 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
Ying Wang3f45b3c2012-04-02 18:21:36 -070066 endif
67else
Jeff Brownae859f92013-07-17 20:29:51 -070068 LOCAL_JAVA_LIBRARIES := core ext framework framework2 $(LOCAL_JAVA_LIBRARIES)
Ying Wang584d8ad2014-04-07 15:14:50 -070069 $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core)
Ying Wang3f45b3c2012-04-02 18:21:36 -070070endif # LOCAL_SDK_VERSION
71LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
72
Ying Wang8578cab2013-06-25 12:34:11 -070073endif # !LOCAL_IS_HOST_MODULE
The Android Open Source Project88b60792009-03-03 19:28:42 -080074
Ying Wang8578cab2013-06-25 12:34:11 -070075full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) $(LOCAL_CLASSPATH)
76full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) $(LOCAL_CLASSPATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -080077
The Android Open Source Project88b60792009-03-03 19:28:42 -080078$(full_target): PRIVATE_CLASSPATH := $(subst $(space),:,$(full_java_libs))
79
The Android Open Source Project88b60792009-03-03 19:28:42 -080080
Ying Wangfb790872011-05-17 14:48:10 -070081intermediates.COMMON := $(call local-intermediates-dir,COMMON)
Joe Onorato64d85d02009-04-09 19:31:12 -070082
83$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH))
The Android Open Source Project88b60792009-03-03 19:28:42 -080084$(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)))
Ying Wangfb790872011-05-17 14:48:10 -070086$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
87$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list
Joe Onorato64d85d02009-04-09 19:31:12 -070088
89ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),)
90$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR)
91endif
92
The Android Open Source Project88b60792009-03-03 19:28:42 -080093$(full_target): PRIVATE_OUT_DIR := $(out_dir)
94$(full_target): PRIVATE_DROIDDOC_OPTIONS := $(LOCAL_DROIDDOC_OPTIONS)
Joe Onorato64d85d02009-04-09 19:31:12 -070095
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
101define prepare-doc-source-list
102$(hide) mkdir -p $(dir $(1))
Joe Onorato64d85d02009-04-09 19:31:12 -0700103$(call dump-words-to-file, $(2), $(1))
104$(hide) for d in $(3) ; do find $$d -name '*.java' >> $(1) 2> /dev/null ; done ; true
105endef
106
107ifeq (a,b)
108$(full_target): PRIVATE_PROFILING_OPTIONS := \
109 -J-agentlib:jprofilerti=port=8849 -J-Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar
110endif
111
112
113ifneq ($(strip $(LOCAL_DROIDDOC_USE_STANDARD_DOCLET)),true)
114##
115##
116## droiddoc only
117##
118##
119
120droiddoc_templates := \
Joe Onorato64d85d02009-04-09 19:31:12 -0700121 $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f)
122
123droiddoc := \
124 $(HOST_JDK_TOOLS_JAR) \
Ben Dodson10344552010-08-05 15:42:37 -0700125 $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
Joe Onorato64d85d02009-04-09 19:31:12 -0700126
Ben Dodson10344552010-08-05 15:42:37 -0700127$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
Joe Onorato64d85d02009-04-09 19:31:12 -0700128$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER)
129$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$(shell date "+%d %b %Y %k:%M")"
The Android Open Source Project88b60792009-03-03 19:28:42 -0800130$(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800131$(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
132$(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR)
133$(full_target): PRIVATE_OUT_CUSTOM_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
134ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),)
Bill Napier9a0e98a2010-08-27 09:58:29 -0700135$(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136else
Dirk Dougherty1151ef42013-02-05 16:45:05 -0800137$(full_target): PRIVATE_DROIDDOC_HTML_DIR :=
138endif
139ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),)
140$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR)
141else
142$(full_target): PRIVATE_ADDITIONAL_HTML_DIR :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800143endif
Dirk Dougherty9c2336e2013-01-28 18:57:30 -0800144ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),)
145$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR)
146else
147$(full_target): PRIVATE_ADDITIONAL_HTML_DIR :=
148endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149
Joe Onorato64d85d02009-04-09 19:31:12 -0700150# TODO: not clear if this is used any more
151$(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152
Dirk Dougherty1151ef42013-02-05 16:45:05 -0800153html_dir_files := $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f)
154
Joe Onoratof58df742010-09-16 11:57:19 -0400155$(full_target): $(full_src_files) $(droiddoc_templates) $(droiddoc) $(html_dir_files) $(full_java_lib_deps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800156 @echo Docs droiddoc: $(PRIVATE_OUT_DIR)
Ying Wangb8a256a2013-02-22 09:59:17 -0800157 $(hide) mkdir -p $(dir $@)
Joe Onorato64d85d02009-04-09 19:31:12 -0700158 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
159 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800160 $(hide) ( \
Joe Onorato64d85d02009-04-09 19:31:12 -0700161 javadoc \
Ying Wang34e3e172013-12-10 11:29:25 -0800162 -encoding UTF-8 \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800163 \@$(PRIVATE_SRC_LIST_FILE) \
Dominic Binks86175d22011-03-09 12:11:19 -0800164 -J-Xmx1280m \
Ying Wang5b6b4642014-04-07 15:19:33 -0700165 -XDignore.symbol.file \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800166 $(PRIVATE_PROFILING_OPTIONS) \
167 -quiet \
Ben Dodson10344552010-08-05 15:42:37 -0700168 -doclet com.google.doclava.Doclava \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800169 -docletpath $(PRIVATE_DOCLETPATH) \
170 -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800171 $(PRIVATE_DROIDDOC_HTML_DIR) \
Dirk Dougherty9c2336e2013-01-28 18:57:30 -0800172 $(PRIVATE_ADDITIONAL_HTML_DIR) \
Ying Wang7b142da2010-06-23 20:59:22 -0700173 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800174 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
175 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
176 -d $(PRIVATE_OUT_DIR) \
177 $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) \
178 $(PRIVATE_DROIDDOC_OPTIONS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800179 && touch -f $@ \
180 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
181
Joe Onorato64d85d02009-04-09 19:31:12 -0700182
183
184else
185##
186##
187## standard doclet only
188##
189##
190$(full_target): $(full_src_files) $(full_java_lib_deps)
191 @echo Docs javadoc: $(PRIVATE_OUT_DIR)
Ying Wangb8a256a2013-02-22 09:59:17 -0800192 @mkdir -p $(dir $@)
Joe Onorato64d85d02009-04-09 19:31:12 -0700193 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
194 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
195 $(hide) ( \
196 javadoc \
Ying Wang34e3e172013-12-10 11:29:25 -0800197 -encoding UTF-8 \
Joe Onorato64d85d02009-04-09 19:31:12 -0700198 $(PRIVATE_DROIDDOC_OPTIONS) \
199 \@$(PRIVATE_SRC_LIST_FILE) \
Ying Wang24de9702010-06-18 13:18:05 -0700200 -J-Xmx1024m \
Ying Wang5b6b4642014-04-07 15:19:33 -0700201 -XDignore.symbol.file \
Joe Onorato64d85d02009-04-09 19:31:12 -0700202 $(PRIVATE_PROFILING_OPTIONS) \
203 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
Narayan Kamathf122d412013-10-25 15:55:46 +0100204 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
Joe Onorato64d85d02009-04-09 19:31:12 -0700205 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
206 -d $(PRIVATE_OUT_DIR) \
207 -quiet \
208 && touch -f $@ \
209 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
210
211
212endif
213##
214##
215## Common to both droiddoc and javadoc
216##
217##
218
219
The Android Open Source Project88b60792009-03-03 19:28:42 -0800220ALL_DOCS += $(full_target)
221
222.PHONY: $(LOCAL_MODULE)-docs
223$(LOCAL_MODULE)-docs : $(full_target)
224
Joe Onoratoaaa5d112010-09-01 10:39:50 -0700225ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),)
226
The Android Open Source Project88b60792009-03-03 19:28:42 -0800227# Define a rule to create a zip of these docs.
228out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip
229$(out_zip): PRIVATE_DOCS_DIR := $(out_dir)
230$(out_zip): $(full_target)
231 @echo Package docs: $@
232 @rm -f $@
233 @mkdir -p $(dir $@)
234 $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * )
235
Joe Onorato36b89ff2013-12-04 02:31:18 -0800236$(LOCAL_MODULE)-docs.zip : $(out_zip)
237
The Android Open Source Project88b60792009-03-03 19:28:42 -0800238$(call dist-for-goals,docs,$(out_zip))
Joe Onoratoaaa5d112010-09-01 10:39:50 -0700239
240endif