1
0
Fork 0

update cargo-xbuild

This commit is contained in:
Sebastien Bourdeauducq 2021-06-19 22:25:07 +08:00
parent 0e9d3f146a
commit 8ec7216e9a
3 changed files with 23 additions and 28 deletions

View File

@ -1,7 +1,7 @@
let let
pkgs = import <nixpkgs> { overlays = [ (import ./nix/mozilla-overlay.nix) ]; }; pkgs = import <nixpkgs> { overlays = [ (import ./nix/mozilla-overlay.nix) ]; };
rustPlatform = (import ./nix/rust-platform.nix { inherit pkgs; }); rustPlatform = (import ./nix/rust-platform.nix { inherit pkgs; });
cargo-xbuild = (pkgs.cargo-xbuild.overrideAttrs(oa: { patches = oa.patches ++ [ ./xbuild_writable_lockfile.diff ]; } )); cargo-xbuild = pkgs.callPackage ./nix/cargo-xbuild.nix {};
cargoSha256Experiments = "0d2v6n6a73vhxm6yq60mvv9pxxxah88kzryb0w32i0ddhfj4rrs7"; cargoSha256Experiments = "0d2v6n6a73vhxm6yq60mvv9pxxxah88kzryb0w32i0ddhfj4rrs7";
cargoSha256SZL = "0ghj5bbix8417wdismwmxkykvdknikwkvg7sjcjmrywnqk4ka6lg"; cargoSha256SZL = "0ghj5bbix8417wdismwmxkykvdknikwkvg7sjcjmrywnqk4ka6lg";
build-crate = name: crate: features: cargoSha256: build-crate = name: crate: features: cargoSha256:

22
nix/cargo-xbuild.nix Normal file
View File

@ -0,0 +1,22 @@
{ lib, fetchFromGitHub, rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "cargo-xbuild";
version = "0.6.5";
src = fetchFromGitHub {
owner = "rust-osdev";
repo = pname;
rev = "v${version}";
sha256 = "18djvygq9v8rmfchvi2hfj0i6fhn36m716vqndqnj56fiqviwxvf";
};
cargoSha256 = "13sj9j9kl6js75h9xq0yidxy63vixxm9q3f8jil6ymarml5wkhx8";
meta = with lib; {
description = "Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc";
homepage = "https://github.com/rust-osdev/cargo-xbuild";
license = with licenses; [ mit asl20 ];
maintainers = with maintainers; [ johntitor xrelkd ];
};
}

View File

@ -1,27 +0,0 @@
diff --git a/src/sysroot.rs b/src/sysroot.rs
index 1f3c8d1..422d3d0 100644
--- a/src/sysroot.rs
+++ b/src/sysroot.rs
@@ -85,10 +85,20 @@ fn build_crate(
}
util::write(&td.join("Cargo.toml"), &stoml)?;
- fs::copy(lockfile, &td.join("Cargo.lock")).chain_err(||
+ let dst_file = td.join("Cargo.lock");
+ fs::copy(lockfile, &dst_file).chain_err(||
format!("failed to copy Cargo.lock from `{}` to `{}`",
- lockfile.display(), &td.join("Cargo.lock").display())
+ lockfile.display(), &dst_file.display())
)?;
+ let mut perms = fs::metadata(&dst_file).chain_err(||
+ format!("failed to retrieve permissions for `{}`",
+ dst_file.display())
+ )?.permissions();
+ perms.set_readonly(false);
+ fs::set_permissions(&dst_file, perms).chain_err(||
+ format!("failed to update permissions for `{}`",
+ dst_file.display())
+ );
util::mkdir(&td.join("src"))?;
util::write(&td.join("src/lib.rs"), "")?;