mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:03:19 +00:00
5475ab6fbb
This CL adds rules to the GN build for building run_vm_tests for Fuchsia. It also adds a wrapper program in //runtime/bin/run_vm_tests_fuchsia.cc and a file containing the output of 'run_vm_tests --list', //runtime/bin/fuchsia_vm_tests.txt. The wrapper program and text file make it easier to run the tests on Fuchsia, and should be able to go away once we are out of the bootstrapping phase. R=asiva@google.com Review URL: https://codereview.chromium.org/2187153003 .
100 lines
3 KiB
Python
Executable file
100 lines
3 KiB
Python
Executable file
#!/usr/bin/env python
|
|
#
|
|
# Copyright (c) 2011, 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.
|
|
#
|
|
# This python script creates a string literal in a C++ source file from a C++
|
|
# source template and text file.
|
|
|
|
import os
|
|
import sys
|
|
from os.path import join
|
|
import time
|
|
from optparse import OptionParser
|
|
|
|
|
|
def makeString(input_files):
|
|
result = ' '
|
|
for string_file in input_files:
|
|
if string_file.endswith('dart'):
|
|
fileHandle = open(string_file, 'rb')
|
|
lineCounter = 0
|
|
result += ' // ' + string_file + '\n '
|
|
for byte in fileHandle.read():
|
|
result += ' %d,' % ord(byte)
|
|
lineCounter += 1
|
|
if lineCounter == 10:
|
|
result += '\n '
|
|
lineCounter = 0
|
|
if lineCounter != 0:
|
|
result += '\n '
|
|
result += ' // Terminating null character.\n 0'
|
|
return result
|
|
|
|
|
|
def makeFile(output_file, input_cc_file, include, var_name, input_files):
|
|
bootstrap_cc_text = open(input_cc_file).read()
|
|
bootstrap_cc_text = bootstrap_cc_text.replace("{{INCLUDE}}", include)
|
|
bootstrap_cc_text = bootstrap_cc_text.replace("{{VAR_NAME}}", var_name)
|
|
bootstrap_cc_text = bootstrap_cc_text.replace("{{DART_SOURCE}}",
|
|
makeString(input_files))
|
|
open(output_file, 'w').write(bootstrap_cc_text)
|
|
return True
|
|
|
|
|
|
def main(args):
|
|
try:
|
|
# Parse input.
|
|
parser = OptionParser()
|
|
parser.add_option("--output",
|
|
action="store", type="string",
|
|
help="output file name")
|
|
parser.add_option("--input_cc",
|
|
action="store", type="string",
|
|
help="input template file")
|
|
parser.add_option("--include",
|
|
action="store", type="string",
|
|
help="variable name")
|
|
parser.add_option("--var_name",
|
|
action="store", type="string",
|
|
help="variable name")
|
|
|
|
(options, args) = parser.parse_args()
|
|
if not options.output:
|
|
sys.stderr.write('--output not specified\n')
|
|
return -1
|
|
if not len(options.input_cc):
|
|
sys.stderr.write('--input_cc not specified\n')
|
|
return -1
|
|
if not len(options.include):
|
|
sys.stderr.write('--include not specified\n')
|
|
return -1
|
|
if not len(options.var_name):
|
|
sys.stderr.write('--var_name not specified\n')
|
|
return -1
|
|
if len(args) == 0:
|
|
sys.stderr.write('No input files specified\n')
|
|
return -1
|
|
|
|
files = [ ]
|
|
for arg in args:
|
|
files.append(arg)
|
|
|
|
if not makeFile(options.output,
|
|
options.input_cc,
|
|
options.include,
|
|
options.var_name,
|
|
files):
|
|
return -1
|
|
|
|
return 0
|
|
except Exception, inst:
|
|
sys.stderr.write('create_string_literal.py exception\n')
|
|
sys.stderr.write(str(inst))
|
|
sys.stderr.write('\n')
|
|
return -1
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv))
|