summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/i18n/icu_util.cc41
-rw-r--r--build/common.gypi15
-rw-r--r--url/url.gyp1
3 files changed, 27 insertions, 30 deletions
diff --git a/base/i18n/icu_util.cc b/base/i18n/icu_util.cc
index 3e1353b4..e5c6984 100644
--- a/base/i18n/icu_util.cc
+++ b/base/i18n/icu_util.cc
@@ -29,18 +29,6 @@
#define ICU_UTIL_DATA_SHARED 1
#define ICU_UTIL_DATA_STATIC 2
-#ifndef ICU_UTIL_DATA_IMPL
-
-#if defined(OS_WIN)
-#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED
-#elif defined(OS_IOS)
-#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE
-#else
-#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC
-#endif
-
-#endif // ICU_UTIL_DATA_IMPL
-
#if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
#define ICU_UTIL_DATA_FILE_NAME "icudt" U_ICU_VERSION_SHORT "l.dat"
#elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED
@@ -86,26 +74,12 @@ bool InitializeICU() {
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
return err == U_ZERO_ERROR;
#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC)
- // Mac/Linux bundle the ICU data in.
+ // The ICU data is statically linked.
return true;
#elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
-#if !defined(OS_MACOSX)
- // For now, expect the data file to be alongside the executable.
- // This is sufficient while we work on unit tests, but will eventually
- // likely live in a data directory.
- FilePath data_path;
- bool path_ok = PathService::Get(base::DIR_EXE, &data_path);
- DCHECK(path_ok);
- u_setDataDirectory(data_path.value().c_str());
- // Only look for the packaged data file;
- // the default behavior is to look for individual files.
- UErrorCode err = U_ZERO_ERROR;
- udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
- return err == U_ZERO_ERROR;
-#else
// If the ICU data directory is set, ICU won't actually load the data until
// it is needed. This can fail if the process is sandboxed at that time.
- // Instead, Mac maps the file in and hands off the data so the sandbox won't
+ // Instead, we map the file in and hand off the data so the sandbox won't
// cause any problems.
// Chrome doesn't normally shut down ICU, so the mapped data shouldn't ever
@@ -113,12 +87,22 @@ bool InitializeICU() {
CR_DEFINE_STATIC_LOCAL(base::MemoryMappedFile, mapped_file, ());
if (!mapped_file.IsValid()) {
// Assume it is in the framework bundle's Resources directory.
+#if !defined(OS_MACOSX)
+ // For now, expect the data file to be alongside the executable.
+ // This is sufficient while we work on unit tests, but will eventually
+ // likely live in a data directory.
+ FilePath data_path;
+ bool path_ok = PathService::Get(base::DIR_EXE, &data_path);
+ DCHECK(path_ok);
+ data_path = data_path.AppendASCII(ICU_UTIL_DATA_FILE_NAME);
+#else
FilePath data_path =
base::mac::PathForFrameworkBundleResource(CFSTR(ICU_UTIL_DATA_FILE_NAME));
if (data_path.empty()) {
DLOG(ERROR) << ICU_UTIL_DATA_FILE_NAME << " not found in bundle";
return false;
}
+#endif // OS check
if (!mapped_file.Initialize(data_path)) {
DLOG(ERROR) << "Couldn't mmap " << data_path.value();
return false;
@@ -127,7 +111,6 @@ bool InitializeICU() {
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(const_cast<uint8*>(mapped_file.data()), &err);
return err == U_ZERO_ERROR;
-#endif // OS check
#endif
}
diff --git a/build/common.gypi b/build/common.gypi
index d6d48e5..d9eed45 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1212,6 +1212,10 @@
# IPC fuzzer is disabled by default.
'enable_ipc_fuzzer%': 0,
+ # Whether or not to use "icu*.dat" file for ICU data.
+ # Do not use it by default.
+ 'icu_use_data_file_flag%': 0,
+
'conditions': [
# The version of GCC in use, set later in platforms that use GCC and have
# not explicitly chosen to build with clang. Currently, this means all
@@ -2152,6 +2156,17 @@
['use_udev==1', {
'defines': ['USE_UDEV'],
}],
+ ['icu_use_data_file_flag==1', {
+ 'defines': ['ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE'],
+ }, { # else icu_use_data_file_flag !=1
+ 'conditions': [
+ ['OS=="win"', {
+ 'defines': ['ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_SHARED'],
+ }, {
+ 'defines': ['ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC'],
+ }],
+ ],
+ }],
['fastbuild!=0', {
'xcode_settings': {
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
diff --git a/url/url.gyp b/url/url.gyp
index 9dc949a..d57c476 100644
--- a/url/url.gyp
+++ b/url/url.gyp
@@ -16,7 +16,6 @@
'dependencies': [
'../base/base.gyp:base',
'../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '../third_party/icu/icu.gyp:icudata',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
],