Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impl custom tools parsing logic + export PATH creation #85

Merged
merged 7 commits into from
May 26, 2024

Conversation

Vollbrecht
Copy link
Collaborator

This fixes the installation of esp-idf tools in esp-idf version >= 5.3. This is accomplished by stop relighting on the tools.py "export" command and instead parse and evaluate the tools.json file found in esp-idf ourselfs. Previously embuild relight on broken output of the "export" command to get all necessary information. This was fixed upstream and we cant use it the way we did previously.

The tools.json file is the source of truth for the tools.py installation script and is used in this tool now to get the equivalent output needed. E.g providing the python virt_env and the path to all installed tools ( compiler, ninja, cmake etc)

Copy link
Collaborator

@ivmarkov ivmarkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change is fine. My only bigger comment is w.r.t. the untyped representation of the tools.json file.

src/espidf.rs Outdated

tools_file.read_to_string(&mut tools_string)?;

let parsed_file = serde_json::from_str::<serde_json::Value>(&tools_string)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you parsing the tools.json file as an untyped map?
I would assume it would still make sense to have an internal struct named ToolsJson or suchlike, which is strongly typed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, i was a bit lazy here. I think there is not to much benefit here for creating a separate strongly typed version over the raw serialized data ( skipping stuff that are not needed), but i can implement that so no problem there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you, but it would lower the amounts of unwraps in this code considerably, I think.
If you decide not to, just merge.

Copy link
Collaborator Author

@Vollbrecht Vollbrecht May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i addressed that, shooting with big guns now. 🔫 In the process i found out multiple problems in the json schema used by espressif themself. No unwraps anymore ( at least as far as the schema is concerned).

src/espidf.rs Outdated

let version_cmd_args = tool_object["version_cmd"]
.as_array()
.unwrap()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These unwraps here and below are precisely because the tool_object is untyped.

src/espidf.rs Outdated
"linux" => match arch {
"x86_64" => Some("linux-amd64"),
// TODO add and test arm variants
_ => None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to at least add support for RPI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arm is kinda a wormhole on linux ;D for rpi 3 & 4 & 5 i think we need different targets and it depends on what OS are flashed onto the pi. E.g a stock "pi os" or some debian version. I think they are all "linux" on the os, but the second part is more unclear. Do you know working matching patterns for the "arch" variants for the different thumb and aarach variants on pi3 -pi5. IIrc they are all different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added linux arm variants the way i think its correct

@Vollbrecht Vollbrecht merged commit 04369e0 into esp-rs:master May 26, 2024
1 check passed
tomstokes added a commit to tomstokes/embuild that referenced this pull request Jun 14, 2024
The custom tools parsing logic introduced in esp-rs#85 does not process the overrides in tools.json. This omission breaks compilation on macOS and likely several other platforms.

This commit adds override parsing logic to properly handle overrides from tools.json

Signed-off-by: Tom Stokes <[email protected]>
tomstokes added a commit to tomstokes/embuild that referenced this pull request Jun 14, 2024
The custom tools parsing logic introduced in esp-rs#85 has incorrect ARCH values. The list of possible ARCH values can be found in the Rust documentation: https://doc.rust-lang.org/std/env/consts/constant.ARCH.html

Unfortunately, the Rust standard library doesn't distinguish between armel and armhf for 32-bit ARM, so this defaults to armel for 32-bit ARM.

The previous code would not properly match any ARM platforms (armv7 and armv8 are not possible ARCH values) and was missing 32-bit Linux.

Signed-off-by: Tom Stokes <[email protected]>
tomstokes added a commit to tomstokes/embuild that referenced this pull request Jun 14, 2024
The custom tools parsing logic introduced in esp-rs#85 has incorrect ARCH values. The list of possible ARCH values can be found in the Rust documentation: https://doc.rust-lang.org/std/env/consts/constant.ARCH.html

Unfortunately, the Rust standard library doesn't distinguish between armel and armhf for 32-bit ARM, so this defaults to armel for 32-bit ARM.

The previous code would not properly match any ARM platforms (armv7 and armv8 are not possible ARCH values) and was missing 32-bit Linux.

Signed-off-by: Tom Stokes <[email protected]>
Vollbrecht pushed a commit that referenced this pull request Jun 15, 2024
* Process overrides in custom tools logic

The custom tools parsing logic introduced in #85 does not process the overrides in tools.json. This omission breaks compilation on macOS and likely several other platforms.

This commit adds override parsing logic to properly handle overrides from tools.json

Signed-off-by: Tom Stokes <[email protected]>

* Fix platform matching in tools parsing

The custom tools parsing logic introduced in #85 has incorrect ARCH values. The list of possible ARCH values can be found in the Rust documentation: https://doc.rust-lang.org/std/env/consts/constant.ARCH.html

Unfortunately, the Rust standard library doesn't distinguish between armel and armhf for 32-bit ARM, so this defaults to armel for 32-bit ARM.

The previous code would not properly match any ARM platforms (armv7 and armv8 are not possible ARCH values) and was missing 32-bit Linux.

Signed-off-by: Tom Stokes <[email protected]>

* Fix clippy warning with 1.79.0 toolchain

The newest version of clippy catches a clippy::manual-unwrap-or-default issue, causing CI builds to fail.

This implements the recommended fix and therefore should fix the CI builds.

Signed-off-by: Tom Stokes <[email protected]>

---------

Signed-off-by: Tom Stokes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants