Refactor: convert the chip
modules into targets
, eliminate the proxy functions on Chip
enum
#247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the second of three PRs performing refactorings on the code base. #245 was the first.
This PR is quite large, so apologies for that. Unfortunately I couldn't really cut these changes down into smaller components, so it is what it is. Fortunately a significant number of the changes are just updating imports or adding the
.into_target()
function call as needed, so there isn't actually too much new code here.I've tested this on various boards just to ensure I'm still able to flash, and experienced no issues.
There were a few motivations behind these changes:
esptool
they use the termtargets
(which is also common in the host/target sense) so this brings us more in-line with their naming (since we're heavily basingespflash
off ofesptool
anyway) and allows us to flatten (what was previously) thechip
module.Chip
impl. I've added the.into_target()
function which now just returns a given Chip's target instead (asBox<dyn Target>
). This decouples the enumeration of supported chips (targets::Chip
enum) from the target details themselves (targets::Esp32*
.flash_targets
module intotargets
, as they are strongly relatedIn addition to the above points, this PR removes more than it adds (which is always a goal of mine, when possible) and reduces the levels of indirection in the code base as well. We also remove a couple dependencies that weren't really necessary in the first place.
One final point, I have removed the re-exports of all types and left only the modules public. I'm not sure how people feel about this (all of the same types are still available, just namespaced) but it seemed like there wasn't really much thought or consistency put into what we were previously re-exporting, and the types that were exported seemed to be chosen fairly arbitrarily. I can revert this if there is reason to, though.
I would like to get at least a couple sets of eyes on this just due to the large number of changes, so @bjoernQ @SergioGasquez @JurajSadel if any of you are able to take a look at some point this week that would be much appreciated!