about summary refs log tree commit diff homepage
path: root/scripts/build/build-ci-container.py
blob: 3f478b54dc080f8f1ad208bbd08b5ec929207754 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3

import yaml
import subprocess
import os
import sys

(abs_path, _) = os.path.split(os.path.abspath(__file__))

with open(os.path.join(abs_path,"../../.github/workflows/build.yaml"), 'r') as stream:
    try:
        ci_config = yaml.safe_load(stream)
        global_env = ci_config['env']
        for job in ci_config['jobs']['Linux']['strategy']['matrix']['include']:
            if job['name'] in ["Docker", "macOS"]:
                print("Skip: {}".format(job['name']))
                continue

            print("Building: {}".format(job['name']))

            build_env = os.environ.copy()

            # Copy current global build configurations
            for k,v in global_env.items():
              build_env[k] = str(v)

            # Override with job specific values
            for k,v in job['env'].items():
                build_env[k] = str(v)

            cmd = [os.path.join(abs_path, 'build.sh'),
                  'klee', # build KLEE and all its dependencies
                  '--docker', # using docker containers
                  '--push-docker-deps', # push containers if possible
                  '--debug', # print debug output
                  '--create-final-image', # assume KLEE is the final image
                  ]


            process = subprocess.Popen(cmd, # Assume KLEE is the final image
                            stdout=subprocess.PIPE,
                            universal_newlines=True,
                            env = build_env)

            while True:
                output = process.stdout.readline()
                print(output.strip())
                return_code = process.poll()
                if return_code != None:
                    break
            if return_code != 0:
                print('Building image failed: {}'.format(return_code))
                for output in process.stdout.readlines():
                    print(output.strip())
                sys.exit(1)

    except yaml.YAMLError as exc:
        print(exc)