FrameworkComputer / inputmodule-rs

Framework Laptop 16 Input Module SW/FW
MIT License
223 stars 24 forks source link

Use cargo-make to build the packages #55

Closed jscatena88 closed 1 year ago

jscatena88 commented 1 year ago

As mentioned in #33, here is a first pass at cargo make integration, Running cargo make in the workspace root will build every package with the appropriate target (it will also run rustfmt by default). cargo make can also be run in individual packages to build just that package. This only scratches the surface of what the tool can do(e.g. it can also be used to install dependencies like flip-link, it can be used as part of your CI, etc. )

You will need to install cargo make to make use of the changes.

I also added a a more understandable compiler error if someone attempts to build fl16-inputmodules with mutually exclusive features enabled.

JohnAZoidberg commented 1 year ago

Thanks! This is pretty cool :) Can it also work for running commands? Currently it's quite cumbersome to run the inputmodule-control program:

# Linux
cargo run --target x86_64-unknown-linux-gnu -p inputmodule-control

# Windows
cargo run --target x86_64-pc-windows-msvc -p inputmodule-control
JohnAZoidberg commented 1 year ago

And can I apply the profile options listed here only to the firmware workspace members? https://github.com/FrameworkComputer/inputmodule-rs/issues/19#issuecomment-1669220692

jscatena88 commented 1 year ago

It should be easy enough to customize the build tasks for each package to call the correct build profile by default, maybe place the non-firmware profiles behind names like profile.release-application and then in the inputmodule-control Makefile you could appropriate env.BUILD_TYPE the way I did in the top level Makefile. i.e.

[tasks.build-release]
env.BUILD_TYPE = "--release-application"

[tasks.build]
env.BUILD_TYPE = "--dev-application"

When you add a task in one of your makefiles it will only override the fields you provide overrides for by default so everything else about the build and build-release tasks would be left alone. (to override everything you add clear = true)

Note all of this is off the cuff and untested for now, I don't have access to my dev machine at this exact moment

EDIT: I also came across CARGO_MAKE_CARGO_PROFILE that looks like it ties in somehow

jscatena88 commented 1 year ago

Running commands should also be fairly trivial, just add something to the effect of

[tasks.run]
command = "cargo"
args = [
    "run",
    "--target",
    "${CARGO_MAKE_RUST_TARGET_TRIPLE}",
]

in the inputmodule-control Makefile. You should then be able to run cargo make run in the inputmodule-control directory or in the root with --cwd inputmodule-control (as above this is currently untested)

JohnAZoidberg commented 1 year ago

Okay, I'm happy with it, thanks a lot @jscatena88!

jscatena88 commented 1 year ago

Cheers! I'm glad it was helpful