blob: ba1c199032dfda51b160bb7a29908edf3ac1e351 [file] [log] [blame]
Ray Milkeyf80bbb22016-03-11 10:16:22 -08001#!/usr/bin/env 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 = ['//buck-tools/eclipse:classpath']
21PAT = re.compile(r'"(//.*?)" -> "//buck-tools:download_file"')
22# TODO(davido): Remove this hack when Buck bugs are fixed:
23# https://github.com/facebook/buck/issues/656
24# https://github.com/facebook/buck/issues/658
25JGIT = re.compile(r'//org.eclipse.jgit.*')
26CELL = '//lib/jgit'
27
28opts = OptionParser()
29opts.add_option('--src', action='store_true')
30args, _ = opts.parse_args()
31
32targets = set()
33
34p = Popen(['buck', 'audit', 'classpath', '--dot'] + MAIN, stdout = PIPE)
35for line in p.stdout:
36 m = PAT.search(line)
37 if m:
38 n = m.group(1)
39 if JGIT.match(n):
40 n = CELL + n[1:]
41 if args.src and n.endswith('__download_bin'):
42 n = n[:-13] + 'src'
43 targets.add(n)
44r = p.wait()
45if r != 0:
46 exit(r)
47
48try:
49 check_call(['buck', 'build'] + sorted(targets))
50except CalledProcessError as err:
51 exit(1)