Roger Meier | 41ad434 | 2015-03-24 22:30:40 +0100 | [diff] [blame] | 1 | # |
| 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
| 20 | import os |
| 21 | import subprocess |
| 22 | |
| 23 | from crossrunner.collect import collect_testlibs |
| 24 | |
| 25 | |
| 26 | def prepare(config_dict, testdir, server_match, client_match): |
| 27 | libs, libs2 = collect_testlibs(config_dict, server_match, client_match) |
| 28 | libs.extend(libs2) |
| 29 | |
| 30 | def prepares(): |
| 31 | for lib in libs: |
| 32 | pre = lib.get('prepare') |
| 33 | if pre: |
| 34 | yield pre, lib['workdir'] |
| 35 | |
| 36 | def files(): |
| 37 | for lib in libs: |
| 38 | workdir = os.path.join(testdir, lib['workdir']) |
| 39 | for c in lib['command']: |
| 40 | if not c.startswith('-'): |
| 41 | p = os.path.join(workdir, c) |
| 42 | if not os.path.exists(p): |
| 43 | yield os.path.split(p) |
| 44 | |
| 45 | def make(p): |
| 46 | d, f = p |
| 47 | with open(os.devnull, 'w') as devnull: |
| 48 | return subprocess.Popen(['make', f], cwd=d, stderr=devnull) |
| 49 | |
| 50 | for pre, d in prepares(): |
| 51 | subprocess.Popen(pre, cwd=d).wait() |
| 52 | |
| 53 | for p in list(map(make, set(files()))): |
| 54 | p.wait() |
| 55 | return True |