blob: c12ce9a74758e6edf80b4c3f3108fbd14b933ebe [file] [log] [blame]
The Android Open Source Projectadc854b2009-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
32
33
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
50$(LOCAL_INSTALLED_MODULE): run-core-tests
51
52
53
54# Definitions to copy the core-tests runner script.
55
56include $(CLEAR_VARS)
57LOCAL_SRC_FILES := run-core-tests
58LOCAL_MODULE_CLASS := EXECUTABLES
59LOCAL_MODULE_TAGS := tests
60LOCAL_MODULE := run-core-tests
61include $(BUILD_PREBUILT)
62
63
64
65# Build all of the native code, if any is present.
66
67include $(CLEAR_VARS)
68
69# Get the list of all native directories that contain sub.mk files.
70# We're using "sub.mk" to make it clear that these are not typical
71# android makefiles.
72define all-core-native-dirs
73$(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null))
74endef
75
76core_magic_local_target := ...//::default:://...
77core_local_path := $(LOCAL_PATH)
78
79# Include a submakefile, resolve its source file locations,
80# and stick them on core_src_files. The submakefiles are
81# free to append to LOCAL_C_INCLUDES, LOCAL_SHARED_LIBRARIES, etc.
82#
83# $(1): directory containing the makefile to include
84define include-core-native-dir
85 LOCAL_SRC_FILES :=
86 include $(LOCAL_PATH)/$(1)/sub.mk
87 ifneq ($$(LOCAL_MODULE),$(core_magic_local_target))
88 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not include CLEAR_VARS \
89 or define LOCAL_MODULE)
90 endif
91 ifneq ($$(LOCAL_PATH),$(core_local_path))
92 $$(error $(LOCAL_PATH)/$(1)/sub.mk should not define LOCAL_PATH)
93 endif
94 core_src_files += $$(addprefix $(1)/,$$(LOCAL_SRC_FILES))
95 LOCAL_SRC_FILES :=
96endef
97
98# Find any native directories containing sub.mk files.
99core_native_dirs := $(strip $(call all-core-native-dirs,main))
100ifeq ($(core_native_dirs),)
101 $(error No native code defined for libcore)
102endif
103
104# Set up the default state.
105LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
106LOCAL_MODULE := $(core_magic_local_target)
107core_src_files :=
108
109# Include the sub.mk files.
110$(foreach dir, \
111 $(core_native_dirs), \
112 $(eval $(call include-core-native-dir,$(dir))))
113
114# Define the rules.
115LOCAL_SRC_FILES := $(core_src_files)
116LOCAL_MODULE := libjavacore
117include $(BUILD_STATIC_LIBRARY)
118
119# Deal with keystores required for security. Note: The path to this file
120# is hardcoded in TrustManagerFactoryImpl.java.
121ALL_PREBUILT += $(TARGET_OUT)/etc/security/cacerts.bks
122$(TARGET_OUT)/etc/security/cacerts.bks : $(LOCAL_PATH)/security/src/main/files/cacerts.bks | $(ACP)
123 $(transform-prebuilt-to-target)