From 606ebb0bfb90a0ba31ac341e618150abc567c373 Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 26 Jan 2020 01:45:02 +0100 Subject: [PATCH] default.nix: fix --- Cargo.lock | 29 ++++++++++++++++++----------- README.md | 2 +- default.nix | 27 ++++++++++++++++++--------- experiments/Cargo.toml | 2 +- libboard_zc706/Cargo.toml | 1 + libboard_zc706/src/lib.rs | 1 + 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09471f3..6c21925 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,10 +15,27 @@ name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "compiler_builtins" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "experiments" +version = "0.0.0" +dependencies = [ + "libboard_zc706 0.0.0", + "libboard_zynq 0.0.0", + "libcortex_a9 0.0.0", + "libregister 0.0.0", + "smoltcp 0.5.0 (git+https://github.com/m-labs/smoltcp.git?rev=8eb01aca364aefe5f823d68d552d62c76c9be4a3)", +] + [[package]] name = "libboard_zc706" version = "0.0.0" dependencies = [ + "compiler_builtins 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", "libboard_zynq 0.0.0", "libcortex_a9 0.0.0", "libregister 0.0.0", @@ -100,21 +117,11 @@ dependencies = [ "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "zc706-experiments" -version = "0.0.0" -dependencies = [ - "libboard_zc706 0.0.0", - "libboard_zynq 0.0.0", - "libcortex_a9 0.0.0", - "libregister 0.0.0", - "smoltcp 0.5.0 (git+https://github.com/m-labs/smoltcp.git?rev=8eb01aca364aefe5f823d68d552d62c76c9be4a3)", -] - [metadata] "checksum bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum compiler_builtins 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b9975aefa63997ef75ca9cf013ff1bb81487aaa0b622c21053afd3b92979a7af" "checksum linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "47314ec1d29aa869ee7cb5a5be57be9b1055c56567d59c3fb6689926743e0bea" "checksum managed 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcec5e97041c7f0f1c5b7d93f12e57293c831c646f4cc7a5db59460c7ea8de6" "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" diff --git a/README.md b/README.md index d9e94e5..ff7011a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ nix-shell --command "cargo xbuild --release" ``` -Currently the ELF output is placed at `target/armv7-none-eabihf/release/zc706-experiments` +Currently the ELF output is placed at `target/armv7-none-eabihf/release/experiments` # Debug diff --git a/default.nix b/default.nix index 5d2f72f..50910f3 100644 --- a/default.nix +++ b/default.nix @@ -24,7 +24,7 @@ let cargo = rust; }); gcc = pkgs.pkgsCross.armv7l-hf-multiplatform.buildPackages.gcc; - xbuildRustPackage = attrs: + xbuildRustPackage = { cargoFeatures, crateSubdir, ... } @ attrs: let buildPkg = rustPlatform.buildRustPackage attrs; in @@ -32,23 +32,32 @@ let nativeBuildInputs = nativeBuildInputs ++ [ pkgs.cargo-xbuild ]; buildPhase = '' - cargo xbuild --release --frozen + set -x + pushd ${crateSubdir} + cargo xbuild --release --frozen \ + --no-default-features \ + --features=${cargoFeatures} + popd ''; XARGO_RUST_SRC = "${rustcSrc}/src"; installPhase = '' mkdir $out + ls -la target/armv7-none-eabihf/release/ cp target/armv7-none-eabihf/release/${name} $out/${name}.elf ''; }); - zc706 = xbuildRustPackage { - name = "zc706"; + xbuildCrate = crate: features: xbuildRustPackage rec { + name = "${crate}"; src = ./.; - cargoSha256 = "15icqy72dck82czpsqz41yjsdar17vpi15v22j6z0zxhzf517rf7"; - nativeBuildInputs = [ - gcc - ]; + crateSubdir = crate; + cargoSha256 = "1wvj585vylbjlab7cxbkr4f60km5y7s8knxxvcixmqywdldnh7g2"; + cargoFeatures = features; doCheck = false; }; in { - inherit pkgs rustPlatform rustcSrc zc706 gcc; + inherit pkgs rustPlatform rustcSrc gcc; + zc706 = { + zc706-experiments = xbuildCrate "experiments" "target_zc706"; + cora-experiments = xbuildCrate "experiments" "target_cora_z7_10"; + }; } diff --git a/experiments/Cargo.toml b/experiments/Cargo.toml index ff15518..763dbfe 100644 --- a/experiments/Cargo.toml +++ b/experiments/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "zc706-experiments" +name = "experiments" description = "Developing bare-metal Rust on Zynq" version = "0.0.0" authors = ["Astro "] diff --git a/libboard_zc706/Cargo.toml b/libboard_zc706/Cargo.toml index 2047373..9de4a30 100644 --- a/libboard_zc706/Cargo.toml +++ b/libboard_zc706/Cargo.toml @@ -11,6 +11,7 @@ target_cora_z7_10 = ["libboard_zynq/target_cora_z7_10"] [dependencies] r0 = "0.2" +compiler_builtins = "0.1" linked_list_allocator = { version = "0.6", default-features = false } libregister = { path = "../libregister" } libcortex_a9 = { path = "../libcortex_a9" } diff --git a/libboard_zc706/src/lib.rs b/libboard_zc706/src/lib.rs index 9d2e80a..a2051a3 100644 --- a/libboard_zc706/src/lib.rs +++ b/libboard_zc706/src/lib.rs @@ -5,6 +5,7 @@ #![feature(panic_info_message)] pub extern crate alloc; +pub extern crate compiler_builtins; pub mod boot; mod abort;