Skip to content

Commit 4a41555

Browse files
authored
Merge pull request #22 from RalfJung/lockfile
make sure we find the lockfile in its new location
2 parents e865b8d + 8803276 commit 4a41555

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
rust:
1919
- nightly
2020
# Check a ~3 months old nightly as "oldest supported version"
21-
- nightly-2024-01-01
21+
- nightly-2024-05-01
2222
# We want to run all of the above on Linux, macOS, windows-msvc, windows-gnu.
2323
# The semantics of combining `include` with other things in GHA are very strange
2424
# so this seems like the best way of doing that.

src/lib.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -443,20 +443,31 @@ panic = 'unwind'
443443

444444
// Prepare a workspace for cargo
445445
let build_dir = TempDir::new().context("failed to create tempdir")?;
446+
// Cargo.lock
446447
let lock_file = build_dir.path().join("Cargo.lock");
447-
let manifest_file = build_dir.path().join("Cargo.toml");
448-
let lib_file = build_dir.path().join("lib.rs");
449-
fs::copy(
450-
src_dir
451-
.parent()
452-
.expect("src_dir must have a parent")
453-
.join("Cargo.lock"),
454-
&lock_file,
455-
)
456-
.context("failed to copy lockfile from sysroot source")?;
448+
let lock_file_src = {
449+
// Since <https://github.com/rust-lang/rust/pull/128534>, the lock file
450+
// lives inside the src_dir.
451+
let new_lock_file_name = src_dir.join("Cargo.lock");
452+
if new_lock_file_name.exists() {
453+
new_lock_file_name
454+
} else {
455+
// Previously, the lock file lived one folder up.
456+
src_dir
457+
.parent()
458+
.expect("src_dir must have a parent")
459+
.join("Cargo.lock")
460+
}
461+
};
462+
fs::copy(lock_file_src, &lock_file)
463+
.context("failed to copy lockfile from sysroot source")?;
457464
make_writeable(&lock_file).context("failed to make lockfile writeable")?;
465+
// Cargo.toml
466+
let manifest_file = build_dir.path().join("Cargo.toml");
458467
let manifest = self.gen_manifest(src_dir);
459468
fs::write(&manifest_file, manifest.as_bytes()).context("failed to write manifest file")?;
469+
// lib.rs
470+
let lib_file = build_dir.path().join("lib.rs");
460471
let lib = match self.config {
461472
SysrootConfig::NoStd => r#"#![no_std]"#,
462473
SysrootConfig::WithStd { .. } => "",

0 commit comments

Comments
 (0)