2019-05-05 20:56:23 +08:00
|
|
|
let
|
2020-09-09 16:51:50 +08:00
|
|
|
pkgs = import <nixpkgs> { overlays = [ (import ./nix/mozilla-overlay.nix) ]; };
|
|
|
|
rustPlatform = (import ./nix/rust-platform.nix { inherit pkgs; });
|
2021-06-19 22:25:07 +08:00
|
|
|
cargo-xbuild = pkgs.callPackage ./nix/cargo-xbuild.nix {};
|
2021-08-09 15:05:05 +08:00
|
|
|
cargoSha256Experiments = "1bvffgr4588bbkjwnhim8rvkjvbnajaiv7hc98b19sr8kb7rcj63";
|
|
|
|
cargoSha256SZL = "13022ssk6s2fgxmmh5msbx01fzcmk2cj95fjpxcsmfy14k9wd77l";
|
2020-10-13 18:28:42 +08:00
|
|
|
build-crate = name: crate: features: cargoSha256:
|
2020-09-09 16:51:50 +08:00
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
name = "${crate}";
|
|
|
|
|
2021-01-15 07:51:45 +08:00
|
|
|
src = builtins.filterSource (path: type:
|
|
|
|
baseNameOf path != "target"
|
|
|
|
) ./.;
|
2020-10-13 18:28:42 +08:00
|
|
|
inherit cargoSha256;
|
2020-09-09 16:51:50 +08:00
|
|
|
|
2021-01-15 11:16:37 +08:00
|
|
|
nativeBuildInputs = [ cargo-xbuild pkgs.llvmPackages_9.clang-unwrapped ];
|
2019-09-26 23:54:37 +08:00
|
|
|
buildPhase = ''
|
2021-01-15 07:52:22 +08:00
|
|
|
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"
|
2020-09-09 16:51:50 +08:00
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
|
|
|
pushd ${crate}
|
2020-01-26 08:45:02 +08:00
|
|
|
cargo xbuild --release --frozen \
|
|
|
|
--no-default-features \
|
2020-09-09 16:51:50 +08:00
|
|
|
--features=${features}
|
2020-01-26 08:45:02 +08:00
|
|
|
popd
|
2019-09-26 23:54:37 +08:00
|
|
|
'';
|
2020-09-09 16:51:50 +08:00
|
|
|
|
2019-09-26 23:54:37 +08:00
|
|
|
installPhase = ''
|
2020-09-09 16:51:50 +08:00
|
|
|
mkdir -p $out $out/nix-support
|
2019-09-26 23:54:37 +08:00
|
|
|
cp target/armv7-none-eabihf/release/${name} $out/${name}.elf
|
2020-09-09 16:51:50 +08:00
|
|
|
echo file binary-dist $out/${name}.elf >> $out/nix-support/hydra-build-products
|
2019-09-26 23:54:37 +08:00
|
|
|
'';
|
2020-09-09 16:51:50 +08:00
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
dontFixup = true;
|
|
|
|
};
|
2020-11-14 00:57:31 +08:00
|
|
|
|
|
|
|
targetCrates = target: {
|
|
|
|
"${target}-experiments" = build-crate "${target}-experiments" "experiments" "target_${target}" cargoSha256Experiments;
|
|
|
|
"${target}-szl" = build-crate "${target}-szl" "szl" "target_${target}" cargoSha256SZL;
|
|
|
|
};
|
2020-11-20 02:41:38 +08:00
|
|
|
targets = ["zc706" "coraz7" "redpitaya" "kasli_soc"];
|
2021-06-25 16:21:49 +08:00
|
|
|
allTargetCrates = (builtins.foldl' (results: target:
|
|
|
|
results // targetCrates target
|
|
|
|
) {} targets);
|
2020-09-09 16:51:50 +08:00
|
|
|
in
|
|
|
|
{
|
2020-10-13 18:43:37 +08:00
|
|
|
inherit cargo-xbuild;
|
2020-11-14 00:57:31 +08:00
|
|
|
zc706-fsbl = import ./nix/fsbl.nix { inherit pkgs; };
|
2021-06-25 16:21:49 +08:00
|
|
|
szl = pkgs.runCommand "szl" {} (builtins.foldl' (commands: target:
|
|
|
|
let
|
|
|
|
szlResult = builtins.getAttr "${target}-szl" allTargetCrates;
|
|
|
|
in
|
|
|
|
commands + "ln -s ${szlResult}/szl.elf $out/szl-${target}.elf\n"
|
|
|
|
) "mkdir $out\n" targets);
|
|
|
|
} // allTargetCrates
|