Merge #5152
5152: Don't crash on empty out_dirs with older cargos r=matklad a=matklad closes #5125 bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
c78180c318
@ -1,6 +1,11 @@
|
|||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
|
|
||||||
use std::{ffi::OsStr, ops, path::Path, process::Command};
|
use std::{
|
||||||
|
ffi::OsStr,
|
||||||
|
ops,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
process::Command,
|
||||||
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId};
|
use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId};
|
||||||
@ -308,9 +313,13 @@ pub fn load_extern_resources(
|
|||||||
if let Ok(message) = message {
|
if let Ok(message) = message {
|
||||||
match message {
|
match message {
|
||||||
Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => {
|
Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => {
|
||||||
let out_dir = AbsPathBuf::assert(out_dir);
|
// cargo_metadata crate returns default (empty) path for
|
||||||
res.out_dirs.insert(package_id.clone(), out_dir);
|
// older cargos, which is not absolute, so work around that.
|
||||||
res.cfgs.insert(package_id, cfgs);
|
if out_dir != PathBuf::default() {
|
||||||
|
let out_dir = AbsPathBuf::assert(out_dir);
|
||||||
|
res.out_dirs.insert(package_id.clone(), out_dir);
|
||||||
|
res.cfgs.insert(package_id, cfgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Message::CompilerArtifact(message) => {
|
Message::CompilerArtifact(message) => {
|
||||||
if message.target.kind.contains(&"proc-macro".to_string()) {
|
if message.target.kind.contains(&"proc-macro".to_string()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user