Skip to content

Commit

Permalink
Merge pull request #22 from RalfJung/lockfile
Browse files Browse the repository at this point in the history
make sure we find the lockfile in its new location
  • Loading branch information
RalfJung authored Aug 5, 2024
2 parents e865b8d + 8803276 commit 4a41555
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
rust:
- nightly
# Check a ~3 months old nightly as "oldest supported version"
- nightly-2024-01-01
- nightly-2024-05-01
# We want to run all of the above on Linux, macOS, windows-msvc, windows-gnu.
# The semantics of combining `include` with other things in GHA are very strange
# so this seems like the best way of doing that.
Expand Down
31 changes: 21 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,20 +443,31 @@ panic = 'unwind'

// Prepare a workspace for cargo
let build_dir = TempDir::new().context("failed to create tempdir")?;
// Cargo.lock
let lock_file = build_dir.path().join("Cargo.lock");
let manifest_file = build_dir.path().join("Cargo.toml");
let lib_file = build_dir.path().join("lib.rs");
fs::copy(
src_dir
.parent()
.expect("src_dir must have a parent")
.join("Cargo.lock"),
&lock_file,
)
.context("failed to copy lockfile from sysroot source")?;
let lock_file_src = {
// Since <https://github.com/rust-lang/rust/pull/128534>, the lock file
// lives inside the src_dir.
let new_lock_file_name = src_dir.join("Cargo.lock");
if new_lock_file_name.exists() {
new_lock_file_name
} else {
// Previously, the lock file lived one folder up.
src_dir
.parent()
.expect("src_dir must have a parent")
.join("Cargo.lock")
}
};
fs::copy(lock_file_src, &lock_file)
.context("failed to copy lockfile from sysroot source")?;
make_writeable(&lock_file).context("failed to make lockfile writeable")?;
// Cargo.toml
let manifest_file = build_dir.path().join("Cargo.toml");
let manifest = self.gen_manifest(src_dir);
fs::write(&manifest_file, manifest.as_bytes()).context("failed to write manifest file")?;
// lib.rs
let lib_file = build_dir.path().join("lib.rs");
let lib = match self.config {
SysrootConfig::NoStd => r#"#![no_std]"#,
SysrootConfig::WithStd { .. } => "",
Expand Down

0 comments on commit 4a41555

Please sign in to comment.