| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"). You may not use |
| 6 | # this file except in compliance with the License. A copy of the License is |
| 7 | # located at |
| 8 | # |
| 9 | # http://aws.amazon.com/apache2.0/ |
| 10 | # |
| 11 | # or in the "license" file accompanying this file. This file is distributed on an |
| 12 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 13 | # implied. See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # The CBMC CI system, at https://github.com/awslabs/aws-batch-cbmc, runs |
| 17 | # this program as part of preparing the source code. This program runs |
| 18 | # before any proof is built. |
| 19 | |
| 20 | |
| 21 | import logging |
| 22 | import os |
| 23 | import subprocess |
| 24 | import sys |
| 25 | |
| 26 | |
| 27 | def main(): |
| 28 | # Unconditionally rebuild the cbmc-batch.yaml file for every proof in |
| 29 | # the source tree, so that the CI parameters for each proof are updated |
| 30 | # before the proof is run. |
| 31 | cmd = ["make", "-B", "cbmc-batch.yaml"] |
| 32 | ok = True |
| 33 | for root, _, fyles in os.walk("."): |
| 34 | if "cbmc-batch.yaml" in fyles: |
| 35 | proc = subprocess.run(cmd, cwd=root) |
| 36 | if proc.returncode: |
| 37 | ok = False |
| 38 | logging.error( |
| 39 | "Failed to build cbmc-batch.yaml in %s (return code %d)", |
| 40 | root, proc.returncode) |
| 41 | |
| 42 | sys.exit(0 if ok else 1) |
| 43 | |
| 44 | |
| 45 | if __name__ == "__main__": |
| 46 | main() |