From 51c03c3a71b106b5fb39a954f550d38e732786a6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 16 Jan 2015 15:54:38 -0800 Subject: [PATCH] mac: Initialize ICU in Node mode --- atom.gyp | 5 ++++- atom/app/atom_library_main.h | 3 +++ .../{atom_library_main.cc => atom_library_main.mm} | 12 ++++++++++++ atom/app/atom_main.cc | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) rename atom/app/{atom_library_main.cc => atom_library_main.mm} (56%) diff --git a/atom.gyp b/atom.gyp index 7aa21a9d5845..d8a539208b5a 100644 --- a/atom.gyp +++ b/atom.gyp @@ -340,8 +340,8 @@ 'chromium_src/chrome/browser/ui/views/color_chooser_win.cc', ], 'framework_sources': [ - 'atom/app/atom_library_main.cc', 'atom/app/atom_library_main.h', + 'atom/app/atom_library_main.mm', ], 'locales': [ 'am', 'ar', 'bg', 'bn', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', @@ -801,6 +801,9 @@ 'vendor', '<(libchromiumcontent_include_dir)', ], + 'defines': [ + 'PRODUCT_NAME="<(product_name)"', + ], 'export_dependent_settings': [ '<(project_name)_lib', ], diff --git a/atom/app/atom_library_main.h b/atom/app/atom_library_main.h index 0c0b814dd765..fba120c79247 100644 --- a/atom/app/atom_library_main.h +++ b/atom/app/atom_library_main.h @@ -11,6 +11,9 @@ extern "C" { __attribute__((visibility("default"))) int AtomMain(int argc, const char* argv[]); + +__attribute__((visibility("default"))) +void AtomInitializeICU(); } #endif // OS_MACOSX diff --git a/atom/app/atom_library_main.cc b/atom/app/atom_library_main.mm similarity index 56% rename from atom/app/atom_library_main.cc rename to atom/app/atom_library_main.mm index 352efba0f163..e4e455969594 100644 --- a/atom/app/atom_library_main.cc +++ b/atom/app/atom_library_main.mm @@ -5,6 +5,9 @@ #include "atom/app/atom_library_main.h" #include "atom/app/atom_main_delegate.h" +#include "base/i18n/icu_util.h" +#include "base/mac/bundle_locations.h" +#include "brightray/common/mac/main_application_bundle.h" #include "content/public/app/content_main.h" #if defined(OS_MACOSX) @@ -15,4 +18,13 @@ int AtomMain(int argc, const char* argv[]) { params.argv = argv; return content::ContentMain(params); } + +void AtomInitializeICU() { + base::mac::SetOverrideFrameworkBundlePath( + brightray::MainApplicationBundlePath() + .Append("Contents") + .Append("Frameworks") + .Append(PRODUCT_NAME " Framework.framework")); + base::i18n::InitializeICU(); +} #endif // OS_MACOSX diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc index 198c3cc2546a..603f2dc2bcf6 100644 --- a/atom/app/atom_main.cc +++ b/atom/app/atom_main.cc @@ -127,8 +127,10 @@ int main(int argc, const char* argv[]) { int main(int argc, const char* argv[]) { char* node_indicator = getenv("ATOM_SHELL_INTERNAL_RUN_AS_NODE"); - if (node_indicator != NULL && strcmp(node_indicator, "1") == 0) + if (node_indicator != NULL && strcmp(node_indicator, "1") == 0) { + AtomInitializeICU(); return node::Start(argc, const_cast(argv)); + } return AtomMain(argc, argv); }