Skip to content

Commit fa767ef

Browse files
committed
fix: don't hard-code the value of --stdlib-includes in bootstrap.py
Use the directory of the latest includes available under `llvm_install_dir`, instead.
1 parent 251173b commit fa767ef

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

bootstrap.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,16 @@ def install_mrdocs(self):
16781678
else:
16791679
print(f"\nMrDocs has been successfully installed in {self.options.mrdocs_install_dir}.\n")
16801680

1681+
def find_latest_clang_include_dir(self):
1682+
parent = os.path.join(self.options.llvm_install_dir, "lib", "clang")
1683+
subdirs = [d for d in os.listdir(parent) if os.path.isdir(os.path.join(parent, d))]
1684+
numeric_subdirs = [d for d in subdirs if d.isdigit()]
1685+
if not numeric_subdirs:
1686+
raise RuntimeError(f"No numeric directories found in {parent}")
1687+
latest_numeric_subdir = max(numeric_subdirs, key=lambda d: int(d))
1688+
1689+
return os.path.join(parent, latest_numeric_subdir, "include")
1690+
16811691
def generate_clion_run_configs(self, configs):
16821692
import xml.etree.ElementTree as ET
16831693

@@ -2210,7 +2220,7 @@ def generate_run_configs(self):
22102220
f'--generator={generator}',
22112221
f'--addons={os.path.join(self.options.mrdocs_src_dir, "share", "mrdocs", "addons")}',
22122222
f'--stdlib-includes={os.path.join(self.options.llvm_install_dir, "include", "c++", "v1")}',
2213-
f'--stdlib-includes={os.path.join(self.options.llvm_install_dir, "lib", "clang", "20", "include")}',
2223+
f'--stdlib-includes={self.find_latest_clang_include_dir()}',
22142224
f'--libc-includes={os.path.join(self.options.mrdocs_src_dir, "share", "mrdocs", "headers", "libc-stubs")}',
22152225
'--log-level=warn'
22162226
]
@@ -2236,7 +2246,7 @@ def generate_run_configs(self):
22362246
f'--generator=adoc',
22372247
f'--addons={os.path.join(self.options.mrdocs_src_dir, "share", "mrdocs", "addons")}',
22382248
f'--stdlib-includes={os.path.join(self.options.llvm_install_dir, "include", "c++", "v1")}',
2239-
f'--stdlib-includes={os.path.join(self.options.llvm_install_dir, "lib", "clang", "20", "include")}',
2249+
f'--stdlib-includes={self.find_latest_clang_include_dir()}',
22402250
f'--libc-includes={os.path.join(self.options.mrdocs_src_dir, "share", "mrdocs", "headers", "libc-stubs")}',
22412251
f'--tagfile=reference.tag.xml',
22422252
'--multipage=true',
@@ -2260,7 +2270,7 @@ def generate_run_configs(self):
22602270
f'--generator=adoc',
22612271
f'--addons={os.path.join(self.options.mrdocs_src_dir, "share", "mrdocs", "addons")}',
22622272
f'--stdlib-includes={os.path.join(self.options.llvm_install_dir, "include", "c++", "v1")}',
2263-
f'--stdlib-includes={os.path.join(self.options.llvm_install_dir, "lib", "clang", "20", "include")}',
2273+
f'--stdlib-includes={self.find_latest_clang_include_dir()}',
22642274
f'--libc-includes={os.path.join(self.options.mrdocs_src_dir, "share", "mrdocs", "headers", "libc-stubs")}',
22652275
f'--tagfile=reference.tag.xml',
22662276
'--multipage=true',

0 commit comments

Comments
 (0)