Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Complete esp32h2 support, simplify linker args, create snippets #141

Merged
merged 9 commits into from
Apr 19, 2024

Conversation

MabezDev
Copy link
Member

This PR:

  • Removes the logging feature and enables it by default
  • Enables esp-wifi to work with the esp32h2
  • Simplifies the linker arg passing by using a build script.
  • Moves some modular bits of code into snippets. Inspired by Idea: Offering VSCode Snippets #140

On its own this PR might seem a little pointless, but by having snippets we can easily make the generator less monolithic and easier to maintain. Instead of one template with a million options, we could now easily create more templates with less options which should reduce the cognitive load of making changes. I will do this in a follow up PR because it might be a bit controversial, but I think the changes here are okay on their own.

@MabezDev MabezDev force-pushed the simplify-linker-args branch 2 times, most recently from bb3eaad to bb88e26 Compare January 10, 2024 18:35
@MabezDev
Copy link
Member Author

Hmm I guess without cargo-generate/cargo-generate#884 it makes this quite a bit more difficult, because I means trying to keep rustfmt valid code in snippets :/

@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 11, 2024

I think I like the idea of snippets. We could even check the condition when populating the snippet and wouldn't need the if in the snippet

While waiting for fmt support in cargo-generate: What was the reason we removed the cargo fmt step from the post-script?

@SergioGasquez
Copy link
Member

While waiting for fmt support in cargo-generate: What was the reason we removed the cargo fmt step from the post-script?

It was causing errors on user who didn't have rustfmt component installed. We can think adding it back if needed.

@SergioGasquez
Copy link
Member

I like the snippets idea, it definitely makes the template more clean, specially if we avoid adding includes!

post-script.rhai Outdated Show resolved Hide resolved
@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 11, 2024

While waiting for fmt support in cargo-generate: What was the reason we removed the cargo fmt step from the post-script?

It was causing errors on user who didn't have rustfmt component installed. We can think adding it back if needed.

I wonder if there is a way to ignore such an error or to check if rustfmt is installed before trying to run the command 🤔

@MabezDev
Copy link
Member Author

So what's the consenus, do we wait/try to implement cargo generates rustfmt builtin, or do we add back the post creation formatting? If we go with the latter, could someone point me to the PR that removed it as a reference 🙏.

@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 11, 2024

I found at least the PR which originally added cargo fmt: https://github.com/esp-rs/esp-template/pull/55/files#diff-0faca75bf39fad85951e939d56d340b47f8ff90ccbfb142f6f1787f649c699c4

Probably having it as a built-in feature for cargo-generate would certainly be even better

@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 11, 2024

I think we need to pass -a to cargo generate in CI in order to make it execute commands

@MabezDev MabezDev force-pushed the simplify-linker-args branch from 3bfc0cb to 03bc1a7 Compare January 11, 2024 13:54
@MabezDev
Copy link
Member Author

So the last thing is around the h2, which will probably require changes in esp-wifi. For some reason dhcpv4 is enabled by default, and dhcpv4 enables the wifi and we get an error.

@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 11, 2024

So the last thing is around the h2, which will probably require changes in esp-wifi. For some reason dhcpv4 is enabled by default, and dhcpv4 enables the wifi and we get an error.

I need to compile with "no-default-features" - having "dhcpv4" a default feature there is probably not ideal 🤔

@SergioGasquez
Copy link
Member

If we add back the rustfmt cmd, we need to update all the places where we document the cargo-generate command, formatting the template, in this case, is relatively easy: see 3623ec5. But definitely, it's easier with rustfmt

@MabezDev
Copy link
Member Author

PR is green 😎, it requires a new release of the esp-wifi, but no rush there. Overall, are we happy with this approach?

@SergioGasquez
Copy link
Member

SergioGasquez commented Jan 23, 2024

I think this approach simplifies the template maintenance! So it's worth giving it a try, if we see that it still hard to maintain in the future we can always reassess.

We just have to take into account that after merging we need to update the books/repos that have the cargo-generrate esp-rs/esp-template to include the -a flag.

Edit: We should also update the readme with the -a flag

@bjoernQ
Copy link
Contributor

bjoernQ commented Jan 23, 2024

I like the approach

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

LGTM

@MabezDev
Copy link
Member Author

Frustratingly cargo generate can't currently do what I want to do for the next step: cargo-generate/cargo-generate#1054 (comment). I was planning on reusing .github etc for each sub template, but it looks like we might have to duplicate them, at least for now :(. Maybe that's not so bad? We either do that, or maybe we could try and symlinks stuff but that sounds like a recipe for hell on windows.

@MabezDev
Copy link
Member Author

Oops, completely forgot about this. What do we think about merging this in its current form? At the very least we will get optional formatting on the project at the end which is an improvement.

I can rebase this, and if no one is working on a port to the new release I could also do that too?

@bjoernQ
Copy link
Contributor

bjoernQ commented Apr 18, 2024

It's definitely an improvement so I guess it's worth to merge it

@MabezDev MabezDev force-pushed the simplify-linker-args branch from 7659448 to 3a385fe Compare April 18, 2024 11:18
@MabezDev MabezDev force-pushed the simplify-linker-args branch 2 times, most recently from 84bd110 to 49101d9 Compare April 19, 2024 10:25
@MabezDev MabezDev force-pushed the simplify-linker-args branch from 49101d9 to 167adab Compare April 19, 2024 10:37
@MabezDev
Copy link
Member Author

This should be ready to go now I think :)

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

LGTM

@MabezDev MabezDev merged commit c5064f0 into main Apr 19, 2024
14 checks passed
@MabezDev MabezDev deleted the simplify-linker-args branch April 19, 2024 12:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants