blob: 2a9cfc653401b803b23c6beb08bb7ac977604fff [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)
Ying Wang3bb5d8b2014-04-16 11:25:31 -0700134
135html_dir_files :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),)
Bill Napier9a0e98a2010-08-27 09:58:29 -0700137$(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR)
Ying Wang3bb5d8b2014-04-16 11:25:31 -0700138html_dir_files := $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800139else
Ying Wang3bb5d8b2014-04-16 11:25:31 -0700140$(full_target): PRIVATE_DROIDDOC_HTML_DIR :=
Dirk Dougherty1151ef42013-02-05 16:45:05 -0800141endif
142ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),)
143$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR)
Dirk Dougherty9c2336e2013-01-28 18:57:30 -0800144else
145$(full_target): PRIVATE_ADDITIONAL_HTML_DIR :=
146endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800147
Joe Onorato64d85d02009-04-09 19:31:12 -0700148# TODO: not clear if this is used any more
149$(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800150
Joe Onoratof58df742010-09-16 11:57:19 -0400151$(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 -0800152 @echo Docs droiddoc: $(PRIVATE_OUT_DIR)
Ying Wangb8a256a2013-02-22 09:59:17 -0800153 $(hide) mkdir -p $(dir $@)
Joe Onorato64d85d02009-04-09 19:31:12 -0700154 $(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 Project88b60792009-03-03 19:28:42 -0800156 $(hide) ( \
Joe Onorato64d85d02009-04-09 19:31:12 -0700157 javadoc \
Ying Wang34e3e172013-12-10 11:29:25 -0800158 -encoding UTF-8 \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800159 \@$(PRIVATE_SRC_LIST_FILE) \
Dominic Binks86175d22011-03-09 12:11:19 -0800160 -J-Xmx1280m \
Ying Wang5b6b4642014-04-07 15:19:33 -0700161 -XDignore.symbol.file \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800162 $(PRIVATE_PROFILING_OPTIONS) \
163 -quiet \
Ben Dodson10344552010-08-05 15:42:37 -0700164 -doclet com.google.doclava.Doclava \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800165 -docletpath $(PRIVATE_DOCLETPATH) \
166 -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800167 $(PRIVATE_DROIDDOC_HTML_DIR) \
Dirk Dougherty9c2336e2013-01-28 18:57:30 -0800168 $(PRIVATE_ADDITIONAL_HTML_DIR) \
Ying Wang7b142da2010-06-23 20:59:22 -0700169 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800170 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
171 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
172 -d $(PRIVATE_OUT_DIR) \
173 $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) \
174 $(PRIVATE_DROIDDOC_OPTIONS) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800175 && touch -f $@ \
176 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
177
Joe Onorato64d85d02009-04-09 19:31:12 -0700178
179
180else
181##
182##
183## standard doclet only
184##
185##
186$(full_target): $(full_src_files) $(full_java_lib_deps)
187 @echo Docs javadoc: $(PRIVATE_OUT_DIR)
Ying Wangb8a256a2013-02-22 09:59:17 -0800188 @mkdir -p $(dir $@)
Joe Onorato64d85d02009-04-09 19:31:12 -0700189 $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
190 $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
191 $(hide) ( \
192 javadoc \
Ying Wang34e3e172013-12-10 11:29:25 -0800193 -encoding UTF-8 \
Joe Onorato64d85d02009-04-09 19:31:12 -0700194 $(PRIVATE_DROIDDOC_OPTIONS) \
195 \@$(PRIVATE_SRC_LIST_FILE) \
Ying Wang24de9702010-06-18 13:18:05 -0700196 -J-Xmx1024m \
Ying Wang5b6b4642014-04-07 15:19:33 -0700197 -XDignore.symbol.file \
Joe Onorato64d85d02009-04-09 19:31:12 -0700198 $(PRIVATE_PROFILING_OPTIONS) \
199 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
Narayan Kamathf122d412013-10-25 15:55:46 +0100200 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
Joe Onorato64d85d02009-04-09 19:31:12 -0700201 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
202 -d $(PRIVATE_OUT_DIR) \
203 -quiet \
204 && touch -f $@ \
205 ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
206
207
208endif
209##
210##
211## Common to both droiddoc and javadoc
212##
213##
214
215
The Android Open Source Project88b60792009-03-03 19:28:42 -0800216ALL_DOCS += $(full_target)
217
218.PHONY: $(LOCAL_MODULE)-docs
219$(LOCAL_MODULE)-docs : $(full_target)
220
Joe Onoratoaaa5d112010-09-01 10:39:50 -0700221ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),)
222
The Android Open Source Project88b60792009-03-03 19:28:42 -0800223# Define a rule to create a zip of these docs.
224out_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
Joe Onorato36b89ff2013-12-04 02:31:18 -0800232$(LOCAL_MODULE)-docs.zip : $(out_zip)
233
The Android Open Source Project88b60792009-03-03 19:28:42 -0800234$(call dist-for-goals,docs,$(out_zip))
Joe Onoratoaaa5d112010-09-01 10:39:50 -0700235
236endif