2019-06-09 00:05:40 +08:00
|
|
|
{ rustPlatform, rust-riscv32i-crates, binutils-riscv32 }:
|
2019-06-06 13:19:17 +08:00
|
|
|
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
name = "helloworld";
|
|
|
|
version = "0.0.0";
|
|
|
|
|
|
|
|
src = ./.;
|
2019-06-08 23:01:37 +08:00
|
|
|
cargoSha256 = "0kf2pnfylfmzm0qvi4jfci43qvrnj1v5f037sb9zpvfqyddhdffl";
|
|
|
|
|
2019-06-06 13:19:17 +08:00
|
|
|
buildPhase = ''
|
|
|
|
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
|
2019-06-08 19:25:38 +08:00
|
|
|
export RUSTFLAGS="-L ${rust-riscv32i-crates}/lib/rustlib/riscv32i-unknown-none-elf/lib -C linker=${binutils-riscv32}/bin/riscv32-unknown-elf-ld -C link-arg=-Tlink.x"
|
2019-06-09 00:05:40 +08:00
|
|
|
cargo build --release --target riscv32i-unknown-none-elf
|
2019-06-06 13:19:17 +08:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
2019-06-08 19:25:38 +08:00
|
|
|
cp target/riscv32i-unknown-none-elf/release/helloworld $out
|
|
|
|
${binutils-riscv32}/bin/riscv32-unknown-elf-objcopy -O binary target/riscv32i-unknown-none-elf/release/helloworld $out/helloworld.bin
|
2019-06-06 13:19:17 +08:00
|
|
|
'';
|
|
|
|
}
|