blob: 241d20b75ce0c33d27ead69c3c08c55e10da4ea2 [file] [log] [blame]
Shawn Pearce7b553262013-05-13 21:25:13 -07001#!/usr/bin/python
2# Copyright (C) 2013 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from optparse import OptionParser
17import re
18from subprocess import check_call, CalledProcessError, Popen, PIPE
19
20MAIN = ['//tools/eclipse:classpath']
Shawn Pearce3b4ca732013-05-23 10:45:51 -070021PAT = re.compile(r'"(//.*?)" -> "//tools:download_file"')
Shawn Pearce7b553262013-05-13 21:25:13 -070022
23opts = OptionParser()
24opts.add_option('--src', action='store_true')
25args, _ = opts.parse_args()
26
27targets = set()
28
29p = Popen(['buck', 'audit', 'classpath', '--dot'] + MAIN, stdout = PIPE)
30for line in p.stdout:
31 m = PAT.search(line)
32 if m:
33 n = m.group(1)
34 if args.src and n.endswith('__download_bin'):
35 n = n[:-4] + '_src'
36 targets.add(n)
37r = p.wait()
38if r != 0:
39 exit(r)
40
41try:
42 check_call(['buck', 'build'] + sorted(targets))
43except CalledProcessError as err:
44 exit(1)