Skip to content

Commit

Permalink
rust: Add get_target_triplet() method
Browse files Browse the repository at this point in the history
This returns --target value from rustc command line, or the native
target.
  • Loading branch information
xclaesse committed Oct 11, 2024
1 parent e527d8a commit fc1fbce
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mesonbuild/compilers/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,22 @@ def get_crt_static(self) -> bool:
p, stdo, stde = Popen_safe_logged(cmd)
return bool(re.search('^target_feature="crt-static"$', stdo, re.MULTILINE))

@functools.lru_cache(maxsize=None)
def get_target_triplet(self) -> str:
# See if we have --target in the command line
cmd = self.get_exelist(ccache=False)
it = iter(cmd)
for i in it:
if i == '--target':
return next(it)
# Fallback to default target
p, stdo, stde = Popen_safe_logged(cmd + ['--version', '--verbose'])
if p.returncode == 0:
match = re.search('host: (.*)$', stdo, re.MULTILINE)
if match:
return match.group(1)
raise MesonException('Failed to determine rustc target triplet')

def get_debug_args(self, is_debug: bool) -> T.List[str]:
return clike_debug_args[is_debug]

Expand Down

0 comments on commit fc1fbce

Please sign in to comment.