File: generate-matrix.py

package info (click to toggle)
qcoro 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,700 kB
  • sloc: cpp: 8,573; python: 32; xml: 26; makefile: 23; sh: 15
file content (119 lines) | stat: -rw-r--r-- 3,075 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import json
from argparse import ArgumentParser
from typing import Any, Optional

qt5_config = {
    "archives": ["qtbase", "icu", "qtwebsockets", "qtdeclarative", "qtwebchannel", "qtlocation"],
    "modules": ["qtwebengine"]
}

qt6_config = {
    "archives": ["qtbase", "icu", "qtdeclarative"],
    "modules": ["qtwebsockets", "qtwebengine", "qtwebchannel", "qtpositioning"]
}

qt = [
    {
        "version": "5.15.2",
        **qt5_config
    },
    {
        "version": "6.2.0",
        **qt6_config
    },
    {
        "version": "6.5.0",
        **qt6_config
    }
]

platforms = [
    {
        "name": "windows",
        "compilers": [
            {"name": "msvc"},
            {"name": "clang-cl"}
        ]
    },
    {
        "name": "macos",
        "compilers": [{"name": "apple-clang"}]
    },
    {
        "name": "linux",
        "compilers": [
            {
                "name": "gcc",
                "versions": ["11", "12", "13", "14"]
            },
            {
                "name": "clang",
                "versions": ["15", "16", "17", "20", "dev"]
            }
        ]
    }
]


output = {
    "include": []
}


def get_os_for_platform(platform: str) -> str:
    if platform == "windows":
        return "windows-2022"
    if platform == "linux":
        return "ubuntu-20.04"
    if platform == "macos":
        return "macos-13"
    raise RuntimeError(f"Invalid platform '{platform}'.")


def get_base_image_for_compiler(compiler: str) -> Optional[str]:
    if compiler == "gcc":
        return "gcc"
    if compiler == "clang":
        return "debian"
    return None


def create_configuration(
    qt: dict[str, Any], platform: str, compiler: str,
    compiler_version: str = ""
) -> dict[str, Any]:
    return {
        "qt_version": qt["version"],
        "qt_modules": ' '.join(qt["modules"]),
        "qt_archives": ' '.join(qt["archives"]),
        "platform": platform,
        "compiler": compiler,
        "compiler_base_image": get_base_image_for_compiler(compiler),
        "compiler_version": compiler_version,
        "compiler_full": compiler if not compiler_version else f"{compiler}-{compiler_version}",
        "runs_on": get_os_for_platform(platform),
        "with_qtdbus": "OFF" if platform == "macos" else "ON"
    }


parser = ArgumentParser()
parser.add_argument('--platform')
args = parser.parse_args()

filtered_platforms = list(filter(lambda p: p['name'] == args.platform, platforms))

for qt_version in qt:
    for platform in filtered_platforms:
        for compiler in platform["compilers"]:
            if "versions" in compiler:
                for compiler_version in compiler["versions"]:
                    output["include"].append(
                        create_configuration(
                            qt_version, platform["name"], compiler["name"], compiler_version
                        )
                    )
            else:
                output["include"].append(
                    create_configuration(qt_version, platform["name"], compiler["name"]))

print(json.dumps(output))