From 0530b324c14c0bbba9bc871ce060fceab08141c7 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 19 Dec 2022 16:30:30 +0530 Subject: [PATCH] cargo_wrapper: Handle windows paths for depfiles Part-of: --- cargo_wrapper.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cargo_wrapper.py b/cargo_wrapper.py index 4bddf9d2..6a6f3e4d 100644 --- a/cargo_wrapper.py +++ b/cargo_wrapper.py @@ -32,7 +32,19 @@ def generate_depfile_for(fpath): with open(f"{file_stem}.d", 'r') as depfile: for l in depfile.readlines(): if l.startswith(str(file_stem)): - output, srcs = l.split(":", maxsplit=2) + # We can't blindly split on `:` because on Windows that's part + # of the drive letter. Lucky for us, the format of the dep file + # is one of: + # + # /path/to/output: /path/to/src1 /path/to/src2 + # /path/to/output: + # + # So we parse these two cases specifically + if l.endswith(':'): + output = l[:-1] + srcs = '' + else: + output, srcs = l.split(": ", maxsplit=2) all_deps = [] for src in srcs.split(" "):