Shawn Pearce | 7b55326 | 2013-05-13 21:25:13 -0700 | [diff] [blame] | 1 | #!/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 | |
| 16 | from optparse import OptionParser |
| 17 | import re |
| 18 | from subprocess import check_call, CalledProcessError, Popen, PIPE |
| 19 | |
| 20 | MAIN = ['//tools/eclipse:classpath'] |
Shawn Pearce | 3b4ca73 | 2013-05-23 10:45:51 -0700 | [diff] [blame] | 21 | PAT = re.compile(r'"(//.*?)" -> "//tools:download_file"') |
Shawn Pearce | 7b55326 | 2013-05-13 21:25:13 -0700 | [diff] [blame] | 22 | |
| 23 | opts = OptionParser() |
| 24 | opts.add_option('--src', action='store_true') |
| 25 | args, _ = opts.parse_args() |
| 26 | |
| 27 | targets = set() |
| 28 | |
| 29 | p = Popen(['buck', 'audit', 'classpath', '--dot'] + MAIN, stdout = PIPE) |
| 30 | for 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) |
| 37 | r = p.wait() |
| 38 | if r != 0: |
| 39 | exit(r) |
| 40 | |
| 41 | try: |
| 42 | check_call(['buck', 'build'] + sorted(targets)) |
| 43 | except CalledProcessError as err: |
| 44 | exit(1) |