1 LOCAL_PATH := $(call my-dir)
4 # The core library is divided into modules. Each module has a separate Java
5 # source directory, and some (hopefully eventually all) also have a directory
6 # for tests. The two sections below define separate targets to build the
7 # core and the associated tests.
9 define all-core-java-files
10 $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find */src/$(1)/java -name "*.java"))
13 # Redirect ls stderr to /dev/null because the corresponding resources
14 # directory doesn't always exist.
15 define all-core-resource-dirs
16 $(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
19 LOCAL_SRC_FILES := $(call all-core-java-files,main)
20 LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,main)
22 LOCAL_NO_STANDARD_LIBRARIES := true
23 LOCAL_DX_FLAGS := --core-library
25 LOCAL_NO_EMMA_INSTRUMENT := true
26 LOCAL_NO_EMMA_COMPILE := true
30 include $(BUILD_JAVA_LIBRARY)
32 core-intermediates := ${intermediates}
34 # Definitions to make the core-tests library.
38 LOCAL_SRC_FILES := $(call all-core-java-files,test)
39 LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,test)
41 LOCAL_NO_STANDARD_LIBRARIES := true
42 LOCAL_JAVA_LIBRARIES := core
43 LOCAL_DX_FLAGS := --core-library
45 LOCAL_MODULE_TAGS := tests
46 LOCAL_MODULE := core-tests
48 include $(BUILD_JAVA_LIBRARY)
50 # This one's tricky. One of our tests needs to have a
51 # resource with a "#" in its name, but Perforce doesn't
52 # allow us to submit such a file. So we create it here
54 TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
55 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
57 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
59 @echo "Hello, world!" > $@
61 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
62 $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
64 # Definitions for building a version of the core-tests.jar
65 # that is suitable for execution on the RI. This JAR would
66 # be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
67 # not possible to refer to that from a shell script (the
68 # variable is not exported from envsetup.sh). There is also
69 # some trickery involved: we need to include some classes
70 # that reside in core.jar, but since we cannot incldue the
71 # whole core.jar in the RI classpath, we copy those classses
72 # over to our new file.
73 HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
75 $(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
76 $(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
77 $(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
78 @rm -rf $(dir $<)/hostctsclasses
79 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
80 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
82 @jar uf $@ -C $(dir $<)hostctsclasses .
84 $(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
86 $(LOCAL_INSTALLED_MODULE): run-core-tests
88 # Definitions to copy the core-tests runner script.
91 LOCAL_SRC_FILES := run-core-tests
92 LOCAL_MODULE_CLASS := EXECUTABLES
93 LOCAL_MODULE_TAGS := tests
94 LOCAL_MODULE := run-core-tests
95 include $(BUILD_PREBUILT)
98 LOCAL_SRC_FILES := run-core-tests-on-ri
99 LOCAL_IS_HOST_MODULE := true
100 LOCAL_MODULE_CLASS := EXECUTABLES
101 LOCAL_MODULE_TAGS := tests
102 LOCAL_MODULE := run-core-tests-on-ri
103 include $(BUILD_PREBUILT)
105 # Build all of the native code, if any is present.
107 include $(CLEAR_VARS)
109 # Get the list of all native directories that contain sub.mk files.
110 # We're using "sub.mk" to make it clear that these are not typical
112 define all-core-native-dirs
113 $(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null))
116 core_magic_local_target := ...//::default:://...
117 core_local_path := $(LOCAL_PATH)
119 # Include a submakefile, resolve its source file locations,
120 # and stick them on core_src_files. The submakefiles are
121 # free to append to LOCAL_C_INCLUDES, LOCAL_SHARED_LIBRARIES, etc.
123 # $(1): directory containing the makefile to include
124 define include-core-native-dir
126 include $(LOCAL_PATH)/$(1)/sub.mk
127 ifneq ($$(LOCAL_MODULE),$(core_magic_local_target))
128 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \
129 or define LOCAL_MODULE)
131 ifneq ($$(LOCAL_PATH),$(core_local_path))
132 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH)
134 core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
138 # Find any native directories containing sub.mk files.
139 core_native_dirs := $(strip $(call all-core-native-dirs,main))
140 ifeq ($(core_native_dirs),)
141 $(error No native code defined for libcore)
144 # Set up the default state.
145 LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
146 LOCAL_MODULE := $(core_magic_local_target)
149 # Include the sub.mk files.
151 $(core_native_dirs), \
152 $(eval $(call include-core-native-dir,$(dir))))
155 LOCAL_SRC_FILES := $(core_src_files)
156 LOCAL_MODULE := libjavacore
157 include $(BUILD_STATIC_LIBRARY)
159 # Deal with keystores required for security. Note: The path to this file
160 # is hardcoded in TrustManagerFactoryImpl.java.
161 ALL_PREBUILT += $(TARGET_OUT)/etc/security/cacerts.bks
162 $(TARGET_OUT)/etc/security/cacerts.bks : $(LOCAL_PATH)/security/src/main/files/cacerts.bks | $(ACP)
163 $(transform-prebuilt-to-target)