Skip to content

Provide library access to code generation #214

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

Merged
merged 3 commits into from
Jan 22, 2019
Merged

Provide library access to code generation #214

merged 3 commits into from
Jan 22, 2019

Conversation

tones111
Copy link
Contributor

This change implements the minimal API described in #207 to allow downstream build.rs scripts to generate the svd2rust output.

Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

Looks good.

Can you put Target inside util instead?

@Emilgardis Emilgardis requested a review from japaric May 10, 2018 06:14
Emilgardis
Emilgardis previously approved these changes May 10, 2018
@tones111
Copy link
Contributor Author

Rebased and updated for v0.13.0

@Emilgardis
Copy link
Member

cc @japaric I want to get an ok from you before merging

@tones111
Copy link
Contributor Author

Rebased for v0.13.1. Instead of returning a tuple a struct with named fields is used to remove ambiguity over the tuple ordering.

dfrankland added a commit to dfrankland/svd2rust that referenced this pull request May 26, 2018
@tones111
Copy link
Contributor Author

ping @Emilgardis @japaric

I'm still interested in landing this PR. rebased against the current master branch.

therealprof
therealprof previously approved these changes Oct 20, 2018
Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

LGTM, but ALAS we can't make any changes because CI is broken.

@jacobrosenthal
Copy link
Contributor

I found myself hacking this in as well. A lof of crates have shell scripts that attempt to cargo install binaries at specific versions. Until thats more doable, making form, svd2rust etc all library usable means we can lock to the correct version in the cargo manifest.

@jacobrosenthal
Copy link
Contributor

jacobrosenthal commented Nov 26, 2018

generate isnt probably the best user facing api, but I have a pretty rough fork that exposes that function, though I wouldn't pr it, as I had to hack on the (i guess now deprecated?) error style used here that I don't really understand how/if theres a good replacement for yet.
https://github.com/jacobrosenthal/svd2rust/tree/lib

It works in concert with a PR into form as well
djmcgill/form#6

Which leads to a cargo alias style script that looks pretty decent and should cross platform and versioned better than the update.sh scripts most people are using
https://github.com/jacobrosenthal/efm32-rs/blob/master/tools/src/bin/gen.rs

Or could be its own full featured crate but Im ambivalent on that atm.

@jacobrosenthal
Copy link
Contributor

After I cleaned my version up, it became the naive solution exposing internals tried here and rejected. oops. Sorry for the noise.

Ive successfully utilized this PR now, though it does seem to be missing the build_rs file generation.

Emilgardis
Emilgardis previously approved these changes Nov 28, 2018
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

lgtm 👍 , I do still want an approval from @japaric before merging though

@jacobrosenthal
Copy link
Contributor

One simple thing thats missing here is the build_rs output. I added it to my commit here and could pr:
jacobrosenthal@0bcc4db

@tones111
Copy link
Contributor Author

My ultimate goal for this effort is to finish the implementation for stm32-rs/stm32-rs#5

Wouldn't generating the build.rs file prevent the crate from providing its own? In the case of stm32-rs, the crate would be able to cover a large number of devices and the user selects the target with a feature flag. In that case the build.rs file has a bunch of other work to accomplish like extracting the correct svd file from one of the archives in the repo.

@jacobrosenthal
Copy link
Contributor

jacobrosenthal commented Nov 29, 2018

From looking at the tool, it seems like the code path for cortex m targets at the very least wants the (currently hardcoded) build.rs to load the memory.x

If you dont want it you could not save it.

Also you should check out my script (which I wasnt intending to run as a build.rs) where I run a pinned programmatic version of rustfmt instead of using command
https://github.com/jacobrosenthal/efm32-rs/blob/master/tools/src/bin/gen.rs#L25-L31

@japaric
Copy link
Member

japaric commented Dec 4, 2018

Thanks for the PR @tones111. I agree with @jacobrosenthal that the build.rs file should be part of the Generation output. Also device.x is not always generated so device_x should be Option<String> to indicate that; likewise build_rs should be None if device_x is None so I think we want something like device_x_build_rs: Option<(String, String)> but with a struct instead of a tuple (and better names).

Finally, Generation should have a private field so we can add more public fields to it without bumping the minor version.

@tones111 tones111 dismissed stale reviews from Emilgardis and therealprof via 46fd643 December 9, 2018 15:02
@tones111 tones111 requested a review from a team as a code owner December 9, 2018 15:02
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

Looks good, just some tiny nit-picks.

@jacobrosenthal
Copy link
Contributor

I tested this for my use cases and it is working well. Well done @tones111

@jacobrosenthal
Copy link
Contributor

Any last requests @therealprof or @japaric can we get a merge (and a point release)

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

LGTM

@therealprof
Copy link
Contributor

bors try

bors bot added a commit that referenced this pull request Dec 15, 2018
@bors
Copy link
Contributor

bors bot commented Dec 15, 2018

try

Build failed

Copy link
Member

@japaric japaric left a comment

Choose a reason for hiding this comment

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

LGTM. @tones111 thanks for working on this!

@Emilgardis
Copy link
Member

try timed out, seems the version of the backtrace crate causing the previous ci fails has been yanked however.

@therealprof
Copy link
Contributor

bors try

bors bot added a commit that referenced this pull request Jan 22, 2019
@bors
Copy link
Contributor

bors bot commented Jan 22, 2019

try

Build succeeded

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Jan 22, 2019
214: Provide library access to code generation r=therealprof a=tones111

This change implements the minimal API described in #207 to allow downstream build.rs scripts to generate the svd2rust output.

Co-authored-by: Paul Sbarra <sbarra.paul@gmail.com>
Co-authored-by: Jacob Rosenthal <jacobrosenthal@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jan 22, 2019

Build succeeded

@bors bors bot merged commit 477531b into rust-embedded:master Jan 22, 2019
@tones111 tones111 deleted the lib_generate branch January 27, 2019 17:01
@japaric japaric mentioned this pull request Feb 5, 2019
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.

5 participants