blob: 62a29efae918a0998924e0fdb879955107fca1be [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:
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.org28655422012-08-15 14:35:40 +000029
30
31def _main():
vspasova@webrtc.org1b0a02e2012-08-30 12:56:38 +000032 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.org28655422012-08-15 14:35:40 +000037 return 0
38
39
40if __name__ == '__main__':
41 sys.exit(_main())