OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 # | 3 # |
4 # Use of this source code is governed by a BSD-style license | 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 | 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 | 6 # tree. An additional intellectual property rights grant can be found |
7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
9 | 9 |
10 import os | 10 import os |
11 import subprocess | 11 import subprocess |
12 import sys | 12 import sys |
13 | 13 |
14 | 14 |
15 def run_ant_build_command(path_to_ant_build_file): | 15 def RunAntBuildCommand(path_to_ant_build_file): |
16 """Tries to build the passed build file with ant.""" | 16 """Tries to build the passed build file with ant.""" |
17 ant_executable = 'ant' | 17 ant_executable = 'ant' |
18 if sys.platform == 'win32': | 18 if sys.platform == 'win32': |
19 if os.getenv('ANT_HOME'): | 19 if os.getenv('ANT_HOME'): |
20 ant_executable = os.path.join(os.getenv('ANT_HOME'), 'bin', 'ant.bat') | 20 ant_executable = os.path.join(os.getenv('ANT_HOME'), 'bin', 'ant.bat') |
21 else: | 21 else: |
22 ant_executable = 'ant.bat' | 22 ant_executable = 'ant.bat' |
23 cmd = [ant_executable, '-buildfile', path_to_ant_build_file] | 23 cmd = [ant_executable, '-buildfile', path_to_ant_build_file] |
24 try: | 24 try: |
25 process = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) | 25 process = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) |
26 process.wait() | 26 process.wait() |
27 if process.returncode != 0: | 27 if process.returncode != 0: |
28 print >> sys.stderr, 'Failed to execute: %s' % ' '.join(cmd) | 28 print >> sys.stderr, 'Failed to execute: %s' % ' '.join(cmd) |
29 return process.returncode | 29 return process.returncode |
30 except subprocess.CalledProcessError as e: | 30 except subprocess.CalledProcessError as e: |
31 print >> sys.stderr, 'Failed to execute: %s.\nCause: %s' % (' '.join(cmd), | 31 print >> sys.stderr, 'Failed to execute: %s.\nCause: %s' % (' '.join(cmd), |
32 e) | 32 e) |
33 return -1 | 33 return -1 |
34 | 34 |
35 def _main(): | 35 def main(): |
36 core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml') | 36 core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml') |
37 run_ant_build_command(core_build) | 37 RunAntBuildCommand(core_build) |
38 | 38 |
39 javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml') | 39 javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml') |
40 return run_ant_build_command(javase_build) | 40 return RunAntBuildCommand(javase_build) |
41 | 41 |
42 | 42 |
43 if __name__ == '__main__': | 43 if __name__ == '__main__': |
44 sys.exit(_main()) | 44 sys.exit(main()) |
OLD | NEW |