aboutsummaryrefslogtreecommitdiff
path: root/test_building_all.py
blob: bf2c50975560aeb5c1e7668942073c4f8c78d195 (plain)
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
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python

import argparse
import json
import time

import subprocess as sp

def get_all_versions(library):
    with open(f"./nix/{library}_pkg_versions.json", "r") as handle:
        versions = json.load(handle)

    return versions

def can_build(library, version, variant):
    cmd = ["nix", "build", f".#{variant}.{library}.{version}"]
    start = time.time()
    try:
        sp.check_output(cmd, stderr=sp.STDOUT)
    except sp.CalledProcessError as e:
        print(e.output.decode())
        return False, time.time() - start
    return True, time.time() - start

def valid_build_type(value):
    value = value.strip()
    valid_types = ["shim", "lib"]
    if value not in valid_types:
        raise argparse.ArgumentTypeError(f"'{value}' not from expected {', '.join(valid_types)})")
    return value


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-l", "--library")
    parser.add_argument("-d", "--variant", default="shim", type=valid_build_type)
    args = parser.parse_args()
    library = args.library
    variant = args.variant


    libraries = [
         "botan", 
         "cryptopp", 
         "openssl", 
         "boringssl", 
         "gcrypt", 
         "mbedtls", 
         "ippcp", 
         "nettle", 
         "libressl", 
    ]

    match library:
        case None:
            for lib in libraries:
                print(f"Library: {lib}")
                for version in get_all_versions(lib):
                    print(f"{version}: {can_build(lib, version, variant)}")
        case _:
            print(f"Library: {library}")
            for version in get_all_versions(library):
                print(f"{version}: {can_build(library, version, variant)}")


if __name__ == '__main__':
    main()