]> git.proxmox.com Git - cargo.git/commit - src/bin/cargo/commands/search.rs
Auto merge of #10281 - Gnurfos:depinfo_relative, r=ehuss
authorbors <bors@rust-lang.org>
Sat, 7 May 2022 19:49:54 +0000 (19:49 +0000)
committerbors <bors@rust-lang.org>
Sat, 7 May 2022 19:49:54 +0000 (19:49 +0000)
commit9fa2bba6791f9df06a13dbfe18bf7add9b9b2d1b
treea966de51853f9e27d123746c629635fad67d5e85
parent7ed2769031d1dc32806ed1c0e8b3c04d97f27148
parente5ff81b0e7c0bc5cad9358adcacf83ed39b98d5b
Auto merge of #10281 - Gnurfos:depinfo_relative, r=ehuss

Fix use of .. in dep-info-basedir

### Summary

This allows setting, in .cargo/config's dep-info-basedir, some relative path that goes above the crate's directory.

### Motivation

In a setup like this:

```
repo_root
├── Makefile
├── some_c_things
│   └── foo.c
└── rust_things
    ├── Cargo.toml
    └─── src
        └── lib.rs
```

If you want the generated .d files to be includable directly in the Makefile (without post-processing), you need them to mention paths relative to the root, like:

rust_things/target/....: rust_things/src/lib.rs

### Implementation

For this you need to have relative paths with parent directories (in this case ..) in dep-info-basedir, which does not work without the change in this PR (due to render_filename doing only strip_prefix, while the basedir still contains literal ..s).

Let me know if this change is acceptable. Another implementation could be to canonicalize in ConfigRelativePath::resolve_path instead, especially since that struct outputs absolute paths. But that would have it access the filesystem, while it currently doesn't.
tests/testsuite/build_script.rs