blob: 9e737f2f702ff0be5f470f24cb3ead1585122bfa [file] [log] [blame]
vspasova@webrtc.org28655422012-08-15 14:35:40 +00001#!/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.org1b0a02e2012-08-30 12:56:38 +000010import os
vspasova@webrtc.org28655422012-08-15 14:35:40 +000011import subprocess
12import sys
13
14
15def run_ant_build_command(path_to_ant_build_file):
16 """Tries to build the passed build file with ant."""
vspasova@webrtc.org1b0a02e2012-08-30 12:56:38 +000017 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:
kjellander@webrtc.orgccb52c22012-10-10 16:11:28 +000024 print >> sys.stderr, 'Failed to execute: %s\nError: %s' % (' '.join(cmd),
25 stderr)
vspasova@webrtc.org1b0a02e2012-08-30 12:56:38 +000026 else:
27 print stdout
28 except Exception as e:
kjellander@webrtc.orgccb52c22012-10-10 16:11:28 +000029 print >> sys.stderr, 'Failed to execute: %s\nError: %s' % (' '.join(cmd), e)
vspasova@webrtc.org28655422012-08-15 14:35:40 +000030
31
32def _main():
vspasova@webrtc.org1b0a02e2012-08-30 12:56:38 +000033 core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml')
34 run_ant_build_command(core_build)
35
36 javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml')
37 run_ant_build_command(javase_build)
vspasova@webrtc.org28655422012-08-15 14:35:40 +000038 return 0
39
40
41if __name__ == '__main__':
kjellander@webrtc.orgccb52c22012-10-10 16:11:28 +000042 sys.exit(_main())