Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Harry Ho | 64bc97bf2a | |
Harry Ho | 92911099d9 |
|
@ -8,21 +8,11 @@ let
|
||||||
rustPlatform = pkgs.recurseIntoAttrs (pkgs.callPackage ./rustPlatform.nix {
|
rustPlatform = pkgs.recurseIntoAttrs (pkgs.callPackage ./rustPlatform.nix {
|
||||||
inherit rustManifest;
|
inherit rustManifest;
|
||||||
});
|
});
|
||||||
buildStm32Firmware = { name, src, cargoDepsName ? name, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, ... } @ args:
|
buildStm32Firmware = { name, src, cargoDepsName ? name, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, binaryName ? name, extraCargoBuildArgs ? "" }:
|
||||||
let
|
let
|
||||||
cargoSha256Drv = pkgs.runCommand "${name}-cargosha256" { } ''
|
cargoSha256Drv = pkgs.runCommand "${name}-cargosha256" { } ''
|
||||||
cp "${src}/cargosha256.nix" $out
|
cp "${src}/cargosha256.nix" $out
|
||||||
'';
|
'';
|
||||||
# If binaryName is specified,
|
|
||||||
# then pass it as an argument for `cargo build`; otherwise, do not add such argument.
|
|
||||||
extraCargoBuildArgs = (
|
|
||||||
(if (args ? extraCargoBuildArgs) then (args.extraCargoBuildArgs + " ") else "") +
|
|
||||||
(if (args ? binaryName) then ("--bin " + binaryName) else "")
|
|
||||||
);
|
|
||||||
# If binaryName is specified,
|
|
||||||
# then use it as the filename of the ELF generated from `cargo build`;
|
|
||||||
# otherwise, use the `name` arg (i.e. the Rust package name) as the ELF filename.
|
|
||||||
binaryName = if (args ? binaryName) then args.binaryName else name;
|
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
inherit name cargoDepsName;
|
inherit name cargoDepsName;
|
||||||
|
@ -35,10 +25,12 @@ let
|
||||||
nativeBuildInputs = [ pkgs.llvm ] ++ extraNativeBuildInputs;
|
nativeBuildInputs = [ pkgs.llvm ] ++ extraNativeBuildInputs;
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
||||||
cargo build --release ${extraCargoBuildArgs}
|
cargo build --release --bin ${binaryName} ${extraCargoBuildArgs}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
inherit checkPhase doCheck;
|
inherit checkPhase doCheck;
|
||||||
|
# binaryName defaults to the `name` arg (i.e. the Rust package name);
|
||||||
|
# it is used as the Cargo binary filename
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out $out/nix-support
|
mkdir -p $out $out/nix-support
|
||||||
cp target/thumbv7em-none-eabihf/release/${binaryName} $out/${name}.elf
|
cp target/thumbv7em-none-eabihf/release/${binaryName} $out/${name}.elf
|
||||||
|
@ -53,10 +45,10 @@ let
|
||||||
in
|
in
|
||||||
pkgs.lib.attrsets.mapAttrs'
|
pkgs.lib.attrsets.mapAttrs'
|
||||||
(name: value: pkgs.lib.attrsets.nameValuePair ("stabilizer-" + name)
|
(name: value: pkgs.lib.attrsets.nameValuePair ("stabilizer-" + name)
|
||||||
(buildStm32Firmware {
|
(buildStm32Firmware ({
|
||||||
name = "stabilizer-" + name;
|
name = "stabilizer-" + name;
|
||||||
# If binaryName is not specified, use the attribute name as binaryName by default.
|
# If binaryName is not specified, use the attribute name as binaryName by default.
|
||||||
binaryName = if (value ? binaryName) then value.binaryName else name;
|
binaryName = name;
|
||||||
cargoDepsName = "stabilizer";
|
cargoDepsName = "stabilizer";
|
||||||
src = <stabilizerSrc>;
|
src = <stabilizerSrc>;
|
||||||
patchPhase = ''
|
patchPhase = ''
|
||||||
|
@ -67,7 +59,7 @@ in
|
||||||
"Ipv4Address::new(192, 168, 1, 1)"
|
"Ipv4Address::new(192, 168, 1, 1)"
|
||||||
'';
|
'';
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
})) {
|
} // value))) {
|
||||||
dual-iir = {};
|
dual-iir = {};
|
||||||
dual-iir-pounder_v1_1 = {
|
dual-iir-pounder_v1_1 = {
|
||||||
binaryName = "dual-iir";
|
binaryName = "dual-iir";
|
||||||
|
|
Loading…
Reference in New Issue