blob: 92696a78c2c36fd123a9fc12531dc34c2ed0e9d6 [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
kjellanderf5318e12017-03-09 02:26:46 -080015def RunAntBuildCommand(path_to_ant_build_file):
vspasova@webrtc.org28655422012-08-15 14:35:40 +000016 """Tries to build the passed build file with ant."""
kjellander@webrtc.orgb13dfbf2012-12-18 19:53:00 +000017 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.org1b0a02e2012-08-30 12:56:38 +000021 else:
kjellander@webrtc.orgb13dfbf2012-12-18 19:53:00 +000022 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.org38ebf982013-03-08 10:58:21 +000030 except subprocess.CalledProcessError as e:
31 print >> sys.stderr, 'Failed to execute: %s.\nCause: %s' % (' '.join(cmd),
32 e)
kjellander@webrtc.orgb13dfbf2012-12-18 19:53:00 +000033 return -1
vspasova@webrtc.org28655422012-08-15 14:35:40 +000034
kjellanderf5318e12017-03-09 02:26:46 -080035def main():
vspasova@webrtc.org1b0a02e2012-08-30 12:56:38 +000036 core_build = os.path.join('third_party', 'zxing', 'core', 'build.xml')
kjellanderf5318e12017-03-09 02:26:46 -080037 RunAntBuildCommand(core_build)
vspasova@webrtc.org1b0a02e2012-08-30 12:56:38 +000038
39 javase_build = os.path.join('third_party', 'zxing', 'javase', 'build.xml')
kjellanderf5318e12017-03-09 02:26:46 -080040 return RunAntBuildCommand(javase_build)
vspasova@webrtc.org28655422012-08-15 14:35:40 +000041
42
43if __name__ == '__main__':
kjellanderf5318e12017-03-09 02:26:46 -080044 sys.exit(main())