Bump version to 19.1.0 (final)
[llvm-project.git] / libcxx / utils / generate_std_clang_module_header.py
blob33c9acf395379605ff0fc475b73494b3e92e87d3
1 # ===----------------------------------------------------------------------===##
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 # ===----------------------------------------------------------------------===##
9 import os.path
11 import libcxx.header_information
13 header_restrictions = libcxx.header_information.header_restrictions
15 libcxx_include_directory = os.path.join(
16 os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "include"
18 with open(
19 os.path.join(libcxx_include_directory, "__std_clang_module"), "w"
20 ) as std_clang_module_header:
21 std_clang_module_header.write(
22 """\
23 // -*- C++ -*-
24 //===----------------------------------------------------------------------===//
26 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
27 // See https://llvm.org/LICENSE.txt for license information.
28 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
30 //===----------------------------------------------------------------------===//
32 // WARNING, this entire header is generated by
33 // utils/generate_std_clang_module_header.py
34 // DO NOT MODIFY!
36 // This header should not be directly included, it's exclusively to import all
37 // of the libc++ public clang modules for the `std` clang module to export. In
38 // other words, it's to facilitate `@import std;` in Objective-C++ and `import std`
39 // in Swift to expose all of the libc++ interfaces. This is generally not
40 // recommended, however there are some clients that need to import all of libc++
41 // without knowing what "all" is.
42 #if !__building_module(std)
43 # error "Do not include this header directly, include individual headers instead"
44 #endif
46 #include <__config>
48 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
49 # pragma GCC system_header
50 #endif
52 """
54 # Include the angle brackets in sorting so that <a.h> sorts before <a>
55 # like check-format wants.
56 for include, header in sorted([(f"<{header}>", header) for header in libcxx.header_information.public_headers]):
57 header_restriction = header_restrictions.get(header)
58 if header_restriction:
59 std_clang_module_header.write(f"#if {header_restriction}\n")
60 std_clang_module_header.write(f"# include {include}\n")
61 std_clang_module_header.write(f"#endif\n")
62 else:
63 std_clang_module_header.write(f"#include {include}\n")