Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: runtime/tools/create_resources.py

Issue 125103004: Move service into VM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/tools/create_resources.py
diff --git a/runtime/tools/create_resources.py b/runtime/tools/create_resources.py
index 44685593e0cb19e5d918a1b079a4c6b0e9ada05d..ab8371d3d0f59efb0831635404748333e45c9ecd 100644
--- a/runtime/tools/create_resources.py
+++ b/runtime/tools/create_resources.py
@@ -13,7 +13,7 @@ from optparse import OptionParser
import re
from datetime import date
-def makeResources(root_dir, input_files):
+def makeResources(root_dir, input_files, table_name):
result = ''
resources = []
@@ -44,28 +44,39 @@ def makeResources(root_dir, input_files):
(resource_url, resource_name, os.stat(resource_file).st_size) );
# Write the resource table.
- result += 'Resources::resource_map_entry Resources::builtin_resources_[] = '
+ result += 'ResourcesEntry __%s_resources_[] = ' % table_name
result += '{\n'
for res in resources:
result += ' { "%s", %s, %d },\n' % res
+ result += ' { 0, 0, 0 },\n'
result += '};\n\n'
- result += 'const intptr_t Resources::builtin_resources_count_ '
- result += '= %d;\n' % len(resources)
return result
-def makeFile(output_file, root_dir, input_files):
+def makeFile(output_file, root_dir, input_files, outer_namespace,
+ inner_namespace, table_name):
cc_text = '''
// Copyright (c) %d, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
''' % date.today().year
- cc_text += '#include "bin/resources.h"\n\n'
- cc_text += 'namespace dart {\n'
- cc_text += 'namespace bin {\n'
- cc_text += makeResources(root_dir, input_files)
- cc_text += '} // namespace bin\n} // namespace dart\n'
+ cc_text += 'namespace %s {\n' % outer_namespace
+ if inner_namespace != None:
+ cc_text += 'namespace %s {\n' % inner_namespace
+ cc_text += '''
+struct ResourcesEntry {
+ const char* path_;
+ const char* resource_;
+ int length_;
+};
+
+'''
+ cc_text += makeResources(root_dir, input_files, table_name)
+ cc_text += '\n'
+ if inner_namespace != None:
+ cc_text += '} // namespace %s\n' % inner_namespace
+ cc_text += '} // namespace %s\n' % outer_namespace
open(output_file, 'w').write(cc_text)
return True
@@ -80,10 +91,23 @@ def main(args):
parser.add_option("--root_prefix",
action="store", type="string",
help="root directory for resources")
+ parser.add_option("--outer_namespace",
+ action="store", type="string",
+ help="outer C++ namespace",
+ default="dart")
+ parser.add_option("--inner_namespace",
+ action="store", type="string",
+ help="inner C++ namespace")
+ parser.add_option("--table_name",
+ action="store", type="string",
+ help="name of table")
(options, args) = parser.parse_args()
if not options.output:
sys.stderr.write('--output not specified\n')
return -1
+ if not options.table_name:
+ sys.stderr.write('--table_name not specified\n')
+ return -1
if len(args) == 0:
sys.stderr.write('No input files specified\n')
return -1
@@ -92,7 +116,9 @@ def main(args):
for arg in args:
files.append(arg)
- if not makeFile(options.output, options.root_prefix, files):
+ if not makeFile(options.output, options.root_prefix, files,
+ options.outer_namespace, options.inner_namespace,
+ options.table_name):
return -1
return 0
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698