Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure we find the lockfile in its new location #22

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading