1#
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19# User-supplied locale service providers (using the java.text.spi or
20# java.util.spi mechanisms) are not supported in Android:
21#
22# http://developer.android.com/reference/java/util/Locale.html
23
24icu4j_src_files := \
25    $(filter-out main/classes/localespi/%, \
26    $(call all-java-files-under,main/classes))
27
28icu4j_test_src_files := \
29    $(filter-out main/tests/localespi/%, \
30    $(call all-java-files-under,main/tests))
31
32# Not all src dirs contain resources, some instead contain other random files
33# that should not be included as resources. The ones that should be included
34# can be identifed by the fact that they contain particular subdir trees.
35
36define all-subdir-with-subdir
37$(patsubst $(LOCAL_PATH)/%/$(2),%,$(wildcard $(LOCAL_PATH)/$(1)/$(2)))
38endef
39
40icu4j_resource_dirs := \
41    $(filter-out main/classes/localespi/%, \
42    $(call all-subdir-with-subdir,main/classes/*/src,com/ibm/icu))
43
44icu4j_test_resource_dirs := \
45    $(filter-out main/tests/localespi/%, \
46    $(call all-subdir-with-subdir,main/tests/*/src,com/ibm/icu/dev))
47
48# For each data *.jar file, define a corresponding icu4j-* target.
49icu4j_data_jars := \
50    $(shell find $(LOCAL_PATH)/main/shared/data -name "*.jar" \
51    | sed "s,^$(LOCAL_PATH)/\(.*/\(.*\)\.jar\)$$,icu4j-\2:\1,")
52
53include $(CLEAR_VARS)
54LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := $(icu4j_data_jars)
55include $(BUILD_MULTI_PREBUILT)
56
57include $(CLEAR_VARS)
58LOCAL_IS_HOST_MODULE := true
59LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := $(subst :,-host:,$(icu4j_data_jars))
60include $(BUILD_MULTI_PREBUILT)
61
62include $(CLEAR_VARS)
63LOCAL_SRC_FILES := $(icu4j_src_files)
64LOCAL_JAVA_RESOURCE_DIRS := $(icu4j_resource_dirs)
65LOCAL_DONT_DELETE_JAR_DIRS := true
66LOCAL_MODULE := icu4j
67include $(BUILD_STATIC_JAVA_LIBRARY)
68
69# Path to the ICU4C data files in the Android device file system:
70icu4c_data := /system/usr/icu
71icu4j_config_root := $(LOCAL_PATH)/main/classes/core/src
72include external/icu/icu4j/adjust_icudt_path.mk
73
74include $(CLEAR_VARS)
75LOCAL_SRC_FILES := $(icu4j_src_files)
76LOCAL_JAVA_RESOURCE_DIRS := $(icu4j_resource_dirs)
77LOCAL_STATIC_JAVA_LIBRARIES := icu4j-icudata-host icu4j-icutzdata-host
78LOCAL_DONT_DELETE_JAR_DIRS := true
79LOCAL_MODULE := icu4j-host
80include $(BUILD_HOST_JAVA_LIBRARY)
81
82ifeq ($(HOST_OS),linux)
83include $(CLEAR_VARS)
84LOCAL_SRC_FILES := $(icu4j_src_files)
85LOCAL_JAVA_RESOURCE_DIRS := $(icu4j_resource_dirs)
86LOCAL_STATIC_JAVA_LIBRARIES := icu4j-icudata-host icu4j-icutzdata-host
87LOCAL_DONT_DELETE_JAR_DIRS := true
88LOCAL_MODULE := icu4j-hostdex
89include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
90endif  # HOST_OS == linux
91
92include $(CLEAR_VARS)
93LOCAL_SRC_FILES := $(icu4j_test_src_files)
94LOCAL_JAVA_RESOURCE_DIRS := $(icu4j_test_resource_dirs)
95LOCAL_STATIC_JAVA_LIBRARIES := icu4j-testdata
96LOCAL_DONT_DELETE_JAR_DIRS := true
97LOCAL_JAVA_LIBRARIES := icu4j
98LOCAL_MODULE := icu4j-tests
99include $(BUILD_STATIC_JAVA_LIBRARY)
100
101$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS += \
102    -C "$(LOCAL_PATH)/main/tests/core/src" \
103    "com/ibm/icu/dev/test/serializable/data"
104
105#==========================================================
106# build ICU tests for host for testing purposes
107#
108# Run the tests using the ICU4J test framework with the following command:
109#   java -cp ${ANDROID_BUILD_TOP}/out/host/linux-x86/framework/icu4j-host.jar:${ANDROID_BUILD_TOP}/out/host/linux-x86/framework/icu4j-tests-host.jar com.ibm.icu.dev.test.TestAll
110#==========================================================
111include $(CLEAR_VARS)
112LOCAL_SRC_FILES := $(icu4j_test_src_files)
113LOCAL_JAVA_RESOURCE_DIRS := $(icu4j_test_resource_dirs)
114LOCAL_STATIC_JAVA_LIBRARIES := icu4j-testdata-host
115LOCAL_DONT_DELETE_JAR_DIRS := true
116LOCAL_JAVA_LIBRARIES := icu4j-host
117LOCAL_MODULE := icu4j-tests-host
118include $(BUILD_HOST_JAVA_LIBRARY)
119
120$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS += \
121    -C "$(LOCAL_PATH)/main/tests/core/src" \
122    "com/ibm/icu/dev/test/serializable/data"
123
124ifeq ($(HOST_OS),linux)
125include $(CLEAR_VARS)
126LOCAL_SRC_FILES := $(icu4j_test_src_files)
127LOCAL_JAVA_RESOURCE_DIRS := $(icu4j_test_resource_dirs)
128LOCAL_STATIC_JAVA_LIBRARIES := icu4j-testdata-host
129LOCAL_DONT_DELETE_JAR_DIRS := true
130LOCAL_JAVA_LIBRARIES := icu4j-hostdex
131LOCAL_MODULE := icu4j-tests-hostdex
132include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
133
134$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS += \
135    -C "$(LOCAL_PATH)/main/tests/core/src" \
136    "com/ibm/icu/dev/test/serializable/data"
137
138endif  # HOST_OS == linux
139
140# LayoutLib (frameworks/base/tools/layoutlib) needs JarJar'd versions of the
141# icudata and icutzdata, so add rules for it.
142include $(CLEAR_VARS)
143LOCAL_STATIC_JAVA_LIBRARIES := icu4j-icudata-host
144LOCAL_JARJAR_RULES := $(LOCAL_PATH)/liblayout-jarjar-rules.txt
145LOCAL_MODULE := icu4j-icudata-host-jarjar
146include $(BUILD_HOST_JAVA_LIBRARY)
147
148include $(CLEAR_VARS)
149LOCAL_STATIC_JAVA_LIBRARIES := icu4j-icutzdata-host
150LOCAL_JARJAR_RULES := $(LOCAL_PATH)/liblayout-jarjar-rules.txt
151LOCAL_MODULE := icu4j-icutzdata-host-jarjar
152include $(BUILD_HOST_JAVA_LIBRARY)
153