Skip to content

Commit

Permalink
Added debug logging for spliced manifests to crate_universe
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Apr 28, 2024
1 parent 4c554fc commit 7cb5238
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crate_universe/src/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ impl Digest {
.with_context(|| format!("Failed to run {} to get its version", binary.display()))?;

if !output.status.success() {
eprintln!("{}", String::from_utf8_lossy(&output.stdout));
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
bail!("Failed to query cargo version")
}

Expand Down
3 changes: 3 additions & 0 deletions crate_universe/src/splicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ impl WorkspaceMetadata {
})
}

/// Update an existing Cargo manifest with metadata about registry urls and target
/// features that are needed in generator steps beyond splicing.
#[tracing::instrument(skip_all)]
pub(crate) fn write_registry_urls_and_feature_map(
cargo: &Cargo,
lockfile: &cargo_lock::Lockfile,
Expand Down
13 changes: 11 additions & 2 deletions crate_universe/src/splicing/splicer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl<'a> SplicerKind<'a> {
}

/// Performs splicing based on the current variant.
#[tracing::instrument(skip_all)]
pub(crate) fn splice(&self, workspace_dir: &Path) -> Result<SplicedManifest> {
match self {
SplicerKind::Workspace {
Expand All @@ -205,6 +206,7 @@ impl<'a> SplicerKind<'a> {
}

/// Implementation for splicing Cargo workspaces
#[tracing::instrument(skip_all)]
fn splice_workspace(
workspace_dir: &Path,
path: &&PathBuf,
Expand Down Expand Up @@ -241,6 +243,7 @@ impl<'a> SplicerKind<'a> {
}

/// Implementation for splicing individual Cargo packages
#[tracing::instrument(skip_all)]
fn splice_package(
workspace_dir: &Path,
path: &&PathBuf,
Expand Down Expand Up @@ -283,6 +286,7 @@ impl<'a> SplicerKind<'a> {
}

/// Implementation for splicing together multiple Cargo packages/workspaces
#[tracing::instrument(skip_all)]
fn splice_multi_package(
workspace_dir: &Path,
manifests: &&BTreeMap<PathBuf, Manifest>,
Expand Down Expand Up @@ -656,8 +660,13 @@ pub(crate) fn write_root_manifest(path: &Path, manifest: cargo_toml::Manifest) -

// TODO(https://gitlab.com/crates.rs/cargo_toml/-/issues/3)
let value = toml::Value::try_from(manifest)?;
fs::write(path, toml::to_string(&value)?)
.context(format!("Failed to write manifest to {}", path.display()))
let content = toml::to_string(&value)?;
tracing::debug!(
"Writing Cargo manifest '{}':\n```toml\n{}```",
path.display(),
content
);
fs::write(path, content).context(format!("Failed to write manifest to {}", path.display()))
}

/// Create a symlink file on unix systems
Expand Down

0 comments on commit 7cb5238

Please sign in to comment.