vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2012 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 | |
vspasova@webrtc.org | 1b0a02e | 2012-08-30 12:56:38 +0000 | [diff] [blame] | 10 | import os |
vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 11 | import subprocess |
| 12 | import sys |
| 13 | |
| 14 | |
kjellander | f5318e1 | 2017-03-09 02:26:46 -0800 | [diff] [blame^] | 15 | def RunAntBuildCommand(path_to_ant_build_file): |
vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 16 | """Tries to build the passed build file with ant.""" |
kjellander@webrtc.org | b13dfbf | 2012-12-18 19:53:00 +0000 | [diff] [blame] | 17 | ant_executable = 'ant' |
| 18 | if sys.platform == 'win32': |
| 19 | if os.getenv('ANT_HOME'): |
| 20 | ant_executable = os.path.join(os.getenv('ANT_HOME'), 'bin', 'ant.bat') |
vspasova@webrtc.org | 1b0a02e | 2012-08-30 12:56:38 +0000 | [diff] [blame] | 21 | else: |
kjellander@webrtc.org | b13dfbf | 2012-12-18 19:53:00 +0000 | [diff] [blame] | 22 | ant_executable = 'ant.bat' |
| 23 | cmd = [ant_executable, '-buildfile', path_to_ant_build_file] |
| 24 | try: |
| 25 | process = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr) |
| 26 | process.wait() |
| 27 | if process.returncode != 0: |
| 28 | print >> sys.stderr, 'Failed to execute: %s' % ' '.join(cmd) |
| 29 | return process.returncode |
kjellander@webrtc.org | 38ebf98 | 2013-03-08 10:58:21 +0000 | [diff] [blame] | 30 | except subprocess.CalledProcessError as e: |
| 31 | print >> sys.stderr, 'Failed to execute: %s.\nCause: %s' % (' '.join(cmd), |
| 32 | e) |
kjellander@webrtc.org | b13dfbf | 2012-12-18 19:53:00 +0000 | [diff] [blame] | 33 | return -1 |
vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 34 | |
kjellander | f5318e1 | 2017-03-09 02:26:46 -0800 | [diff] [blame^] | 35 | def main(): |
vspasova@webrtc.org | 1b0a02e | 2012-08-30 12:56:38 +0000 | [diff] [blame] | 36 | core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml') |
kjellander | f5318e1 | 2017-03-09 02:26:46 -0800 | [diff] [blame^] | 37 | RunAntBuildCommand(core_build) |
vspasova@webrtc.org | 1b0a02e | 2012-08-30 12:56:38 +0000 | [diff] [blame] | 38 | |
| 39 | javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml') |
kjellander | f5318e1 | 2017-03-09 02:26:46 -0800 | [diff] [blame^] | 40 | return RunAntBuildCommand(javase_build) |
vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 41 | |
| 42 | |
| 43 | if __name__ == '__main__': |
kjellander | f5318e1 | 2017-03-09 02:26:46 -0800 | [diff] [blame^] | 44 | sys.exit(main()) |