summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 04:37:06 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-04 04:37:06 +0000
commitf35bcea85ccfefe9324dcb80e110f843a1f8b5bb (patch)
tree9081f0bf141414ca28c4abe999226487cf9b3cd6
parent363f7b2a58deccb0054b87e3cbdbb64a287b0465 (diff)
downloadchromium_src-f35bcea85ccfefe9324dcb80e110f843a1f8b5bb.zip
chromium_src-f35bcea85ccfefe9324dcb80e110f843a1f8b5bb.tar.gz
chromium_src-f35bcea85ccfefe9324dcb80e110f843a1f8b5bb.tar.bz2
Move the logic for getting icu data out of icu_util
Currently, how to build/link the icu data is split between common.gypi and icu_util.cc Move it out of icu_util.cc and put it in common.gypi Also, remove icudata from the dependency list in url.gyp. icuuc depends on icudata and specifying icuuc alone is sufficient. Otherwise, ninja complains about multiple rules specified for icudata and a circular dependency when icu_use_data_file_flag is set to 1 on Linux. A similar change has to be made in third_party/WebKit/Source/web/web.gyp. (see https://codereview.chromium.org/93053003/ ) This CL does not change the actual build process, yet. It's just to prepare to switch to "icu*.dat" on Mac and Linux. BUG=72633 TEST=All the configuration/builds go fine on all platforms. Review URL: https://codereview.chromium.org/89863002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238567 0039d316-1c4b-4281-b951-d872f2087c98
-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',
],