3 import os
, pathlib
, sys
6 def generate(private
, public
):
7 return f
'{{ include: [ "{private}", "private", "<{public}>", "public" ] }}'
11 print(f
"========== {__file__} error ==========", file=sys
.stderr
)
13 f
"\tFile '{file}' is a top-level detail header without a mapping",
19 def generate_map(include
):
21 detail_directories
= []
24 for i
in include
.iterdir():
25 if i
.is_dir() and i
.name
.startswith("__"):
26 detail_directories
.append(f
"{i.name}")
29 if i
.name
.startswith("__"):
30 detail_files
.append(i
.name
)
33 if i
.name
.endswith(".h"):
34 c_headers
.append(i
.name
)
37 temporary_mappings
= {"__locale_dir": "locale"}
38 for i
in detail_directories
:
39 public_header
= temporary_mappings
.get(i
, i
.lstrip("_"))
40 result
.append(f
'{generate(f"@<{i}/.*>", public_header)},')
42 for i
in detail_files
:
46 elif i
== "__availability":
48 elif i
== "__bit_reference":
52 elif i
== "__config_site.in":
60 elif i
== "__hash_table":
61 public
= ["unordered_map", "unordered_set"]
64 elif i
== "__mbstate_t.h":
66 elif i
== "__mutex_base":
68 elif i
== "__node_handle":
69 public
= ["map", "set", "unordered_map", "unordered_set"]
70 elif i
== "__pstl_algorithm":
72 elif i
== "__pstl_config_site.in":
74 elif i
== "__pstl_execution":
76 elif i
== "__pstl_memory":
78 elif i
== "__pstl_numeric":
80 elif i
== "__split_buffer":
81 public
= ["deque", "vector"]
82 elif i
== "__std_mbstate_t.h":
84 elif i
== "__threading_support":
85 public
= ["atomic", "mutex", "semaphore", "thread"]
87 public
= ["map", "set"]
88 elif i
== "__undef_macros":
90 elif i
== "__verbose_abort":
96 result
.append(f
'{generate(f"<{i}>", p)},')
103 monorepo_root
= pathlib
.Path(
104 os
.path
.dirname(os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
106 assert monorepo_root
.exists()
107 include
= pathlib
.Path(os
.path
.join(monorepo_root
, "libcxx", "include"))
109 mapping
= generate_map(include
)
110 data
= "[\n " + "\n ".join(mapping
) + "\n]\n"
111 with
open(f
"{include}/libcxx.imp", "w") as f
:
115 if __name__
== "__main__":