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 | |
| 15 | def run_ant_build_command(path_to_ant_build_file): |
| 16 | """Tries to build the passed build file with ant.""" |
vspasova@webrtc.org | 1b0a02e | 2012-08-30 12:56:38 +0000 | [diff] [blame^] | 17 | ant_suffix = '.bat' if 'win32' in sys.platform else '' |
| 18 | cmd = ['ant%s' % ant_suffix, '-buildfile', path_to_ant_build_file] |
| 19 | try: |
| 20 | process = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
| 21 | stderr=subprocess.PIPE) |
| 22 | stdout, stderr = process.communicate() |
| 23 | if process.returncode != 0: |
| 24 | print 'Failed to execute: %s\nError: %s' % (' '.join(cmd), stderr) |
| 25 | else: |
| 26 | print stdout |
| 27 | except Exception as e: |
| 28 | print 'Failed to execute: %s\nError: %s' % (' '.join(cmd), e) |
vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 29 | |
| 30 | |
| 31 | def _main(): |
vspasova@webrtc.org | 1b0a02e | 2012-08-30 12:56:38 +0000 | [diff] [blame^] | 32 | core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml') |
| 33 | run_ant_build_command(core_build) |
| 34 | |
| 35 | javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml') |
| 36 | run_ant_build_command(javase_build) |
vspasova@webrtc.org | 2865542 | 2012-08-15 14:35:40 +0000 | [diff] [blame] | 37 | return 0 |
| 38 | |
| 39 | |
| 40 | if __name__ == '__main__': |
| 41 | sys.exit(_main()) |