| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2011 Google Inc. All Rights Reserved. |
| 2 |
| 3 import os |
| 4 import platform |
| 5 import shutil |
| 6 import stat |
| 7 import sys |
| 8 |
| 9 HOME = os.path.dirname(os.path.realpath(__file__)) |
| 10 HOME = os.path.join(HOME, os.pardir, os.pardir) |
| 11 |
| 12 FROGSH_FALLBACK = """#!/bin/sh |
| 13 echo -en "\033[31mERROR\033[0m: Building frogsh in 'debug' mode requires " |
| 14 echo "building the dart" |
| 15 echo "runtime in 'release' mode. Retry building frogsh as follows:" |
| 16 echo " > rm $0" |
| 17 echo " > ./tools/build.py -m release runtime" |
| 18 echo " > ./tools/build.py -m debug frogsh" |
| 19 exit 1 |
| 20 """ |
| 21 |
| 22 sys.path.append(HOME) |
| 23 import frog |
| 24 |
| 25 def main(args): |
| 26 product_dir = args[1] |
| 27 js_out = os.path.join(product_dir, 'frog', 'bin', 'frogsh') |
| 28 vm = os.path.join(product_dir, 'dart') |
| 29 id = platform.system() |
| 30 if id == 'Windows' or id == 'Microsoft': |
| 31 vm = vm + '.exe' |
| 32 shutil.copy(os.path.join(HOME, 'scripts', 'bootstrap', 'frogsh.bat'), |
| 33 js_out + '.bat') |
| 34 frog_args = ['frog.py', '--vm=' + vm, |
| 35 '--js_cmd=node --crankshaft', |
| 36 '--', |
| 37 '--out=' + js_out, 'minfrog.dart'] |
| 38 |
| 39 # TODO(ngeoffray): Compile frogsh without checks integrated. |
| 40 # if js_out.find('Release') != -1: |
| 41 exit_code = frog.main(frog_args) |
| 42 if exit_code: |
| 43 if js_out.find('Release') != -1: |
| 44 return exit_code |
| 45 else: |
| 46 with open(js_out, 'w') as f: |
| 47 f.write(FROGSH_FALLBACK) |
| 48 |
| 49 os.chmod(js_out, stat.S_IXUSR | stat.S_IXGRP | stat.S_IRUSR | |
| 50 stat.S_IRGRP | stat.S_IWUSR) |
| 51 return 0 |
| 52 |
| 53 |
| 54 if __name__ == '__main__': |
| 55 sys.exit(main(sys.argv)) |
| OLD | NEW |