blob: ac955debf2e7e4a444a7037d4c771d714e9c7bb9 [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
25 subprocess.run(cmd, check=True, env=env)
Nicholas Bishop82a3feb2021-06-23 13:18:18 -040026
27
28if __name__ == '__main__':
29 main()