Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
depfile_path_to_relative.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2013 The Flutter Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import os
8import subprocess
9import sys
10
11
12def main():
13 parser = argparse.ArgumentParser(
14 description='Executes a command, then rewrites the depfile, converts all absolute paths to relative'
15 )
16 parser.add_argument('--depfile', help='Path to the depfile to rewrite', required=True)
17 parser.add_argument('command', nargs='+', help='Positional args for the command to run')
18 args = parser.parse_args()
19
20 retval = subprocess.call(args.command)
21 if retval != 0:
22 return retval
23
24 lines = []
25 with open(args.depfile, 'r') as f:
26 for line in f:
27 lines.append(' '.join(os.path.relpath(p) for p in line.split()))
28 with open(args.depfile, 'w') as f:
29 f.write('\n'.join(lines))
30
31
32if __name__ == '__main__':
33 sys.exit(main())
Definition main.py:1