Home | History | Annotate | Download | only in core
      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 
     23 LOCAL_IS_HOST_MODULE := $(call true-or-empty,$(LOCAL_IS_HOST_MODULE))
     24 ifeq ($(LOCAL_IS_HOST_MODULE),true)
     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)
     37 full_target := $(call doc-timestamp-for,$(LOCAL_MODULE))
     38 
     39 ifeq ($(LOCAL_DROIDDOC_SOURCE_PATH),)
     40 LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)
     41 endif
     42 
     43 ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),)
     44 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/$(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
     45 endif
     46 
     47 ifeq ($(LOCAL_DROIDDOC_ASSET_DIR),)
     48 LOCAL_DROIDDOC_ASSET_DIR := assets
     49 endif
     50 ifeq ($(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR),)
     51 LOCAL_DROIDDOC_CUSTOM_ASSET_DIR := assets
     52 endif
     53 
     54 ifeq ($(LOCAL_IS_HOST_MODULE),true)
     55 $(full_target): PRIVATE_BOOTCLASSPATH :=
     56 full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
     57   $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
     58 full_java_lib_deps := $(full_java_libs)
     59 
     60 else
     61 
     62 ifneq ($(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
     74 else
     75   LOCAL_JAVA_LIBRARIES := core-libart ext framework $(LOCAL_JAVA_LIBRARIES)
     76   $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core-libart)
     77 endif  # LOCAL_SDK_VERSION
     78 LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
     79 
     80 full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
     81 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
     82 endif # !LOCAL_IS_HOST_MODULE
     83 
     84 $(full_target): PRIVATE_CLASSPATH := $(subst $(space),:,$(full_java_libs))
     85 
     86 
     87 intermediates.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 
     95 ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),)
     96 $(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR)
     97 endif
     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
    107 define 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
    111 endef
    112 
    113 ifeq (a,b)
    114 $(full_target): PRIVATE_PROFILING_OPTIONS := \
    115     -J-agentlib:jprofilerti=port=8849 -J-Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar
    116 endif
    117 
    118 
    119 ifneq ($(strip $(LOCAL_DROIDDOC_USE_STANDARD_DOCLET)),true)
    120 ##
    121 ##
    122 ## droiddoc only
    123 ##
    124 ##
    125 
    126 droiddoc_templates := \
    127     $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f)
    128 
    129 droiddoc := \
    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 
    141 html_dir_files :=
    142 ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),)
    143 $(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR)
    144 html_dir_files := $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f)
    145 else
    146 $(full_target): PRIVATE_DROIDDOC_HTML_DIR :=
    147 endif
    148 ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),)
    149 $(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR)
    150 else
    151 $(full_target): PRIVATE_ADDITIONAL_HTML_DIR :=
    152 endif
    153 
    154 # TODO: not clear if this is used any more
    155 $(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
    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 $@)
    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 		javadoc \
    164                 -encoding UTF-8 \
    165                 \@$(PRIVATE_SRC_LIST_FILE) \
    166                 -J-Xmx1280m \
    167                 -XDignore.symbol.file \
    168                 $(PRIVATE_PROFILING_OPTIONS) \
    169                 -quiet \
    170                 -doclet com.google.doclava.Doclava \
    171                 -docletpath $(PRIVATE_DOCLETPATH) \
    172                 -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \
    173                 $(PRIVATE_DROIDDOC_HTML_DIR) \
    174                 $(PRIVATE_ADDITIONAL_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         && touch -f $@ \
    182     ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
    183 
    184 
    185 
    186 else
    187 ##
    188 ##
    189 ## standard doclet only
    190 ##
    191 ##
    192 $(full_target): $(full_src_files) $(full_java_lib_deps)
    193 	@echo Docs javadoc: $(PRIVATE_OUT_DIR)
    194 	@mkdir -p $(dir $@)
    195 	$(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
    196 			$(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
    197 	$(hide) ( \
    198 		javadoc \
    199                 -encoding UTF-8 \
    200                 $(PRIVATE_DROIDDOC_OPTIONS) \
    201                 \@$(PRIVATE_SRC_LIST_FILE) \
    202                 -J-Xmx1024m \
    203                 -XDignore.symbol.file \
    204                 $(PRIVATE_PROFILING_OPTIONS) \
    205                 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
    206                 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
    207                 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
    208                 -d $(PRIVATE_OUT_DIR) \
    209                 -quiet \
    210         && touch -f $@ \
    211     ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
    212 
    213 
    214 endif
    215 ##
    216 ##
    217 ## Common to both droiddoc and javadoc
    218 ##
    219 ##
    220 
    221 
    222 ALL_DOCS += $(full_target)
    223 
    224 .PHONY: $(LOCAL_MODULE)-docs
    225 $(LOCAL_MODULE)-docs : $(full_target)
    226 
    227 ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),)
    228 
    229 # Define a rule to create a zip of these docs.
    230 out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip
    231 $(out_zip): PRIVATE_DOCS_DIR := $(out_dir)
    232 $(out_zip): $(full_target)
    233 	@echo Package docs: $@
    234 	@rm -f $@
    235 	@mkdir -p $(dir $@)
    236 	$(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * )
    237 
    238 $(LOCAL_MODULE)-docs.zip : $(out_zip)
    239 
    240 $(call dist-for-goals,docs,$(out_zip))
    241 
    242 endif
    243