RusPiRo / ruspiro-tutorials

RusPiRo Tutorial Corner - Doing Raspberry Pi bare metal development the 'Rust way'...
13 stars 2 forks source link

[Feature Request] Use cargo-make instead of make #5

Closed minghuaw closed 4 years ago

minghuaw commented 4 years ago

Using a makefile for a rust project seems not very intuitive. Would you consider using a Makefile.toml instead as the default tool?

For example, the following Makefile.toml file could replace the makefile

# =============================================================================
# Global environment variables
# =============================================================================

[env]
CC = "aarch64-linux-gnu-gcc"
AR = "aarch64-linux-gnu-ar"
CFLAGS = "-march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53"
RUSTFLAGS = "-C linker=${CC} -C target-cpu=cortex-a53 -C target-feature=+strict-align,+a53,+fp-armv8,+neon -C link-arg=-nostartfiles -C link-arg=-T./link64.ld -C opt-level=3 -C debuginfo=0"

# =============================================================================
# Tasks
# =============================================================================

[tasks.default]
clear = true
dependencies = [
    "build",
]

[tasks.build]
clear = true
run_task = "build64"

[tasks.kernel8.linux]
command = "cargo"
args = ["xbuild", "--target", "aarch64-unknown-linux-gnu", "--release", "--bin", "kernel", "--target-dir", "./target/"]

[tasks.build64.linux]
clear = true
dependencies = [
    "kernel8"
]
command = "cargo"
args = ["objcopy", "--", "-O", "binary", "./target/aarch64-unknown-linux-gnu/release/kernel", "./target/kernel8.img"]

[tasks.clean]
command = "cargo"
args = ["clean"]

The following commands would be equivalent

cargo make build64
make all64
2ndTaleStudio commented 4 years ago

Hi, this sounds awsome. I was not aware that cargo-makeevent exists. This would also eliminate the need for a makefile on windows and a shell script on linux, I could merge into one single makefile.toml

Thanks for this hint. It will be part of one of the next updates ;)