| OLD | NEW |
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #!/usr/bin/env python | 5 #!/usr/bin/env python |
| 6 # | 6 # |
| 7 | 7 |
| 8 """Rewrites HTML files, converting Dart script sections into JavaScript. | 8 """Rewrites HTML files, converting Dart script sections into JavaScript. |
| 9 | 9 |
| 10 Process HTML files, and internally changes script sections that use Dart code | 10 Process HTML files, and internally changes script sections that use Dart code |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 'dartc')) | 178 'dartc')) |
| 179 if not exists(binary): | 179 if not exists(binary): |
| 180 raise ConverterException(DARTC_NOT_FOUND_ERROR % DART_PATH) | 180 raise ConverterException(DARTC_NOT_FOUND_ERROR % DART_PATH) |
| 181 cmd = [binary, | 181 cmd = [binary, |
| 182 '-noincremental', | 182 '-noincremental', |
| 183 '--work', outdir, | 183 '--work', outdir, |
| 184 '--out', self.outputFileName(inputfile, outdir)] | 184 '--out', self.outputFileName(inputfile, outdir)] |
| 185 if self.optimize: | 185 if self.optimize: |
| 186 cmd.append('--optimize') | 186 cmd.append('--optimize') |
| 187 else: | 187 else: |
| 188 binary = abspath(join(DART_PATH, 'frog', | 188 binary = abspath(join(DART_PATH, |
| 189 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), | 189 utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32'), |
| 190 'frog', 'bin', 'frogsh')) | 190 'frog', 'bin', 'frogsh')) |
| 191 if not exists(binary): | 191 if not exists(binary): |
| 192 raise ConverterException(FROG_NOT_FOUND_ERROR % DART_PATH) | 192 raise ConverterException(FROG_NOT_FOUND_ERROR % DART_PATH) |
| 193 cmd = [binary, '--compile-only', | 193 cmd = [binary, '--compile-only', |
| 194 '--libdir=' + join(DART_PATH, 'frog', 'lib'), | 194 '--libdir=' + join(DART_PATH, 'frog', 'lib'), |
| 195 '--out=' + self.outputFileName(inputfile, outdir)] | 195 '--out=' + self.outputFileName(inputfile, outdir)] |
| 196 if self.extra_flags != "": | 196 if self.extra_flags != "": |
| 197 cmd.append(self.extra_flags); | 197 cmd.append(self.extra_flags); |
| 198 cmd.append(inputfile) | 198 cmd.append(inputfile) |
| 199 return cmd | 199 return cmd |
| 200 | 200 |
| 201 def outputFileName(self, inputfile, outdir): | 201 def outputFileName(self, inputfile, outdir): |
| 202 return join(outdir, basename(inputfile) + '.js') | 202 return join(outdir, basename(inputfile) + '.js') |
| 203 | 203 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 if 'dartium' in options.target: | 583 if 'dartium' in options.target: |
| 584 convertForDartium(filename, options.out, | 584 convertForDartium(filename, options.out, |
| 585 outfile.replace(extension, '-dart' + extension), options.verbose) | 585 outfile.replace(extension, '-dart' + extension), options.verbose) |
| 586 except Exception as e: | 586 except Exception as e: |
| 587 print "%sERROR%s: %s" % (RED_COLOR, NO_COLOR, str(e)) | 587 print "%sERROR%s: %s" % (RED_COLOR, NO_COLOR, str(e)) |
| 588 return 1 | 588 return 1 |
| 589 return 0 | 589 return 0 |
| 590 | 590 |
| 591 if __name__ == '__main__': | 591 if __name__ == '__main__': |
| 592 sys.exit(main()) | 592 sys.exit(main()) |
| OLD | NEW |