Initialize ICU data files in d8 and disable i18n for other code samples
BUG=v8:2745 R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/18899002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15572 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
189c0782d3
commit
518ca395cc
@ -137,6 +137,8 @@ void DispatchDebugMessages() {
|
||||
|
||||
int RunMain(int argc, char* argv[]) {
|
||||
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
|
||||
v8::V8::SetFlagsFromString("--noenable_i18n",
|
||||
static_cast<int>(strlen("--noenable_i18n")));
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <v8.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@ -634,6 +635,8 @@ int main(int argc, char* argv[]) {
|
||||
fprintf(stderr, "No script was specified.\n");
|
||||
return 1;
|
||||
}
|
||||
V8::SetFlagsFromString("--noenable_i18n",
|
||||
static_cast<int>(strlen("--noenable_i18n")));
|
||||
Isolate* isolate = Isolate::GetCurrent();
|
||||
HandleScope scope(isolate);
|
||||
Handle<String> source = ReadFile(file);
|
||||
|
@ -67,6 +67,8 @@ static bool run_shell;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
|
||||
v8::V8::SetFlagsFromString("--noenable_i18n",
|
||||
static_cast<int>(strlen("--noenable_i18n")));
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
run_shell = (argc == 1);
|
||||
int result;
|
||||
|
@ -68,6 +68,10 @@
|
||||
#include "v8.h"
|
||||
#endif // V8_SHARED
|
||||
|
||||
#if defined(V8_I18N_SUPPORT)
|
||||
#include "icu_util.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
#include <unistd.h> // NOLINT
|
||||
#endif
|
||||
@ -1582,6 +1586,9 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
|
||||
int Shell::Main(int argc, char* argv[]) {
|
||||
if (!SetOptions(argc, argv)) return 1;
|
||||
#if defined(V8_I18N_SUPPORT)
|
||||
InitializeICU();
|
||||
#endif
|
||||
#ifndef V8_SHARED
|
||||
i::FLAG_harmony_array_buffer = true;
|
||||
i::FLAG_harmony_typed_arrays = true;
|
||||
|
10
src/d8.gyp
10
src/d8.gyp
@ -31,6 +31,7 @@
|
||||
'console%': '',
|
||||
# Enable support for Intel VTune. Supported on ia32/x64 only
|
||||
'v8_enable_vtunejit%': 0,
|
||||
'v8_enable_i18n_support%': 0,
|
||||
},
|
||||
'includes': ['../build/common.gypi'],
|
||||
'targets': [
|
||||
@ -78,6 +79,15 @@
|
||||
'../src/third_party/vtune/v8vtune.gyp:v8_vtune',
|
||||
],
|
||||
}],
|
||||
['v8_enable_i18n_support==1', {
|
||||
'sources': [
|
||||
'icu_util.cc',
|
||||
'icu_util.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'<(DEPTH)/third_party/icu/icu.gyp:*',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
|
60
src/icu_util.cc
Normal file
60
src/icu_util.cc
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "icu_util.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
#include "unicode/putil.h"
|
||||
#include "unicode/udata.h"
|
||||
|
||||
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
|
||||
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
|
||||
bool InitializeICU() {
|
||||
#if defined(_WIN32)
|
||||
// We expect to find the ICU data module alongside the current module.
|
||||
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
|
||||
if (!module) return false;
|
||||
|
||||
FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
|
||||
if (!addr) return false;
|
||||
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
|
||||
return err == U_ZERO_ERROR;
|
||||
#else
|
||||
// Mac/Linux bundle the ICU data in.
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace v8
|
40
src/icu_util.h
Normal file
40
src/icu_util.h
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2013 the V8 project authors. All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#ifndef V8_ICU_UTIL_H_
|
||||
#define V8_ICU_UTIL_H_
|
||||
|
||||
namespace v8 {
|
||||
|
||||
// Call this function to load ICU's data tables for the current process. This
|
||||
// function should be called before ICU is used.
|
||||
bool InitializeICU();
|
||||
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_ICU_UTIL_H_
|
Loading…
Reference in New Issue
Block a user