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 core_src_files := $(call all-main-java-files-under,dalvik dom json luni support 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     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 local_javac_flags=-encoding UTF-8
     65 #local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
     66 local_javac_flags+=-Xmaxwarns 9999999
     67 
     68 #
     69 # Build for the target (device).
     70 #
     71 
     72 # Definitions to make the core library.
     73 
     74 include $(CLEAR_VARS)
     75 
     76 LOCAL_SRC_FILES := $(core_src_files)
     77 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
     78 
     79 LOCAL_NO_STANDARD_LIBRARIES := true
     80 LOCAL_JAVACFLAGS := $(local_javac_flags)
     81 LOCAL_DX_FLAGS := --core-library
     82 
     83 LOCAL_MODULE_TAGS := optional
     84 LOCAL_MODULE := core
     85 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
     86 LOCAL_REQUIRED_MODULES := tzdata
     87 
     88 include $(BUILD_JAVA_LIBRARY)
     89 
     90 core-intermediates := ${intermediates}
     91 
     92 
     93 # Make the core-tests library.
     94 ifeq ($(LIBCORE_SKIP_TESTS),)
     95 include $(CLEAR_VARS)
     96 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
     97 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
     98 LOCAL_NO_STANDARD_LIBRARIES := true
     99 LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
    100 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc mockwebserver nist-pkix-tests
    101 LOCAL_JAVACFLAGS := $(local_javac_flags)
    102 LOCAL_MODULE := core-tests
    103 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    104 include $(BUILD_STATIC_JAVA_LIBRARY)
    105 endif
    106 
    107 # This one's tricky. One of our tests needs to have a
    108 # resource with a "#" in its name, but Perforce doesn't
    109 # allow us to submit such a file. So we create it here
    110 # on-the-fly.
    111 TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
    112 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
    113 
    114 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
    115 	@mkdir -p $(dir $@)
    116 	@echo "Hello, world!" > $@
    117 
    118 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
    119 $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
    120 
    121 
    122 #
    123 # Build for the host.
    124 #
    125 
    126 ifeq ($(WITH_HOST_DALVIK),true)
    127 
    128     # Definitions to make the core library.
    129 
    130     include $(CLEAR_VARS)
    131 
    132     LOCAL_SRC_FILES := $(core_src_files)
    133     LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
    134 
    135     LOCAL_NO_STANDARD_LIBRARIES := true
    136     LOCAL_JAVACFLAGS := $(local_javac_flags)
    137     LOCAL_DX_FLAGS := --core-library
    138 
    139     LOCAL_BUILD_HOST_DEX := true
    140 
    141     LOCAL_MODULE_TAGS := optional
    142     LOCAL_MODULE := core-hostdex
    143     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    144     LOCAL_REQUIRED_MODULES := tzdata-host
    145 
    146     include $(BUILD_HOST_JAVA_LIBRARY)
    147 
    148     # Make the core-tests library.
    149     ifeq ($(LIBCORE_SKIP_TESTS),)
    150     include $(CLEAR_VARS)
    151     LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
    152     LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
    153     LOCAL_NO_STANDARD_LIBRARIES := true
    154     LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex
    155     LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
    156     LOCAL_JAVACFLAGS := $(local_javac_flags)
    157     LOCAL_MODULE_TAGS := optional
    158     LOCAL_MODULE := core-tests-hostdex
    159     LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    160     LOCAL_BUILD_HOST_DEX := true
    161     include $(BUILD_HOST_JAVA_LIBRARY)
    162     endif
    163 endif
    164 
    165 #
    166 # Local droiddoc for faster libcore testing
    167 #
    168 #
    169 # Run with:
    170 #     mm -j32 libcore-docs
    171 #
    172 # Main output:
    173 #     ../out/target/common/docs/libcore/reference/packages.html
    174 #
    175 # All text for proofreading (or running tools over):
    176 #     ../out/target/common/docs/libcore-proofread.txt
    177 #
    178 # TODO list of missing javadoc, etc:
    179 #     ../out/target/common/docs/libcore-docs-todo.html
    180 #
    181 # Rerun:
    182 #     rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
    183 #
    184 include $(CLEAR_VARS)
    185 
    186 # for shared defintion of libcore_to_document
    187 include $(LOCAL_PATH)/Docs.mk
    188 
    189 LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH))
    190 # rerun doc generation without recompiling the java
    191 LOCAL_JAVA_LIBRARIES:=
    192 LOCAL_JAVACFLAGS := $(local_javac_flags)
    193 LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
    194 
    195 LOCAL_MODULE := libcore
    196 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
    197 
    198 LOCAL_DROIDDOC_OPTIONS := \
    199  -offlinemode \
    200  -title "libcore" \
    201  -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
    202  -todo ../$(LOCAL_MODULE)-docs-todo.html \
    203  -hdf android.whichdoc offline
    204 
    205 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
    206 
    207 include $(BUILD_DROIDDOC)
    208