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
static SkString join(const CommandLineFlags::StringArray &)