sq: refactor build system

This commit is contained in:
Berkus Decker 2023-11-19 02:22:18 +02:00
parent 6e3e618c12
commit 7c76dbded1
6 changed files with 125 additions and 46 deletions

View File

@ -1,13 +1,17 @@
_default:
@just --list
# Clean project
clean:
cargo make clean
# Update all dependencies
deps-up:
cargo update
# Build default hw kernel and run chainofcommand to boot this kernel onto the board
boot: chainofcommand
cargo make chainboot
cargo make chainboot # make boot-kernel ?
# Build and run kernel in QEMU with serial port emulation
zellij:
@ -24,7 +28,7 @@ zellij-cb:
# Build chainofcommand serial loader
chainofcommand:
cd bin/chainofcommand
cargo make build
cargo make build # --workspace=bin/chainofcommand
# Build and run kernel in QEMU
qemu:
@ -60,21 +64,17 @@ cb-eject:
# Build default hw kernel
build:
cargo make build-device
cargo make kernel-binary
# Clean project
clean:
cargo make clean
cargo make kernel-binary # Should be only one command to do that, not two!
# Run clippy checks
clippy:
# TODO: use cargo-hack
cargo make clippy
env CLIPPY_FEATURES=noserial cargo make clippy
env CLIPPY_FEATURES=qemu cargo make clippy
env CLIPPY_FEATURES=noserial,qemu cargo make clippy
env CLIPPY_FEATURES=jtag cargo make clippy
env CLIPPY_FEATURES=noserial,jtag cargo make clippy
cargo make xtool-clippy
env CLIPPY_FEATURES=noserial cargo make xtool-clippy
env CLIPPY_FEATURES=qemu cargo make xtool-clippy
env CLIPPY_FEATURES=noserial,qemu cargo make xtool-clippy
env CLIPPY_FEATURES=jtag cargo make xtool-clippy
env CLIPPY_FEATURES=noserial,jtag cargo make xtool-clippy
# Run tests in QEMU
test:
@ -84,7 +84,7 @@ alias disasm := hopper
# Build and disassemble kernel
hopper:
cargo make hopper
cargo make xtool-hopper
alias ocd := openocd
@ -102,20 +102,24 @@ gdb-cb:
# Build and print all symbols in the kernel
nm:
cargo make nm
# Check formatting
fmt-check:
cargo fmt -- --check
cargo make xtool-nm
# Run `cargo expand` on nucleus
expand:
cargo make expand -- nucleus
cargo make xtool-expand-target -- nucleus
# Render modules dependency tree
modules:
cargo make xtool-modules
# Generate and open documentation
doc:
cargo make docs-flow
# Check formatting
fmt-check:
cargo fmt -- --check
# Run lint tasks
lint: clippy fmt-check

View File

@ -95,7 +95,7 @@ alias = "all"
[tasks.all]
dependencies = ["kernel-binary", "chainboot", "chainofcommand", "ttt"]
[tasks.modules]
[tasks.xtool-modules]
command = "cargo"
args = ["modules", "tree"]
@ -105,7 +105,7 @@ clear = true
alias = "empty"
# Run a target build with current platform configuration.
[tasks.build-target] # do-build
[tasks.build-target]
command = "cargo"
args = ["build", "@@split(PLATFORM_TARGET, )", "@@split(RUST_STD, )", "--release"]
@ -127,11 +127,7 @@ script = [
"echo \n\n"
]
[tasks.qemu]
alias = "empty"
# @todo Should be expand-target (since it's not for a host platform)
[tasks.expand]
[tasks.xtool-expand-target]
env = { "TARGET_FEATURES" = "" }
command = "cargo"
args = ["expand", "@@split(PLATFORM_TARGET, )", "--release"]
@ -146,7 +142,7 @@ env = { "TARGET_FEATURES" = "" }
command = "cargo"
args = ["doc", "--open", "--no-deps", "@@split(PLATFORM_TARGET, )"]
[tasks.clippy]
[tasks.xtool-clippy]
env = { "TARGET_FEATURES" = "rpi3", "CLIPPY_FEATURES" = { value = "--features=${CLIPPY_FEATURES}", condition = { env_set = ["CLIPPY_FEATURES"] } } }
command = "cargo"
args = ["clippy", "@@split(PLATFORM_TARGET, )", "@@split(RUST_STD, )", "@@remove-empty(CLIPPY_FEATURES)", "--", "--deny", "warnings", "--allow", "deprecated"]
@ -232,18 +228,28 @@ script = [
"diskutil ejectAll ${VOLUME}"
]
[tasks.qemu]
alias = "empty"
#
# Per-workspace commands, disabled in the root by efault.
#
# Tasks for chainboot
[tasks.chainboot]
dependencies = ["build-device", "kernel-binary"]
command = "echo"
args = ["\n***===***\n", "🏎️ Run the following command in your terminal:\n", "🏎️ ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/debug/chainofcommand ${CHAINBOOT_SERIAL} ${CHAINBOOT_BAUD} --kernel ${KERNEL_BIN}\n", "***===***\n\n"]
[tasks.cb-eject]
# Tasks for nucleus
[tasks.build-kernel-binary]
alias = "empty"
[tasks.kernel]
alias = "empty"
# Tasks for chainboot
[tasks.chainboot]
alias = "empty"
# sdeject
#[tasks.cb-eject]
#alias = "empty"
# Tasks for chainofcommand
[tasks.chainofcommand]
alias = "empty"
@ -252,6 +258,49 @@ alias = "empty"
[tasks.ttt]
alias = "empty"
# Tasks for nucleus
[tasks.hopper]
# Other tasks
[tasks.gdb]
alias = "empty"
[tasks.gdb-cb]
alias = "empty"
[tasks.sdcard]
alias = "empty"
[tasks.qemu-gdb]
alias = "empty"
[tasks.qemu-cb]
alias = "empty"
[tasks.qemu-cb-gdb]
alias = "empty"
[tasks.xtool-hopper]
alias = "empty"
[tasks.xtool-nm]
alias = "empty"
[tasks.zellij-cb]
alias = "empty"
[tasks.zellij-cb-gdb]
alias = "empty"
[tasks.zellij-nucleus]
alias = "empty"
## Target dependencies:
[tasks.kernel-binary]
alias = "empty"
[tasks.chainboot-binary]
alias = "empty"
[tasks.chainofcommand-binary]
alias = "empty"
[tasks.ttt-binary]
alias = "empty"

View File

@ -9,6 +9,11 @@
CHAINBOOT_ELF = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/${TARGET}/release/chainboot"
CHAINBOOT_BIN = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/chainboot.bin"
[tasks.chainboot]
dependencies = ["build-device", "build-kernel-binary"]
command = "echo"
args = ["\n***===***\n", "🏎️ Run the following command in your terminal:\n", "🏎️ ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/debug/chainofcommand ${CHAINBOOT_SERIAL} ${CHAINBOOT_BAUD} --kernel ${KERNEL_BIN}\n", "***===***\n\n"]
[tasks.build-kernel-binary]
env = { "BINARY_FILE" = "${CHAINBOOT_ELF}" }
run_task = "build-custom-binary"
@ -37,6 +42,10 @@ script = [
]
[tasks.sdcard]
clear = true
alias = "sdcard-cb"
[tasks.sdcard-cb]
dependencies = ["build", "build-kernel-binary"]
script_runner = "@duckscript"
script = [
@ -47,9 +56,10 @@ script = [
'''
]
[tasks.cb-eject]
clean = true
alias = "cb-eject-chainboot"
[tasks.cb-eject-chainboot]
dependencies = ["sdeject"]
# Just use sdeject
#[tasks.cb-eject]
#clean = true
#alias = "cb-eject-chainboot"
#
#[tasks.cb-eject-chainboot]
#dependencies = ["sdeject"]

View File

@ -6,16 +6,24 @@
# Build chainofcommand tool
#
[tasks.build]
clear = true
alias = "build-coc"
[tasks.build-device]
clear = true
alias = "empty"
[tasks.build-coc]
command = "cargo"
args = ["build"]
[tasks.chainofcommand]
alias = "build"
alias = "build-coc"
[tasks.test]
command = "cargo"
args = ["test"]
[tasks.clippy]
[tasks.xtool-clippy]
command = "cargo"
args = ["clippy", "--", "-D", "warnings"]

View File

@ -9,6 +9,14 @@
env = { "BINARY_FILE" = "${KERNEL_ELF}" }
run_task = "build-custom-binary"
[tasks.kernel]
clear = true
alias = "build-kernel-binary"
[tasks.build]
clear = true
alias = "build-kernel-binary"
[tasks.qemu]
clear = true
alias = "qemu-kernel"

View File

@ -22,7 +22,7 @@ args = ["build", "--features=${TARGET_FEATURES}"]
command = "cargo"
args = ["test"]
[tasks.clippy]
[tasks.xtool-clippy]
command = "cargo"
args = ["clippy", "--", "-D", "warnings"]