Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
depfile_path_to_relative Namespace Reference

Functions

 main ()
 

Function Documentation

◆ main()

depfile_path_to_relative.main ( )

Definition at line 12 of file depfile_path_to_relative.py.

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
Definition main.py:1