espflash
espflash copied to clipboard
Add support for using custom cargo metadata when in a workspace
Alright, let's try this again 😁
I took the advice of @liebman and used cargo in place of the cargo_toml package, and this has resulted in a much more robust and flexible solution. Not entirely happy with the load_metadata function still, but it appears to work at least.
I did actually test this on hardware this time around, and it seems to be working as intended. @liebman if you could test this out one more time that would be appreciated!
Also cleaned up the errors module, bumped a couple dependencies, and some other little bits.
(Hopefully) closes #291
Using a small test project I tested running at the projects root and in the binary crates directory.
I found that this needs to use a newer cargo than 0.63 or it does not have support for workspace inheritance and you get this
Error: cargo_espflash::invalid_workspace
× The current workspace is invalid, and could not be loaded
help: Ensure that a valid Cargo.toml file is in the executing directory
If I update it to 0.66 (latest) it works well. With one minor issue.
- Running from root works well (with .cargo/config.tom at workspace root level)
- Running from the binary crate fails if there is no
.cargo/config.tomlin the current directory as it can't find the target (it does not look in the workspace root directory)
Basically there currently has to be a .cargo/config.toml in the current directory to specify a target. Ideally it would look first in the package that will be flashed (--package option if running from root) and if one is not found there then the workspace root.
I see you have a comment about having to use an older version - would not that only apply if these were going to be run on an esp32 target?
Sorry for the delays, I needed a little break from this project 😅
Thank you for providing the example project. I have made a number of additional changes and I am able to flash your project both from the workspace root and from within the candle package, so I think we're in good shape! @liebman if you wouldn't mind just giving this one more test to verify it's working on your end that would be appreciated!
EDIT: Oops, cargo is unhappy about our MSRV. Will fix.
This works!