mirror of
				https://github.com/rust-lang/cargo.git
				synced 2025-11-03 13:12:53 +00:00 
			
		
		
		
	
							parent
							
								
									27dba04f40
								
							
						
					
					
						commit
						17b129afca
					
				@ -4,6 +4,7 @@ use semver::ReqParseError;
 | 
				
			|||||||
use semver::VersionReq;
 | 
					use semver::VersionReq;
 | 
				
			||||||
use serde::ser;
 | 
					use serde::ser;
 | 
				
			||||||
use serde::Serialize;
 | 
					use serde::Serialize;
 | 
				
			||||||
 | 
					use std::path::PathBuf;
 | 
				
			||||||
use std::rc::Rc;
 | 
					use std::rc::Rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::core::{PackageId, SourceId, Summary};
 | 
					use crate::core::{PackageId, SourceId, Summary};
 | 
				
			||||||
@ -61,6 +62,10 @@ struct SerializedDependency<'a> {
 | 
				
			|||||||
    /// The registry URL this dependency is from.
 | 
					    /// The registry URL this dependency is from.
 | 
				
			||||||
    /// If None, then it comes from the default registry (crates.io).
 | 
					    /// If None, then it comes from the default registry (crates.io).
 | 
				
			||||||
    registry: Option<&'a str>,
 | 
					    registry: Option<&'a str>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// The path to the manifest for a local path dependency.
 | 
				
			||||||
 | 
					    #[serde(skip_serializing_if = "Option::is_none")]
 | 
				
			||||||
 | 
					    manifest_path: Option<PathBuf>,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl ser::Serialize for Dependency {
 | 
					impl ser::Serialize for Dependency {
 | 
				
			||||||
@ -80,6 +85,7 @@ impl ser::Serialize for Dependency {
 | 
				
			|||||||
            target: self.platform(),
 | 
					            target: self.platform(),
 | 
				
			||||||
            rename: self.explicit_name_in_toml().map(|s| s.as_str()),
 | 
					            rename: self.explicit_name_in_toml().map(|s| s.as_str()),
 | 
				
			||||||
            registry: registry_id.as_ref().map(|sid| sid.url().as_str()),
 | 
					            registry: registry_id.as_ref().map(|sid| sid.url().as_str()),
 | 
				
			||||||
 | 
					            manifest_path: self.source_id().manifest_path(),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        .serialize(s)
 | 
					        .serialize(s)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ use std::cmp::{self, Ordering};
 | 
				
			|||||||
use std::collections::HashSet;
 | 
					use std::collections::HashSet;
 | 
				
			||||||
use std::fmt::{self, Formatter};
 | 
					use std::fmt::{self, Formatter};
 | 
				
			||||||
use std::hash::{self, Hash};
 | 
					use std::hash::{self, Hash};
 | 
				
			||||||
use std::path::Path;
 | 
					use std::path::{Path, PathBuf};
 | 
				
			||||||
use std::ptr;
 | 
					use std::ptr;
 | 
				
			||||||
use std::sync::Mutex;
 | 
					use std::sync::Mutex;
 | 
				
			||||||
use url::Url;
 | 
					use url::Url;
 | 
				
			||||||
@ -237,6 +237,15 @@ impl SourceId {
 | 
				
			|||||||
        self.inner.kind == SourceKind::Path
 | 
					        self.inner.kind == SourceKind::Path
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Returns the manifest path if this is a path dependency.
 | 
				
			||||||
 | 
					    pub fn manifest_path(self) -> Option<PathBuf> {
 | 
				
			||||||
 | 
					        if self.inner.kind != SourceKind::Path {
 | 
				
			||||||
 | 
					            return None;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Some(self.inner.url.to_file_path().unwrap().join("Cargo.toml"))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns `true` if this source is from a registry (either local or not).
 | 
					    /// Returns `true` if this source is from a registry (either local or not).
 | 
				
			||||||
    pub fn is_registry(self) -> bool {
 | 
					    pub fn is_registry(self) -> bool {
 | 
				
			||||||
        matches!(
 | 
					        matches!(
 | 
				
			||||||
 | 
				
			|||||||
@ -1984,6 +1984,7 @@ fn deps_with_bin_only() {
 | 
				
			|||||||
                      "rename": null,
 | 
					                      "rename": null,
 | 
				
			||||||
                      "optional": false,
 | 
					                      "optional": false,
 | 
				
			||||||
                      "uses_default_features": true,
 | 
					                      "uses_default_features": true,
 | 
				
			||||||
 | 
					                      "manifest_path": "[..]/bdep/Cargo.toml",
 | 
				
			||||||
                      "features": [],
 | 
					                      "features": [],
 | 
				
			||||||
                      "target": null,
 | 
					                      "target": null,
 | 
				
			||||||
                      "registry": null
 | 
					                      "registry": null
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user