| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Command line wrapper to run the frog compiler under the Dart VM""" | 6 """Command line wrapper to run the frog compiler under the Dart VM""" |
| 7 | 7 |
| 8 # TODO(jimhug): This is a temporary hack to enable running on the VM. We need | 8 # TODO(jimhug): This is a temporary hack to enable running on the VM. We need |
| 9 # the ability to get command-line arguments, to return exit codes, and to | 9 # the ability to get command-line arguments, to return exit codes, and to |
| 10 # communicate with spawned processes in the VM for this to go away. | 10 # communicate with spawned processes in the VM for this to go away. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 def GetDart(): | 36 def GetDart(): |
| 37 # Get the release version. | 37 # Get the release version. |
| 38 return utils.GetDartRunner('release', 'ia32', 'vm') | 38 return utils.GetDartRunner('release', 'ia32', 'vm') |
| 39 | 39 |
| 40 def GetD8(): | 40 def GetD8(): |
| 41 return join(dirname(GetDart()), 'd8') | 41 return join(dirname(GetDart()), 'd8') |
| 42 | 42 |
| 43 D8 = GetD8() | 43 D8 = GetD8() |
| 44 | 44 |
| 45 # The following environment variable is needed for isolate tests to work. |
| 46 # TODO(sigmund): delete this and the 'env' parameter in 'execute' when we remove |
| 47 # dependencies to nodejs |
| 48 os.environ['NODE_MODULE_CONTEXTS'] = '1' |
| 49 |
| 45 def execute(cmd): | 50 def execute(cmd): |
| 46 """Execute a command in a subprocess. """ | 51 """Execute a command in a subprocess. """ |
| 47 try: | 52 try: |
| 48 proc = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) | 53 proc = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr, |
| 54 env=os.environ) |
| 49 return proc.wait() | 55 return proc.wait() |
| 50 except Exception as e: | 56 except Exception as e: |
| 51 print 'Exception when executing: ' + ' '.join(cmd) | 57 print 'Exception when executing: ' + ' '.join(cmd) |
| 52 print e | 58 print e |
| 53 return 1 | 59 return 1 |
| 54 | 60 |
| 55 def parseOptions(args): | 61 def parseOptions(args): |
| 56 optionParser = optparse.OptionParser() | 62 optionParser = optparse.OptionParser() |
| 57 | 63 |
| 58 optionParser.add_option('--work', dest='workdir', | 64 optionParser.add_option('--work', dest='workdir', |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 else: | 211 else: |
| 206 print 'Compilation succeded. Code generated in: %s' % outfile | 212 print 'Compilation succeded. Code generated in: %s' % outfile |
| 207 | 213 |
| 208 if cleanup: shutil.rmtree(workdir) | 214 if cleanup: shutil.rmtree(workdir) |
| 209 if result != 0: | 215 if result != 0: |
| 210 return 1 | 216 return 1 |
| 211 return 0 | 217 return 0 |
| 212 | 218 |
| 213 if __name__ == '__main__': | 219 if __name__ == '__main__': |
| 214 sys.exit(main(sys.argv)) | 220 sys.exit(main(sys.argv)) |
| OLD | NEW |