blob: dcc43b5ae8059508a2789f338285b8924a294e2c [file] [log] [blame]
Nicholas Bishop82a3feb2021-06-23 13:18:18 -04001#!/usr/bin/env python3
2# pylint: disable=missing-docstring
3
4import os
5import subprocess
6import sys
7
8
9def main():
10 repo_dir = os.path.dirname(os.path.realpath(__file__))
Nicholas Bishopbd517902021-06-23 17:13:27 -040011 tools_dir = os.path.join(repo_dir, 'tools')
12 tools_manifest = os.path.join(tools_dir, 'Cargo.toml')
Nicholas Bishop82a3feb2021-06-23 13:18:18 -040013
Nicholas Bishop2147fa82021-06-23 14:27:33 -040014 cmd = ['cargo', 'run', '--quiet', '--manifest-path', tools_manifest, '--']
Nicholas Bishop82a3feb2021-06-23 13:18:18 -040015 cmd += ['--repo', repo_dir]
16 cmd += sys.argv[1:]
17
Nicholas Bishopbd517902021-06-23 17:13:27 -040018 # Make rustc use absolute paths for messages.
19 var_name = 'RUSTFLAGS'
20 env = dict(os.environ)
21 flags = env.get(var_name, '')
22 flags += ' --remap-path-prefix=src={}/src'.format(tools_dir)
23 env[var_name] = flags
24
Nicholas Bishop49794fd2021-06-23 18:55:21 -040025 res = subprocess.run(cmd, check=False, env=env)
26 # Exit with the child's return code. Do it this way instead of
27 # using check=True because we don't want a stack trace.
28 if res.returncode != 0:
29 sys.exit(res.returncode)
Nicholas Bishop82a3feb2021-06-23 13:18:18 -040030
31
32if __name__ == '__main__':
33 main()