The open source OpenXR runtime
1#!/usr/bin/env python3
2# Copyright 2022-2023, Collabora, Ltd.
3#
4# SPDX-License-Identifier: BSL-1.0
5#
6# Original author: Rylie Pavlik <rylie.pavlik@collabora.com
7"""Script to set up msvc.imp for include-what-you-use."""
8from pathlib import Path
9from generate_iwyu_mapping import write_mapping_file
10
11_SCRIPT_DIR = Path(__file__).parent.resolve()
12_OUTPUT_FILENAME = _SCRIPT_DIR / "msvc.imp"
13
14_STL_EQUIVS = {
15 "<xutility>": ["<utility>"],
16 "<xstring>": ["<string>"],
17 "<xatomic.h>": ["<atomic>"],
18 "<xtr1common>": ["<type_traits>"],
19 "<corecrt_math.h>": ["<math.h>", "<cmath>"],
20 "<vcruntime_exceptions.h>": ["<exception>"],
21 # This header contains common functionality used by a ton of containers
22 "<xmemory>": [
23 "<deque>",
24 "<filesystem>",
25 "<forward_list>",
26 "<functional>",
27 "<future>",
28 "<hash_map>",
29 "<hash_set>",
30 "<list>",
31 "<map>",
32 "<memory>",
33 "<set>",
34 "<string>",
35 "<unordered_map>",
36 "<unordered_set>",
37 "<vector>",
38 ],
39}
40
41
42def get_all_stl_entries():
43 for src, dests in _STL_EQUIVS.items():
44 for dest in dests:
45 yield """{ include: ["%s", "private", "%s", "public"] },""" % (
46 src,
47 dest,
48 )
49
50
51def write_file():
52 entries = list(get_all_stl_entries())
53 write_mapping_file(entries, _OUTPUT_FILENAME, Path(__file__).resolve().name)
54
55
56if __name__ == "__main__":
57 write_file()