The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | LOCAL_PATH := $(call my-dir) |
| 2 | include $(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 | |
| 9 | define all-core-java-files |
| 10 | $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find */src/$(1)/java -name "*.java")) |
| 11 | endef |
| 12 | |
| 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) |
| 17 | endef |
| 18 | |
| 19 | LOCAL_SRC_FILES := $(call all-core-java-files,main) |
| 20 | LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,main) |
| 21 | |
| 22 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 23 | LOCAL_DX_FLAGS := --core-library |
| 24 | |
| 25 | LOCAL_NO_EMMA_INSTRUMENT := true |
| 26 | LOCAL_NO_EMMA_COMPILE := true |
| 27 | |
| 28 | LOCAL_MODULE := core |
| 29 | |
| 30 | include $(BUILD_JAVA_LIBRARY) |
| 31 | |
Jorg Pleumann | d967396 | 2009-04-02 08:23:31 -0700 | [diff] [blame] | 32 | core-intermediates := ${intermediates} |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 33 | |
| 34 | # Definitions to make the core-tests library. |
| 35 | |
| 36 | include $(CLEAR_VARS) |
| 37 | |
| 38 | LOCAL_SRC_FILES := $(call all-core-java-files,test) |
| 39 | LOCAL_JAVA_RESOURCE_DIRS := $(call all-core-resource-dirs,test) |
| 40 | |
| 41 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 42 | LOCAL_JAVA_LIBRARIES := core |
| 43 | LOCAL_DX_FLAGS := --core-library |
| 44 | |
| 45 | LOCAL_MODULE_TAGS := tests |
| 46 | LOCAL_MODULE := core-tests |
| 47 | |
| 48 | include $(BUILD_JAVA_LIBRARY) |
| 49 | |
Jorg Pleumann | d967396 | 2009-04-02 08:23:31 -0700 | [diff] [blame] | 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 |
| 53 | # on-the-fly. |
Aaron Kushner | df4d33a | 2009-04-29 02:57:17 -0700 | [diff] [blame] | 54 | TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/ |
Jorg Pleumann | d967396 | 2009-04-02 08:23:31 -0700 | [diff] [blame] | 55 | TMP_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. |
| 73 | HOST_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 Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 86 | $(LOCAL_INSTALLED_MODULE): run-core-tests |
| 87 | |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 88 | # Definitions to copy the core-tests runner script. |
| 89 | |
| 90 | include $(CLEAR_VARS) |
| 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) |
| 96 | |
Jorg Pleumann | d967396 | 2009-04-02 08:23:31 -0700 | [diff] [blame] | 97 | include $(CLEAR_VARS) |
| 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) |
The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 104 | |
| 105 | # Build all of the native code, if any is present. |
| 106 | |
| 107 | include $(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. |
| 112 | define all-core-native-dirs |
| 113 | $(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null)) |
| 114 | endef |
| 115 | |
| 116 | core_magic_local_target := ...//::default:://... |
| 117 | core_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 |
| 124 | define 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 := |
| 136 | endef |
| 137 | |
| 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) |
| 142 | endif |
| 143 | |
| 144 | # Set up the default state. |
| 145 | LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) |
| 146 | LOCAL_MODULE := $(core_magic_local_target) |
| 147 | core_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. |
| 155 | LOCAL_SRC_FILES := $(core_src_files) |
| 156 | LOCAL_MODULE := libjavacore |
| 157 | include $(BUILD_STATIC_LIBRARY) |
| 158 | |
| 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) |