| 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 | |
| 32 | |
| 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 | |
| 50 | $(LOCAL_INSTALLED_MODULE): run-core-tests |
| 51 | |
| 52 | |
| 53 | |
| 54 | # Definitions to copy the core-tests runner script. |
| 55 | |
| 56 | include $(CLEAR_VARS) |
| 57 | LOCAL_SRC_FILES := run-core-tests |
| 58 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 59 | LOCAL_MODULE_TAGS := tests |
| 60 | LOCAL_MODULE := run-core-tests |
| 61 | include $(BUILD_PREBUILT) |
| 62 | |
| 63 | |
| 64 | |
| 65 | # Build all of the native code, if any is present. |
| 66 | |
| 67 | include $(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. |
| 72 | define all-core-native-dirs |
| 73 | $(patsubst %/sub.mk,%,$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/native/sub.mk 2> /dev/null)) |
| 74 | endef |
| 75 | |
| 76 | core_magic_local_target := ...//::default:://... |
| 77 | core_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 |
| 84 | define 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 := |
| 96 | endef |
| 97 | |
| 98 | # Find any native directories containing sub.mk files. |
| 99 | core_native_dirs := $(strip $(call all-core-native-dirs,main)) |
| 100 | ifeq ($(core_native_dirs),) |
| 101 | $(error No native code defined for libcore) |
| 102 | endif |
| 103 | |
| 104 | # Set up the default state. |
| 105 | LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) |
| 106 | LOCAL_MODULE := $(core_magic_local_target) |
| 107 | core_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. |
| 115 | LOCAL_SRC_FILES := $(core_src_files) |
| 116 | LOCAL_MODULE := libjavacore |
| 117 | include $(BUILD_STATIC_LIBRARY) |
| 118 | |
| 119 | # Deal with keystores required for security. Note: The path to this file |
| 120 | # is hardcoded in TrustManagerFactoryImpl.java. |
| 121 | ALL_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) |