forked from aws/thinkbox-frost-mx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
67 lines (54 loc) · 2.33 KB
/
build.py
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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from typing import Any
from cpt.packager import ConanMultiPackager
import argparse
import platform
import pprint
VALID_MAX_CONFIGS: dict[tuple[str, str], set[str]] = {
('Visual Studio', '15'): { '2017', '2018', '2019', '2020', '2021', '2022' },
('Visual Studio', '16'): { '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024' },
('Visual Studio', '17'): { '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025', '2026' }
}
COMMON_PACKAGER_ARGS: dict[str, Any] = {
'build_types': ['Release'],
'archs': ['x86_64'],
'build_policy': 'missing'
}
WINDOWS_PACKAGER_ARGS: dict[str, Any] = {
'visual_versions': ['15', '16', '17'],
'visual_runtimes': ['MD']
}
def parse_arguments() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--username', default=None, help='The Conan username to use for the built package.')
parser.add_argument('-c', '--channel', default=None, help='The Conan channel to use for the built package.')
parser.add_argument('-o', '--option', action='append', dest='options', help='Specify package options to be used by the build.')
parser.add_argument('--dry-run', action='store_true', help='Print the configurations that would be built without actually building them.')
return parser.parse_args()
def main() -> None:
args = parse_arguments()
packager_args = {
'username': args.username,
'channel': args.channel,
'options': args.options
}
packager_args.update(COMMON_PACKAGER_ARGS)
if platform.system() == 'Windows':
packager_args.update(WINDOWS_PACKAGER_ARGS)
else:
raise Exception('Platform not supported.')
builder = ConanMultiPackager(**packager_args)
builder.add_common_builds(build_all_options_values=[
'max_version'
], pure_c=False)
builder.remove_build_if(
lambda build: build.options['frostmx:max_version'] not in VALID_MAX_CONFIGS[
(build.settings['compiler'], build.settings['compiler.version'])
])
if args.dry_run:
pprint.pprint(builder.builds, indent=4)
else:
builder.run()
if __name__ == '__main__':
main()