Generate NDK headers and a new public library libicu
Symbol selection
- Expose the C symbols listed in libicu_export.txt
- Currently, we focus on exposing the symbols used by the ART mainline
module, and selecting a logical set of symbols from uchar.h,
ustring.h, uloc.h, uversion.h and utypes.h.
- The symbols are further filtered by checking whether we have
provided the same functionality in Java by ICU4J/ICU4C via
android.icu.*/java.* classes. The Java APIs are reviewed/proved useful
and it could reduce the maintenance cost since ICU4J mostly mirrors
the behavior of ICU4C and code changes/bug fixes are often applied
in both places. But here is the exception:
1. uloc_setDefault
Many places in libcore assumes Locale, ULocale, and ICU4C has the same
default locale. App setting a different default locale in ICU4C will
likely break things.
2. uloc_getDefault
We could expose uloc_getDefault, but since uloc_setDefault is not
exposed, uloc_getDefault becomes a shortcut function to obtain
the default Locale from ULocale.getDefault or even framework's
getResources().getConfiguration().locale. Such behavior is not
well-documented in uloc_getDefault. Also, without ART managed
runtime, e.g. standalone executable binary, the behavior could be
undefined. Probably Android should provide JNI interop method/other
C API to get the Android system default locale, but not via
uloc_getDefault.
- Other symbols excluded from the above headers
u_UCharsToChars
u_austrcpy
u_austrncpy
u_charsToUChars
u_getFC_NFKC_Closure
u_strCompareIter
u_strFromJavaModifiedUTF8WithSub
u_strFromWCS
u_strToJavaModifiedUTF8
u_strToWCS
u_uastrcpy
u_uastrncpy
u_unescape
u_unescapeAt
u_versionFromString
u_versionFromUString
uloc_acceptLanguageFromHTTP
uloc_getLCID
uloc_getLocaleForLCID
uloc_getParent
Symbol name
- libicu.so will have symbols for the exact same functionality
as the symbols in libicuuc.so and libicui18n.so,
e.g. u_isalpha and u_isalpha_66. The ICU-version-specific symbol
u_isalpha_66 is kept for app compatability because many app has been
using it even though the version number increases for every platform
release. u_isalpha is implemented as a shim of u_isalpha_66 in
shim.cpp.
Code transformation
- shim.cpp, libicu.map.txt and the headers are generated by running
the new generate_ndk.py script
Test
- CTS will be in the next CL.
Bug: 160350521
Test: ./generate_ndk.py
Test: m droid
Change-Id: I2eb6d5a0968c72bb6922221a971414de20273041
diff --git a/libicu/Android.bp b/libicu/Android.bp
new file mode 100644
index 0000000..e48eaec
--- /dev/null
+++ b/libicu/Android.bp
@@ -0,0 +1,51 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+ndk_library {
+ name: "libicu",
+ symbol_file: "libicu.map.txt",
+ first_version: "31",
+ unversioned_until: "current",
+}
+
+ndk_headers {
+ name: "libicu_ndk_headers",
+ from: "ndk_headers",
+ to: "",
+ srcs: ["ndk_headers/**/*.h"],
+ license: ":icu_license",
+}
+
+cc_library_shared {
+ name: "libicu",
+ defaults: ["icu4c_defaults"],
+ host_supported: true,
+ native_bridge_supported: true,
+ export_include_dirs: ["ndk_headers"],
+ // The whole implementation comes from the intermediate library libicu_static because
+ // ndk_headers/ has symbol name collisions with the headers in libicuuc/libicui18n.
+ whole_static_libs: ["libicu_static"],
+ shared_libs: [
+ "libicuuc",
+ "libicui18n",
+ ],
+ apex_available: [
+ "com.android.i18n",
+ ],
+ target: {
+ android: {
+ version_script: "libicu.map.txt",
+ },
+ },
+}