1# ===----------------------------------------------------------------------===## 2# 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 6# 7# ===----------------------------------------------------------------------===## 8 9import os.path 10 11import libcxx.header_information 12 13header_restrictions = libcxx.header_information.header_restrictions 14 15libcxx_include_directory = os.path.join( 16 os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "include" 17) 18with 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//===----------------------------------------------------------------------===// 25// 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 29// 30//===----------------------------------------------------------------------===// 31 32// WARNING, this entire header is generated by 33// utils/generate_std_clang_module_header.py 34// DO NOT MODIFY! 35 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 45 46#include <__config> 47 48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 49# pragma GCC system_header 50#endif 51 52""" 53 ) 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") 64