Commit a2b453d4 authored by loislo@chromium.org's avatar loislo@chromium.org

Revert "[blink-in-js] Migrate resources required for blink-in-js to grd - part 3"

This reverts commit 0ad77c5152a930f08e04a2db05ad5331c711333f.

It breaks compilation on Linux GN (dbg) which is tree closer.
http://build.chromium.org/p/chromium.linux/builders/Linux%20GN%20(dbg)

BUG=312586
TBR= dpranke@chromium.org, haraken@chromium.org, jochen@chromium.org

Review URL: https://codereview.chromium.org/557543004

git-svn-id: svn://svn.chromium.org/blink/trunk@181957 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 17f96580
......@@ -15,7 +15,6 @@
#include "core/PrivateScriptSourcesForTesting.h"
#endif
#include "core/dom/ExceptionCode.h"
#include "platform/PlatformResourceLoader.h"
namespace blink {
......@@ -40,10 +39,10 @@ static void dumpV8Message(v8::Handle<v8::Message> message)
fprintf(stderr, "%s (line %d): %s\n", fileName.utf8().data(), lineNumber, toCoreString(errorMessage).utf8().data());
}
static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String scriptClassName, const char* source, size_t size)
static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String scriptClassName, const unsigned char* source, size_t size)
{
v8::TryCatch block;
String sourceString(source, size);
String sourceString(reinterpret_cast<const char*>(source), size);
String fileName = scriptClassName + ".js";
v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName, TextPosition::minimumPosition(), 0, isolate, NotSharableCrossOrigin, V8CacheOptionsOff);
if (block.HasCaught()) {
......@@ -83,8 +82,7 @@ static void installPrivateScript(v8::Isolate* isolate, String className)
// by make_private_script_source.py.
for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) {
if (className == kPrivateScriptSources[index].className) {
String resourceData = loadResourceAsASCIIString(kPrivateScriptSources[index].resourceFile);
compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, resourceData.utf8().data(), resourceData.length());
compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
compiledScriptCount++;
}
}
......@@ -109,8 +107,7 @@ static v8::Handle<v8::Value> installPrivateScriptRunner(v8::Isolate* isolate)
fprintf(stderr, "Private script error: Target source code was not found. (Class name = %s)\n", className.utf8().data());
RELEASE_ASSERT_NOT_REACHED();
}
String resourceData = loadResourceAsASCIIString(kPrivateScriptSources[index].resourceFile);
return compileAndRunPrivateScript(isolate, className, resourceData.utf8().data(), resourceData.length());
return compileAndRunPrivateScript(isolate, className, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
}
static v8::Handle<v8::Object> classObjectOfPrivateScript(ScriptState* scriptState, String className)
......
......@@ -9,7 +9,6 @@ Usage:
python make_private_script_source.py DESTINATION_FILE SOURCE_FILES
"""
import optparse
import os
import re
import sys
......@@ -33,51 +32,34 @@ def extract_partial_interface_name(filename):
def main():
parser = optparse.OptionParser()
parser.add_option('--for-testing', action="store_true", default=False)
options, args = parser.parse_args()
output_filename = args[0]
input_filenames = args[1:]
output_filename = sys.argv[1]
input_filenames = sys.argv[2:]
source_name, ext = os.path.splitext(os.path.basename(output_filename))
contents = []
contents.append('#ifndef %s_h\n' % source_name)
contents.append('#define %s_h\n' % source_name)
if options.for_testing:
for input_filename in input_filenames:
class_name, ext = os.path.splitext(os.path.basename(input_filename))
with open(input_filename) as input_file:
input_text = input_file.read()
hex_values = ['0x{0:02x}'.format(ord(char)) for char in input_text]
contents.append('const char kSourceOf%s[] = {\n %s\n};\n\n' % (
contents.append('const unsigned char kSourceOf%s[] = {\n %s\n};\n\n' % (
class_name, ', '.join(hex_values)))
contents.append('struct %s {' % source_name)
contents.append("""
const char* scriptClassName;
const char* className;
""")
if options.for_testing:
contents.append("""
const char* source;
size_t size;""")
else:
contents.append('const char* resourceFile;')
contents.append("""
const unsigned char* source;
size_t size;
};
""")
contents.append('struct %s k%s[] = {\n' % (source_name, source_name))
for input_filename in input_filenames:
script_class_name, ext = os.path.splitext(os.path.basename(input_filename))
class_name = extract_partial_interface_name(input_filename) or script_class_name
if options.for_testing:
contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (script_class_name, class_name, script_class_name, script_class_name))
else:
contents.append(' { "%s", "%s", "%s.js" },\n' % (script_class_name, class_name, script_class_name))
contents.append('};\n')
contents.append('#endif // %s_h\n' % source_name)
with open(output_filename, 'w') as output_file:
output_file.write("".join(contents))
......
......@@ -183,7 +183,6 @@
'action': [
'python',
'../build/scripts/make_private_script_source.py',
'--for-testing',
'<@(_outputs)',
'<@(_private_script_files)'
],
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "PlatformResourceLoader.h"
#include "public/platform/Platform.h"
#include "public/platform/WebData.h"
namespace blink {
String loadResourceAsASCIIString(const char* resource)
{
const WebData& resourceData = Platform::current()->loadResource(resource);
String dataString(resourceData.data(), resourceData.size());
ASSERT(!dataString.isEmpty() && dataString.containsOnlyASCII());
return dataString;
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PlatformResourceLoader_h
#define PlatformResourceLoader_h
#include "platform/PlatformExport.h"
#include "wtf/text/WTFString.h"
namespace blink {
PLATFORM_EXPORT String loadResourceAsASCIIString(const char* resource);
} // namespace blink
#endif // PlatformResourceLoader_h
......@@ -91,8 +91,6 @@
'PlatformKeyboardEvent.cpp',
'PlatformKeyboardEvent.h',
'PlatformMouseEvent.h',
'PlatformResourceLoader.cpp',
'PlatformResourceLoader.h',
'PlatformScreen.cpp',
'PlatformScreen.h',
'PlatformThreadData.cpp',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment