cargo_wrapper: Handle windows paths for depfiles

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1027>
This commit is contained in:
Nirbheek Chauhan 2022-12-19 16:30:30 +05:30 committed by Sebastian Dröge
parent 161c6db641
commit 041f51c4bb

View file

@ -32,6 +32,18 @@ def generate_depfile_for(fpath):
with open(f"{file_stem}.d", 'r') as depfile: with open(f"{file_stem}.d", 'r') as depfile:
for l in depfile.readlines(): for l in depfile.readlines():
if l.startswith(str(file_stem)): if l.startswith(str(file_stem)):
# 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) output, srcs = l.split(": ", maxsplit=2)
all_deps = [] all_deps = []