Skip to content

Commit f8b4eab

Browse files
committed
Allows to use a different clang version than the default system one
For some project using new c++ features it maybe useful to for the use of a specific verison of clang. This very small patch allow this use by setting up an environment variable. The use of an environment variable is forced by tree.py that locates the libclang statically and not using an argument. Otherwise an argument to generate command would have been preffered.
1 parent fc7f594 commit f8b4eab

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cldoc/includepaths.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414

1515
from . import utf8
1616

17+
versionned_clang = 'clang++'
18+
if "CLDOC_CLANG_VERSION" in os.environ:
19+
versionned_clang = 'clang++-' + os.environ["CLDOC_CLANG_VERSION"]
20+
1721
def flags(f):
1822
devnull = open(os.devnull)
1923

2024
try:
21-
p = subprocess.Popen(['clang++', '-E', '-xc++'] + f + ['-v', '-'],
25+
p = subprocess.Popen([versionned_clang, '-E', '-xc++'] + f + ['-v', '-'],
2226
stdin=devnull,
2327
stdout=subprocess.PIPE,
2428
stderr=subprocess.PIPE)

cldoc/tree.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .clang import cindex
1616
import tempfile
1717
import functools
18+
import os
1819

1920
from .defdict import Defdict
2021

@@ -55,6 +56,9 @@
5556
else:
5657
versions = [None, '7.0', '6.0', '5.0', '4.0', '3.9', '3.8', '3.7', '3.6', '3.5', '3.4', '3.3', '3.2']
5758

59+
if "CLDOC_CLANG_VERSION" in os.environ:
60+
versions = [None , os.environ["CLDOC_CLANG_VERSION"] ]
61+
5862
for v in versions:
5963
name = 'clang'
6064

0 commit comments

Comments
 (0)