Skip to content

Commit 99cbc83

Browse files
authored
Merge 3cfd505 into 2e54f77
2 parents 2e54f77 + 3cfd505 commit 99cbc83

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mesonbuild/compilers/mixins/clike.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def to_native(self, copy: bool = False) -> T.List[str]:
101101
# Remove system/default include paths added with -isystem
102102
default_dirs = self.compiler.get_default_include_dirs()
103103
if default_dirs:
104-
real_default_dirs = [os.path.realpath(i) for i in default_dirs]
104+
real_default_dirs = [self._cached_realpath(i) for i in default_dirs]
105105
bad_idx_list = [] # type: T.List[int]
106106
for i, each in enumerate(new):
107107
if not each.startswith('-isystem'):
@@ -110,16 +110,21 @@ def to_native(self, copy: bool = False) -> T.List[str]:
110110
# Remove the -isystem and the path if the path is a default path
111111
if (each == '-isystem' and
112112
i < (len(new) - 1) and
113-
os.path.realpath(new[i + 1]) in real_default_dirs):
113+
self._cached_realpath(new[i + 1]) in real_default_dirs):
114114
bad_idx_list += [i, i + 1]
115-
elif each.startswith('-isystem=') and os.path.realpath(each[9:]) in real_default_dirs:
115+
elif each.startswith('-isystem=') and self._cached_realpath(each[9:]) in real_default_dirs:
116116
bad_idx_list += [i]
117-
elif os.path.realpath(each[8:]) in real_default_dirs:
117+
elif self._cached_realpath(each[8:]) in real_default_dirs:
118118
bad_idx_list += [i]
119119
for i in reversed(bad_idx_list):
120120
new.pop(i)
121121
return self.compiler.unix_args_to_native(new._container)
122122

123+
@staticmethod
124+
@functools.lru_cache(maxsize=None)
125+
def _cached_realpath(arg: str) -> str:
126+
return os.path.realpath(arg)
127+
123128
def __repr__(self) -> str:
124129
self.flush_pre_post()
125130
return f'CLikeCompilerArgs({self.compiler!r}, {self._container!r})'

0 commit comments

Comments
 (0)