blob: b22b4c04ca014cc6f862b32b038c66931672cde7 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001LOCAL_PATH := $(call my-dir)
2include $(CLEAR_VARS)
3
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.
8
9define all-core-java-files
10$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find */src/$(1)/java -name "*.java"))
11endef
12
13# Redirect ls stderr to /dev/null because the corresponding resources
14# directory doesn't always exist.
15define all-core-resource-dirs
16$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
17endef
18
19LOCAL_SRC_FILES := $(call all-core-java-files,main)
20LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,main)
21
22LOCAL_NO_STANDARD_LIBRARIES := true
23LOCAL_DX_FLAGS := --core-library
24
25LOCAL_NO_EMMA_INSTRUMENT := true
26LOCAL_NO_EMMA_COMPILE := true
27
28LOCAL_MODULE := core
29
30include $(BUILD_JAVA_LIBRARY)
31
Jorg Pleumann673d6142009-04-02 22:35:50 -070032core-intermediates := ${intermediates}
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080033
34# Definitions to make the core-tests library.
35
36include $(CLEAR_VARS)
37
38LOCAL_SRC_FILES := $(call all-core-java-files,test)
39LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,test)
40
41LOCAL_NO_STANDARD_LIBRARIES := true
42LOCAL_JAVA_LIBRARIES := core
43LOCAL_DX_FLAGS := --core-library
44
45LOCAL_MODULE_TAGS := tests
46LOCAL_MODULE := core-tests
47
48include $(BUILD_JAVA_LIBRARY)
49
Jorg Pleumann673d6142009-04-02 22:35:50 -070050# 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
53# on-the-fly.
54TMP_RESOURCE_DIR := /tmp/
55TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
56
57$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
58 @mkdir -p $(dir $@)
59 @echo "Hello, world!" > $@
60
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)
63
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.
73HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
74
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
81 @cp $< $@
82 @jar uf $@ -C $(dir $<)hostctsclasses .
83
84$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
85
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080086$(LOCAL_INSTALLED_MODULE): run-core-tests
87
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080088# Definitions to copy the core-tests runner script.
89
90include $(CLEAR_VARS)
91LOCAL_SRC_FILES := run-core-tests
92LOCAL_MODULE_CLASS := EXECUTABLES
93LOCAL_MODULE_TAGS := tests
94LOCAL_MODULE := run-core-tests
95include $(BUILD_PREBUILT)
96
Jorg Pleumann673d6142009-04-02 22:35:50 -070097include $(CLEAR_VARS)
98LOCAL_SRC_FILES := run-core-tests-on-ri
99LOCAL_IS_HOST_MODULE := true
100LOCAL_MODULE_CLASS := EXECUTABLES
101LOCAL_MODULE_TAGS := tests
102LOCAL_MODULE := run-core-tests-on-ri
103include $(BUILD_PREBUILT)
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800104
105# Build all of the native code, if any is present.
106
107include $(CLEAR_VARS)
108
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
111# android makefiles.
112define all-core-native-dirs
113$(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null))
114endef
115
116core_magic_local_target := ...//::default:://...
117core_local_path := $(LOCAL_PATH)
118
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.
122#
123# $(1): directory containing the makefile to include
124define include-core-native-dir
125 LOCAL_SRC_FILES :=
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)
130 endif
131 ifneq ($$(LOCAL_PATH),$(core_local_path))
132 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH)
133 endif
134 core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
135 LOCAL_SRC_FILES :=
136endef
137
138# Find any native directories containing sub.mk files.
139core_native_dirs := $(strip $(call all-core-native-dirs,main))
140ifeq ($(core_native_dirs),)
141 $(error No native code defined for libcore)
142endif
143
144# Set up the default state.
145LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
146LOCAL_MODULE := $(core_magic_local_target)
147core_src_files :=
148
149# Include the sub.mk files.
150$(foreach dir, \
151 $(core_native_dirs), \
152 $(eval $(call include-core-native-dir,$(dir))))
153
154# Define the rules.
155LOCAL_SRC_FILES := $(core_src_files)
156LOCAL_MODULE := libjavacore
157include $(BUILD_STATIC_LIBRARY)
158
159# Deal with keystores required for security. Note: The path to this file
160# is hardcoded in TrustManagerFactoryImpl.java.
161ALL_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)