| Index: frog.py
|
| ===================================================================
|
| --- frog.py (revision 1140)
|
| +++ frog.py (working copy)
|
| @@ -18,10 +18,13 @@
|
| import subprocess
|
| import sys
|
|
|
| -from os.path import dirname, join, realpath
|
|
|
| +from os.path import dirname, join, realpath, exists
|
| +
|
| HOME = dirname(realpath(__file__))
|
| -DART = join(HOME, 'bin/dart_bin')
|
| +sys.path.append(join(HOME, os.pardir, 'tools'))
|
| +import utils
|
| +
|
| CODE = '''#import('%(HOME)s/lang.dart');
|
| #import('%(HOME)s/file_system_vm.dart');
|
|
|
| @@ -40,7 +43,22 @@
|
| </html>
|
| '''
|
|
|
| +def GetDart():
|
| + # Try a release version
|
| + dart = utils.GetDartRunner('release', 'ia32', 'vm')
|
| + if exists(dart): return dart
|
| + # Try at the top level
|
| + dart = join(os.pardir, dart)
|
| + if exists(dart): return dart
|
|
|
| + # Try a debug version
|
| + dart = utils.GetDartRunner('debug', 'ia32', 'vm')
|
| + if exists(dart): return dart
|
| + # Try at the top level
|
| + dart = join(os.pardir, dart)
|
| + return dart
|
| +
|
| +
|
| def execute(cmd):
|
| """Execute a command in a subprocess. """
|
| try:
|
| @@ -87,7 +105,7 @@
|
|
|
| optionParser.add_option('--verbose',
|
| help='Verbose output', default=False, action='store_true')
|
| -
|
| +
|
| optionParser.set_usage("frog <dart-script-file> [<dart-options>]")
|
| return optionParser.parse_args(args)
|
|
|
| @@ -105,23 +123,24 @@
|
| if options.verbose:
|
| print ("dartArgs=%s pythonArgs=%s extraArgs=%s" %
|
| (' '.join(dartArgs), ' '.join(pythonArgs), ' '.join(extraArgs)))
|
| -
|
| +
|
| if len(extraArgs) != 0:
|
| optionParser.print_help()
|
| return 1
|
|
|
| - if not os.path.exists(DART):
|
| - print("Dart VM not configured in %s" % DART)
|
| + dart = GetDart()
|
| + if not exists(dart):
|
| + print("Dart VM not configured in %s" % dart)
|
| return 1
|
|
|
| if subprocess.call("node --help >/dev/null 2>&1", shell=True):
|
| print "Executing node failed. See frog/README.txt for instructions"
|
| return 1
|
| -
|
| - return compileAndRun(options, dartArgs)
|
|
|
| + return compileAndRun(options, dartArgs, dart)
|
|
|
| -def compileAndRun(options, args):
|
| +
|
| +def compileAndRun(options, args, dart):
|
| nodeArgs = []
|
| for i in range(len(args)):
|
| if args[i].endswith('.dart'):
|
| @@ -130,7 +149,7 @@
|
| break
|
|
|
| if options.verbose: print "nodeArgs %s" % ' '.join(nodeArgs);
|
| -
|
| +
|
| workdir = options.workdir
|
| cleanup = False
|
| if not workdir:
|
| @@ -168,8 +187,8 @@
|
| f.close()
|
|
|
| if options.verbose: print "Wrote wrapper to %s:\n%s" % (GODART, go_contents);
|
| -
|
| - compiler_cmd = [DART]
|
| +
|
| + compiler_cmd = [dart]
|
| if options.vm_flags:
|
| compiler_cmd.extend(options.vm_flags.split(' '))
|
| compiler_cmd.append(GODART);
|
|
|