Skip to content

Commit

Permalink
Use our own release profile to insulate from custom release profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
RossSmyth committed Apr 13, 2024
1 parent cb6c757 commit cca83af
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use anyhow::{bail, Context, Result};
use tempfile::TempDir;
use walkdir::WalkDir;

/// The name of the profile used for buliding the sysroot.
const DEFAULT_SYSROOT_PROFILE: &str = "custom_sysroot";

/// Returns where the given rustc stores its sysroot source code.
pub fn rustc_sysroot_src(mut rustc: Command) -> Result<PathBuf> {
let output = rustc
Expand Down Expand Up @@ -347,6 +350,13 @@ version = "0.0.0"
# empty dummy, just so that things are being built
path = "lib.rs"
[profile.{DEFAULT_SYSROOT_PROFILE}]
# While it says "inherits", we override all settings.
# This is to insulate us from any custom release profile.
# The only reason we use inherits is because it's required.
inherits = "release"
panic = 'unwind'
{crates}
{patches}
Expand Down Expand Up @@ -426,7 +436,8 @@ path = "lib.rs"
// Run cargo.
let mut cmd = cargo;
cmd.arg(self.mode.as_str());
cmd.arg("--release");
cmd.arg("--profile");
cmd.arg(DEFAULT_SYSROOT_PROFILE);
cmd.arg("--manifest-path");
cmd.arg(&manifest_file);
cmd.arg("--target");
Expand Down Expand Up @@ -458,7 +469,7 @@ path = "lib.rs"
TempDir::new_in(&self.sysroot_dir).context("failed to create staging dir")?;
let out_dir = build_target_dir
.join(&target_name)
.join("release")
.join(DEFAULT_SYSROOT_PROFILE)
.join("deps");
for entry in fs::read_dir(&out_dir).context("failed to read cargo out dir")? {
let entry = entry.context("failed to read cargo out dir entry")?;
Expand Down

0 comments on commit cca83af

Please sign in to comment.