Home | History | Annotate | Download | only in libcore
      1 # -*- mode: makefile -*-
      2 # Copyright (C) 2007 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 # Definitions for building the Java library and associated tests.
     18 #
     19 
     20 #
     21 # Common definitions for host and target.
     22 #
     23 
     24 # libcore is divided into modules.
     25 #
     26 # The structure of each module is:
     27 #
     28 #   src/
     29 #       main/               # To be shipped on every device.
     30 #            java/          # Java source for library code.
     31 #            native/        # C++ source for library code.
     32 #            resources/     # Support files.
     33 #       test/               # Built only on demand, for testing.
     34 #            java/          # Java source for tests.
     35 #            native/        # C++ source for tests (rare).
     36 #            resources/     # Support files.
     37 #
     38 # All subdirectories are optional (hence the "2> /dev/null"s below).
     39 
     40 define all-main-java-files-under
     41 $(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/main/java -name "*.java" 2> /dev/null)))
     42 endef
     43 
     44 define all-test-java-files-under
     45 $(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/test/java -name "*.java" 2> /dev/null)))
     46 endef
     47 
     48 define all-core-resource-dirs
     49 $(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
     50 endef
     51 
     52 # The Java files and their associated resources.
     53 common_core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni xml)
     54 core_resource_dirs := $(call all-core-resource-dirs,main)
     55 test_resource_dirs := $(call all-core-resource-dirs,test)
     56 test_src_files := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml)
     57 
     58 ifeq ($(EMMA_INSTRUMENT),true)
     59 ifneq ($(EMMA_INSTRUMENT_STATIC),true)
     60     common_core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
     61     core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res
     62 endif
     63 endif
     64 
     65 libart_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libart)
     66 
     67 local_javac_flags=-encoding UTF-8
     68 #local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
     69 local_javac_flags+=-Xmaxwarns 9999999
     70 
     71 #
     72 # Build for the target (device).
     73 #
     74 
     75 # Definitions to make the core library.
     76 
     77 include $(CLEAR_VARS)
     78 LOCAL_SRC_FILES := $(libart_core_src_files)
     79 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
     80 LOCAL_NO_STANDARD_LIBRARIES := true
     81 LOCAL_JAVACFLAGS := $(local_javac_flags)
     82 LOCAL_DX_FLAGS := --core-library
     83 LOCAL_MODULE_TAGS := optional
     84 LOCAL_MODULE := core-libart
     85 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
     86 LOCAL_REQUIRED_MODULES := tzdata
     87 # Should not be dex-preopted as it isn't really a Dalvik boot jar or a
     88 # regular java library, but part of the image for ART.
     89 LOCAL_DEX_PREOPT := false
     90 include $(BUILD_JAVA_LIBRARY)
     91 
     92 ifeq ($(LIBCORE_SKIP_TESTS),)
     93 # Make the core-tests library.
     94 include $(CLEAR_VARS)
     95 LOCAL_SRC_FILES := $(test_src_files)
     96 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
     97 LOCAL_NO_STANDARD_LIBRARIES := true
     98 LOCAL_JAVA_LIBRARIES := core-libart okhttp core-junit bouncycastle
     99 LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests
    100 LOCAL_JAVACFLAGS := $(local_javac_flags)
    101 LOCAL_MODULE := core-tests
    102 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    103 include $(BUILD_STATIC_JAVA_LIBRARY)
    104 endif
    105 
    106 ifeq ($(LIBCORE_SKIP_TESTS),)
    107 # Make the core-tests-support library.
    108 include $(CLEAR_VARS)
    109 LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
    110 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    111 LOCAL_NO_STANDARD_LIBRARIES := true
    112 LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle
    113 LOCAL_JAVACFLAGS := $(local_javac_flags)
    114 LOCAL_MODULE := core-tests-support
    115 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    116 include $(BUILD_STATIC_JAVA_LIBRARY)
    117 endif
    118 
    119 ifeq ($(LIBCORE_SKIP_TESTS),)
    120 # Make the jsr166-tests library.
    121 include $(CLEAR_VARS)
    122 LOCAL_SRC_FILES :=  $(call all-test-java-files-under, jsr166-tests)
    123 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    124 LOCAL_NO_STANDARD_LIBRARIES := true
    125 LOCAL_JAVA_LIBRARIES := core-libart core-junit
    126 LOCAL_JAVACFLAGS := $(local_javac_flags)
    127 LOCAL_MODULE := jsr166-tests
    128 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    129 include $(BUILD_STATIC_JAVA_LIBRARY)
    130 endif
    131 
    132 # This one's tricky. One of our tests needs to have a
    133 # resource with a "#" in its name, but Perforce doesn't
    134 # allow us to submit such a file. So we create it here
    135 # on-the-fly.
    136 TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
    137 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
    138 
    139 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
    140 	@mkdir -p $(dir $@)
    141 	@echo "Hello, world!" > $@
    142 
    143 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
    144 $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
    145 
    146 
    147 #
    148 # Build for the host.
    149 #
    150 
    151 include $(CLEAR_VARS)
    152 LOCAL_SRC_FILES := $(call all-main-java-files-under, dex)
    153 LOCAL_MODULE_TAGS := optional
    154 LOCAL_MODULE := dex-host
    155 include $(BUILD_HOST_JAVA_LIBRARY)
    156 
    157 # Definitions to make the core library.
    158 include $(CLEAR_VARS)
    159 LOCAL_SRC_FILES := $(libart_core_src_files)
    160 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
    161 LOCAL_NO_STANDARD_LIBRARIES := true
    162 LOCAL_JAVACFLAGS := $(local_javac_flags)
    163 LOCAL_DX_FLAGS := --core-library
    164 LOCAL_MODULE_TAGS := optional
    165 LOCAL_MODULE := core-libart-hostdex
    166 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    167 LOCAL_REQUIRED_MODULES := tzdata-host
    168 # Should not be dex-preopted as it isn't really a Dalvik boot jar or a
    169 # regular java library, but part of the image for ART.
    170 LOCAL_DEX_PREOPT := false
    171 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
    172 
    173 # Make the core-tests library.
    174 ifeq ($(LIBCORE_SKIP_TESTS),)
    175     include $(CLEAR_VARS)
    176     LOCAL_SRC_FILES := $(test_src_files)
    177     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    178     LOCAL_NO_STANDARD_LIBRARIES := true
    179     LOCAL_JAVA_LIBRARIES := core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex
    180     LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
    181     LOCAL_JAVACFLAGS := $(local_javac_flags)
    182     LOCAL_MODULE_TAGS := optional
    183     LOCAL_MODULE := core-tests-hostdex
    184     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    185     include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
    186 endif
    187 
    188 # Make the core-tests-support library.
    189 ifeq ($(LIBCORE_SKIP_TESTS),)
    190     include $(CLEAR_VARS)
    191     LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
    192     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    193     LOCAL_NO_STANDARD_LIBRARIES := true
    194     LOCAL_JAVA_LIBRARIES := core-libart-hostdex core-junit-hostdex bouncycastle-hostdex
    195     LOCAL_JAVACFLAGS := $(local_javac_flags)
    196     LOCAL_MODULE_TAGS := optional
    197     LOCAL_MODULE := core-tests-support-hostdex
    198     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    199     include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
    200 endif
    201 
    202 #
    203 # Local droiddoc for faster libcore testing
    204 #
    205 #
    206 # Run with:
    207 #     mm -j32 libcore-docs
    208 #
    209 # Main output:
    210 #     ../out/target/common/docs/libcore/reference/packages.html
    211 #
    212 # All text for proofreading (or running tools over):
    213 #     ../out/target/common/docs/libcore-proofread.txt
    214 #
    215 # TODO list of missing javadoc, etc:
    216 #     ../out/target/common/docs/libcore-docs-todo.html
    217 #
    218 # Rerun:
    219 #     rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
    220 #
    221 include $(CLEAR_VARS)
    222 
    223 # for shared defintion of libcore_to_document
    224 include $(LOCAL_PATH)/Docs.mk
    225 
    226 LOCAL_SRC_FILES := $(libcore_to_document)
    227 # rerun doc generation without recompiling the java
    228 LOCAL_JAVA_LIBRARIES:=
    229 LOCAL_JAVACFLAGS := $(local_javac_flags)
    230 LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
    231 
    232 LOCAL_MODULE := libcore
    233 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    234 
    235 LOCAL_DROIDDOC_OPTIONS := \
    236  -offlinemode \
    237  -title "libcore" \
    238  -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
    239  -todo ../$(LOCAL_MODULE)-docs-todo.html \
    240  -hdf android.whichdoc offline
    241 
    242 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
    243 
    244 include $(BUILD_DROIDDOC)
    245