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 
     57 ifeq ($(EMMA_INSTRUMENT),true)
     58 ifneq ($(EMMA_INSTRUMENT_STATIC),true)
     59     common_core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
     60     core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res
     61 endif
     62 endif
     63 
     64 libdvm_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libdvm)
     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 := $(libdvm_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
     85 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
     86 LOCAL_REQUIRED_MODULES := tzdata
     87 include $(BUILD_JAVA_LIBRARY)
     88 
     89 include $(CLEAR_VARS)
     90 LOCAL_SRC_FILES := $(libart_core_src_files)
     91 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
     92 LOCAL_NO_STANDARD_LIBRARIES := true
     93 LOCAL_JAVACFLAGS := $(local_javac_flags)
     94 LOCAL_DX_FLAGS := --core-library
     95 LOCAL_MODULE_TAGS := optional
     96 LOCAL_MODULE := core-libart
     97 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
     98 LOCAL_REQUIRED_MODULES := tzdata
     99 include $(BUILD_JAVA_LIBRARY)
    100 
    101 # Create the conscrypt library
    102 include $(CLEAR_VARS)
    103 LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
    104 LOCAL_JAVA_LIBRARIES := core
    105 LOCAL_NO_STANDARD_LIBRARIES := true
    106 LOCAL_JAVACFLAGS := $(local_javac_flags)
    107 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
    108 LOCAL_MODULE_TAGS := optional
    109 LOCAL_MODULE := conscrypt
    110 LOCAL_REQUIRED_MODULES := libjavacrypto
    111 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    112 include $(BUILD_JAVA_LIBRARY)
    113 
    114 # Create the conscrypt library without jarjar for tests
    115 include $(CLEAR_VARS)
    116 LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
    117 LOCAL_JAVA_LIBRARIES := core
    118 LOCAL_NO_STANDARD_LIBRARIES := true
    119 LOCAL_JAVACFLAGS := $(local_javac_flags)
    120 LOCAL_MODULE_TAGS := optional
    121 LOCAL_MODULE := conscrypt-nojarjar
    122 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    123 include $(BUILD_STATIC_JAVA_LIBRARY)
    124 
    125 
    126 ifeq ($(LIBCORE_SKIP_TESTS),)
    127 # Make the core-tests library.
    128 include $(CLEAR_VARS)
    129 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml)
    130 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    131 LOCAL_NO_STANDARD_LIBRARIES := true
    132 LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit okhttp
    133 LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests okhttp-tests
    134 LOCAL_JAVACFLAGS := $(local_javac_flags)
    135 LOCAL_MODULE := core-tests
    136 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    137 include $(BUILD_STATIC_JAVA_LIBRARY)
    138 endif
    139 
    140 ifeq ($(LIBCORE_SKIP_TESTS),)
    141 # Make the core-tests-support library.
    142 include $(CLEAR_VARS)
    143 LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
    144 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    145 LOCAL_NO_STANDARD_LIBRARIES := true
    146 LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
    147 LOCAL_JAVACFLAGS := $(local_javac_flags)
    148 LOCAL_MODULE := core-tests-support
    149 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    150 include $(BUILD_STATIC_JAVA_LIBRARY)
    151 endif
    152 
    153 ifeq ($(LIBCORE_SKIP_TESTS),)
    154 # Make the conscrypt-tests library.
    155 include $(CLEAR_VARS)
    156 LOCAL_SRC_FILES := $(call all-test-java-files-under,crypto)
    157 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    158 LOCAL_NO_STANDARD_LIBRARIES := true
    159 LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
    160 LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support conscrypt-nojarjar
    161 LOCAL_JAVACFLAGS := $(local_javac_flags)
    162 LOCAL_MODULE_TAGS := optional
    163 LOCAL_MODULE := conscrypt-tests
    164 LOCAL_REQUIRED_MODULES := libjavacrypto
    165 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
    166 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    167 include $(BUILD_STATIC_JAVA_LIBRARY)
    168 endif
    169 
    170 # This one's tricky. One of our tests needs to have a
    171 # resource with a "#" in its name, but Perforce doesn't
    172 # allow us to submit such a file. So we create it here
    173 # on-the-fly.
    174 TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
    175 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
    176 
    177 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
    178 	@mkdir -p $(dir $@)
    179 	@echo "Hello, world!" > $@
    180 
    181 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
    182 $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
    183 
    184 
    185 #
    186 # Build for the host.
    187 #
    188 
    189 include $(CLEAR_VARS)
    190 LOCAL_SRC_FILES := $(call all-main-java-files-under, dex)
    191 LOCAL_MODULE_TAGS := optional
    192 LOCAL_MODULE := dex-host
    193 include $(BUILD_HOST_JAVA_LIBRARY)
    194 
    195 ifeq ($(WITH_HOST_DALVIK),true)
    196 
    197     # Definitions to make the core library.
    198     include $(CLEAR_VARS)
    199     LOCAL_SRC_FILES := $(libdvm_core_src_files)
    200     LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
    201     LOCAL_NO_STANDARD_LIBRARIES := true
    202     LOCAL_JAVACFLAGS := $(local_javac_flags)
    203     LOCAL_DX_FLAGS := --core-library
    204     LOCAL_BUILD_HOST_DEX := true
    205     LOCAL_MODULE_TAGS := optional
    206     LOCAL_MODULE := core-hostdex
    207     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    208     LOCAL_REQUIRED_MODULES := tzdata-host
    209     include $(BUILD_HOST_JAVA_LIBRARY)
    210 
    211     include $(CLEAR_VARS)
    212     LOCAL_SRC_FILES := $(libart_core_src_files)
    213     LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
    214     LOCAL_NO_STANDARD_LIBRARIES := true
    215     LOCAL_JAVACFLAGS := $(local_javac_flags)
    216     LOCAL_DX_FLAGS := --core-library
    217     LOCAL_BUILD_HOST_DEX := true
    218     LOCAL_MODULE_TAGS := optional
    219     LOCAL_MODULE := core-libart-hostdex
    220     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    221     LOCAL_REQUIRED_MODULES := tzdata-host
    222     include $(BUILD_HOST_JAVA_LIBRARY)
    223 
    224     # Make the conscrypt-hostdex library
    225     include $(CLEAR_VARS)
    226     LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
    227     LOCAL_JAVA_LIBRARIES := core-hostdex
    228     LOCAL_NO_STANDARD_LIBRARIES := true
    229     LOCAL_JAVACFLAGS := $(local_javac_flags)
    230     LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
    231     LOCAL_BUILD_HOST_DEX := true
    232     LOCAL_MODULE_TAGS := optional
    233     LOCAL_MODULE := conscrypt-hostdex
    234     LOCAL_REQUIRED_MODULES := libjavacrypto
    235     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    236     include $(BUILD_HOST_JAVA_LIBRARY)
    237 
    238     # Make the conscrypt-hostdex-nojarjar for tests
    239     include $(CLEAR_VARS)
    240     LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
    241     LOCAL_JAVA_LIBRARIES := core-hostdex
    242     LOCAL_NO_STANDARD_LIBRARIES := true
    243     LOCAL_JAVACFLAGS := $(local_javac_flags)
    244     LOCAL_BUILD_HOST_DEX := true
    245     LOCAL_MODULE_TAGS := optional
    246     LOCAL_MODULE := conscrypt-hostdex-nojarjar
    247     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    248     include $(BUILD_HOST_JAVA_LIBRARY)
    249 
    250     # Make the core-tests library.
    251     ifeq ($(LIBCORE_SKIP_TESTS),)
    252     include $(CLEAR_VARS)
    253     LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni xml)
    254     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    255     LOCAL_NO_STANDARD_LIBRARIES := true
    256     LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex core-tests-support-hostdex okhttp-hostdex
    257     LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
    258     LOCAL_JAVACFLAGS := $(local_javac_flags)
    259     LOCAL_MODULE_TAGS := optional
    260     LOCAL_MODULE := core-tests-hostdex
    261     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    262     LOCAL_BUILD_HOST_DEX := true
    263     include $(BUILD_HOST_JAVA_LIBRARY)
    264     endif
    265 
    266     # Make the core-tests-support library.
    267     ifeq ($(LIBCORE_SKIP_TESTS),)
    268     include $(CLEAR_VARS)
    269     LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
    270     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    271     LOCAL_NO_STANDARD_LIBRARIES := true
    272     LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex
    273     LOCAL_JAVACFLAGS := $(local_javac_flags)
    274     LOCAL_MODULE_TAGS := optional
    275     LOCAL_MODULE := core-tests-support-hostdex
    276     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    277     LOCAL_BUILD_HOST_DEX := true
    278     include $(BUILD_HOST_JAVA_LIBRARY)
    279     endif
    280 
    281     # Make the conscrypt-tests library.
    282     ifeq ($(LIBCORE_SKIP_TESTS),)
    283     include $(CLEAR_VARS)
    284     LOCAL_SRC_FILES := $(call all-test-java-files-under,crypto)
    285     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    286     LOCAL_NO_STANDARD_LIBRARIES := true
    287     LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
    288     LOCAL_JAVACFLAGS := $(local_javac_flags)
    289     LOCAL_MODULE_TAGS := optional
    290     LOCAL_MODULE := conscrypt-tests-hostdex
    291     LOCAL_REQUIRED_MODULES := libjavacrypto
    292     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    293     LOCAL_BUILD_HOST_DEX := true
    294     include $(BUILD_HOST_JAVA_LIBRARY)
    295     endif
    296 endif
    297 
    298 #
    299 # Local droiddoc for faster libcore testing
    300 #
    301 #
    302 # Run with:
    303 #     mm -j32 libcore-docs
    304 #
    305 # Main output:
    306 #     ../out/target/common/docs/libcore/reference/packages.html
    307 #
    308 # All text for proofreading (or running tools over):
    309 #     ../out/target/common/docs/libcore-proofread.txt
    310 #
    311 # TODO list of missing javadoc, etc:
    312 #     ../out/target/common/docs/libcore-docs-todo.html
    313 #
    314 # Rerun:
    315 #     rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
    316 #
    317 include $(CLEAR_VARS)
    318 
    319 # for shared defintion of libcore_to_document
    320 include $(LOCAL_PATH)/Docs.mk
    321 
    322 LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH))
    323 # rerun doc generation without recompiling the java
    324 LOCAL_JAVA_LIBRARIES:=
    325 LOCAL_JAVACFLAGS := $(local_javac_flags)
    326 LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
    327 
    328 LOCAL_MODULE := libcore
    329 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    330 
    331 LOCAL_DROIDDOC_OPTIONS := \
    332  -offlinemode \
    333  -title "libcore" \
    334  -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
    335  -todo ../$(LOCAL_MODULE)-docs-todo.html \
    336  -hdf android.whichdoc offline
    337 
    338 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
    339 
    340 include $(BUILD_DROIDDOC)
    341