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 11from libcxx.header_information import module_headers 12from libcxx.header_information import header_restrictions 13from libcxx.header_information import headers_not_available 14 15 16libcxx_module_directory = os.path.join( 17 os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "modules" 18) 19with open( 20 os.path.join(libcxx_module_directory, "std.cppm.in"), "w" 21) as std_module_cpp_in: 22 std_module_cpp_in.write( 23 """\ 24// -*- C++ -*- 25//===----------------------------------------------------------------------===// 26// 27// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 28// See https://llvm.org/LICENSE.txt for license information. 29// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 30// 31//===----------------------------------------------------------------------===// 32 33// WARNING, this entire header is generated by 34// utils/generate_std_cppm_in.py 35// DO NOT MODIFY! 36 37module; 38 39#include <__config> 40 41// The headers of Table 24: C++ library headers [tab:headers.cpp] 42// and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c] 43""" 44 ) 45 for header in module_headers: 46 if header in header_restrictions: 47 std_module_cpp_in.write( 48 f"""\ 49#if {header_restrictions[header]} 50# include <{header}> 51#endif 52""" 53 ) 54 else: 55 std_module_cpp_in.write(f"#include <{header}>\n") 56 57 std_module_cpp_in.write("\n// *** Headers not yet available ***\n") 58 for header in sorted(headers_not_available): 59 std_module_cpp_in.write( 60 f"""\ 61#if __has_include(<{header}>) 62# error "update the header information for <{header}> in libcxx/utils/generate_std_cppm_in.py" 63#endif // __has_include(<{header}>) 64""" 65 ) 66 67 std_module_cpp_in.write( 68 """ 69export module std; 70 71@LIBCXX_MODULE_STD_INCLUDE_SOURCES@ 72""" 73 ) 74