|
| 1 | +# Copyright (c) 2019 The Khronos Group Inc. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +import json |
| 5 | +import sys |
| 6 | +from dataclasses import dataclass |
| 7 | +from itertools import product |
| 8 | + |
| 9 | +VS_VERSION = "Visual Studio 17 2022" |
| 10 | + |
| 11 | +PLATFORMS = ("Win32", "x64", "ARM", "ARM64") |
| 12 | + |
| 13 | +TRUE_FALSE = (True, False) |
| 14 | + |
| 15 | + |
| 16 | +@dataclass |
| 17 | +class BuildConfig: |
| 18 | + arch: str |
| 19 | + uwp: bool |
| 20 | + |
| 21 | + def should_skip(self) -> bool: |
| 22 | + # ARM/ARM64 is only built for the UWP platform. |
| 23 | + return "ARM" in self.arch and not self.uwp |
| 24 | + |
| 25 | + # can switch to just doing x64 for speed of testing |
| 26 | + # return self.arch != "x64" |
| 27 | + |
| 28 | + def preset(self) -> str: |
| 29 | + if self.uwp: |
| 30 | + return f"{self.arch.lower()}_uwp" |
| 31 | + |
| 32 | + return self.arch.lower() |
| 33 | + |
| 34 | + def win_artifact_name(self) -> str: |
| 35 | + return f"loader_{self.preset()}" |
| 36 | + |
| 37 | + def platform_dirname(self) -> str: |
| 38 | + if self.uwp: |
| 39 | + return f"{self.arch}_uwp" |
| 40 | + return self.arch |
| 41 | + |
| 42 | + |
| 43 | +_UNFILTERED_BUILD_CONFIGS = [ |
| 44 | + BuildConfig(arch, uwp) for arch, uwp in product(PLATFORMS, TRUE_FALSE) |
| 45 | +] |
| 46 | + |
| 47 | +BUILD_CONFIGS = [c for c in _UNFILTERED_BUILD_CONFIGS if not c.should_skip()] |
| 48 | + |
| 49 | + |
| 50 | +def output_json(data, variable_name=None): |
| 51 | + if variable_name: |
| 52 | + print(f"::set-output name={variable_name}::{json.dumps(data)}") |
| 53 | + else: |
| 54 | + print(json.dumps(data, indent=4)) |
0 commit comments