cargo_wrapper: Fix depfile generation for binaries and add debug logging

The depfile generation was only handling lib.rs files, missing main.rs
files used by binary crates. This caused incomplete dependency tracking
for binary targets.

Also added debug logging to help diagnose issues with Cargo.toml
detection and stripped whitespace from source paths to handle parsing
edge cases.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2471>
This commit is contained in:
Thibault Saunier 2025-08-14 21:47:58 -04:00 committed by GStreamer Marge Bot
parent 738de23ef8
commit 9dcb2afaf7

View file

@ -69,14 +69,19 @@ def generate_depfile_for(fpath, build_start_time, logfile=None):
all_deps = []
for src in srcs.split(' '):
src = src.strip()
all_deps.append(src)
src = P(src)
if src.name == 'lib.rs':
if src.name in ['lib.rs', 'main.rs']:
# `rustc` doesn't take `Cargo.toml` into account
# but we need to
cargo_toml = src.parent.parent / 'Cargo.toml'
print(f' Looking for {cargo_toml}: ', file=logfile, end='')
if cargo_toml.exists():
print(f'Found', file=logfile)
all_deps.append(str(cargo_toml))
else:
print(f'Not found', file=logfile)
depfile_content += f'{output}: {' '.join(all_deps)}\n'