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

Unified Diff: runtime/tools/gen_library_src_paths.py

Issue 2668353004: Windows: Link library sources into gen_snapshot/dart_bootstrap (Closed)
Patch Set: don't include non-dart files, make symbols static Created 3 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/lib/libgen_in.cc ('k') | runtime/vm/bootstrap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/tools/gen_library_src_paths.py
diff --git a/runtime/tools/gen_library_src_paths.py b/runtime/tools/gen_library_src_paths.py
index 8a55118f0a9bfdce58e3bb367fdbb46c7a5f9f4f..07505c8fca150b6fdbd0c23f45d8ee1f6aadc7cd 100755
--- a/runtime/tools/gen_library_src_paths.py
+++ b/runtime/tools/gen_library_src_paths.py
@@ -16,31 +16,40 @@ from optparse import OptionParser
HOST_OS = utils.GuessOS()
-def makeString(input_file):
- # TODO(iposva): For now avoid creating overly long strings on Windows.
- if HOST_OS == 'win32':
- return 'NULL'
- result = '"'
+def makeString(input_file, var_name):
+ result = 'static const char ' + var_name + '[] = {\n '
fileHandle = open(input_file, 'rb')
lineCounter = 0
for byte in fileHandle.read():
- result += '\\x%02x' % ord(byte)
+ result += '\'\\x%02x' % ord(byte) + '\', '
lineCounter += 1
if lineCounter == 19:
- result += '"\n "'
+ result += '\n '
lineCounter = 0
- result += '"'
+ result += '0};\n'
return result
+def makeSourceArrays(in_files):
+ result = '';
+ file_count = 0;
+ for string_file in in_files:
+ if string_file.endswith('.dart'):
+ file_count += 1
+ file_string = makeString(string_file, "source_array_" + str(file_count))
+ result += file_string
+ return result
def makeFile(output_file, input_cc_file, include, var_name, lib_name, in_files):
part_index = [ ]
bootstrap_cc_text = open(input_cc_file).read()
+ bootstrap_cc_text = bootstrap_cc_text.replace("{{SOURCE_ARRAYS}}", makeSourceArrays(in_files))
bootstrap_cc_text = bootstrap_cc_text.replace("{{INCLUDE}}", include)
bootstrap_cc_text = bootstrap_cc_text.replace("{{VAR_NAME}}", var_name)
main_file_found = False
+ file_count = 0
for string_file in in_files:
if string_file.endswith('.dart'):
+ file_count += 1
if (not main_file_found):
inpt = open(string_file, 'r')
for line in inpt:
@@ -51,7 +60,7 @@ def makeFile(output_file, input_cc_file, include, var_name, lib_name, in_files):
"{{LIBRARY_SOURCE_MAP}}",
' "' + lib_name + '",\n "' +
os.path.abspath(string_file).replace('\\', '\\\\') + '",\n' +
- ' ' + makeString(string_file) + ',\n')
+ ' source_array_' + str(file_count) + ',\n')
inpt.close()
if (main_file_found):
continue
@@ -59,14 +68,13 @@ def makeFile(output_file, input_cc_file, include, var_name, lib_name, in_files):
os.path.basename(string_file).replace('\\', '\\\\') + '",\n')
part_index.append(' "' +
os.path.abspath(string_file).replace('\\', '\\\\') + '",\n')
- part_index.append(' ' + makeString(string_file) + ',\n\n')
+ part_index.append(' source_array_' + str(file_count) + ',\n\n')
bootstrap_cc_text = bootstrap_cc_text.replace("{{LIBRARY_SOURCE_MAP}}", '')
bootstrap_cc_text = bootstrap_cc_text.replace("{{PART_SOURCE_MAP}}",
''.join(part_index))
open(output_file, 'w').write(bootstrap_cc_text)
return True
-
def main(args):
try:
# Parse input.
« no previous file with comments | « runtime/lib/libgen_in.cc ('k') | runtime/vm/bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698