OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Utility functions for Windows builds. | 7 """Utility functions for Windows builds. |
8 | 8 |
9 These functions are executed via gyp-win-tool when using the ninja generator. | 9 These functions are executed via gyp-win-tool when using the ninja generator. |
10 """ | 10 """ |
11 | 11 |
| 12 import json |
12 import os | 13 import os |
13 import shutil | 14 import shutil |
| 15 import subprocess |
14 import sys | 16 import sys |
15 | 17 |
16 | 18 |
17 def main(args): | 19 def main(args): |
18 executor = WinTool() | 20 executor = WinTool() |
19 exit_code = executor.Dispatch(args) | 21 exit_code = executor.Dispatch(args) |
20 if exit_code is not None: | 22 if exit_code is not None: |
21 sys.exit(exit_code) | 23 sys.exit(exit_code) |
22 | 24 |
23 | 25 |
(...skipping 18 matching lines...) Expand all Loading... |
42 if os.path.exists(dest): | 44 if os.path.exists(dest): |
43 if os.path.isdir(dest): | 45 if os.path.isdir(dest): |
44 shutil.rmtree(dest) | 46 shutil.rmtree(dest) |
45 else: | 47 else: |
46 os.unlink(dest) | 48 os.unlink(dest) |
47 if os.path.isdir(source): | 49 if os.path.isdir(source): |
48 shutil.copytree(source, dest) | 50 shutil.copytree(source, dest) |
49 else: | 51 else: |
50 shutil.copy2(source, dest) | 52 shutil.copy2(source, dest) |
51 | 53 |
| 54 def ExecTouch(self, path): |
| 55 """Basic touch.""" |
| 56 if os.path.exists(path): |
| 57 os.utime(path, None) |
| 58 else: |
| 59 open(path, 'w').close() |
| 60 |
| 61 def ExecQuietMidl(self, outdir, tlb, h, dlldata, iid, proxy, idl, *flags): |
| 62 args = ['midl', '/nologo'] + list(flags) + [ |
| 63 '/out', outdir, |
| 64 '/tlb', tlb, |
| 65 '/h', h, |
| 66 '/dlldata', dlldata, |
| 67 '/iid', iid, |
| 68 '/proxy', proxy, |
| 69 idl] |
| 70 popen = subprocess.Popen(args, |
| 71 shell=True, |
| 72 stdout=subprocess.PIPE, |
| 73 stderr=subprocess.STDOUT) |
| 74 out, err = popen.communicate() |
| 75 # TODO(scottmg): Filter out the silly noise. |
| 76 sys.stdout.write(out) |
| 77 return popen.returncode |
| 78 |
| 79 def ExecDealWithCygwin(self, argspath): |
| 80 """|path| contains the arguments to a cygwin bash sub-shell in python |
| 81 repr()'d format. Returns error code from sub-shell.""" |
| 82 build_to_base, cygdirs, args = json.loads(open(argspath, 'r').read()) |
| 83 # TODO(scottmg): Totally don't get how this setup path is supposed to |
| 84 # work. msvs_cygwin_dirs? But never seems right. |
| 85 args = ' '.join(a.replace('\\', '/') for a in args) |
| 86 cmd = 'call ..\\..\\third_party\\cygwin\\setup_env.bat && ' \ |
| 87 'cd %s && ' \ |
| 88 'bash -c "%s"' % (build_to_base, args) |
| 89 print "running:", cmd |
| 90 return os.system(cmd) |
52 | 91 |
53 if __name__ == '__main__': | 92 if __name__ == '__main__': |
54 sys.exit(main(sys.argv[1:])) | 93 sys.exit(main(sys.argv[1:])) |
OLD | NEW |