OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 # | |
4 # Use of this source code is governed by a BSD-style license | |
5 # that can be found in the LICENSE file in the root of the source | |
6 # tree. An additional intellectual property rights grant can be found | |
7 # in the file PATENTS. All contributing project authors may | |
8 # be found in the AUTHORS file in the root of the source tree. | |
9 | |
10 """Builds a local mercurial (hg) copy. | |
11 | |
12 This is used by the go toolchain. | |
13 """ | |
14 | |
15 import os | |
16 import subprocess | |
17 import sys | |
18 | |
19 import utils | |
20 | |
21 | |
22 def main(argv): | |
23 if len(argv) != 2: | |
24 return 'Usage: %s <mercurial_dir>' % argv[0] | |
25 | |
26 mercurial_dir = argv[1] | |
27 if not os.path.exists(mercurial_dir): | |
28 return 'Expected mercurial at {}.'.format(mercurial_dir) | |
29 | |
30 os.chdir(mercurial_dir) | |
31 | |
32 if utils.GetPlatform() == 'win': | |
33 subprocess.check_call(['python', 'setup.py', '--pure', 'build_py', '-c', | |
34 '-d', '.', 'build_ext', | |
35 '-i', 'build_mo', '--force']) | |
36 with open('hg.bat', 'w') as put_hg_in_path: | |
37 # Write a hg.bat since the go toolchain expects to find something called | |
38 # 'hg' in the path, but Windows only recognizes executables ending with | |
39 # an extension in PATHEXT. Writing hg.bat effectively makes 'hg' callable | |
40 # if the mercurial folder is in PATH. | |
41 mercurial_path = os.path.abspath('hg') | |
42 put_hg_in_path.write('python %s %%*' % mercurial_path) | |
43 else: | |
44 subprocess.check_call(['make', 'local']) | |
45 | |
46 if __name__ == '__main__': | |
47 sys.exit(main(sys.argv)) | |
OLD | NEW |