Skip to content

Add ability to dump equivalent commandline flags from builder #548

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

Closed
fitzgen opened this issue Feb 28, 2017 · 16 comments
Closed

Add ability to dump equivalent commandline flags from builder #548

fitzgen opened this issue Feb 28, 2017 · 16 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Feb 28, 2017

This would be really useful for being able to reproduce (and then minimize with creduce) bindgen failures inside build.rs.

I find myself doing a hacky job of this manually with stylo right now.

@fitzgen
Copy link
Member Author

fitzgen commented Feb 28, 2017

I can mentor an ambitious contributor who might want to take this on. Leave a comment if that is you.

@basic-bgnr
Copy link
Contributor

@fitzgen I volunteer. What's next ?

@fitzgen
Copy link
Member Author

fitzgen commented Mar 2, 2017

@basic-bgnr great!

In src/lib.rs there is the Builder struct, which provides a programmatic API for configuring bindings generation. The other API is the command line API. When debugging bindgen behavior with creduce, it is often easier to use the command line API. So, it would be great to have a Builder::command_line_flags() method that returned a Vec<String> representing the equivalent command line flags for the given Builder instance.

See src/options.rs for how command line flags get translated into a Builder, which is the reverse transformation that we are interested in.

We can test it by adding a tests module to the bottom of the file:

#[cfg(test)]
mod tests {
    #[test]
    fn a_unit_test_function() {
        // ...
    }
}

Let me know if you have any questions or if any of that isn't clear. Thanks! :)

@basic-bgnr
Copy link
Contributor

@fitzgen OK great, I'll get to it shortly.

@basic-bgnr
Copy link
Contributor

basic-bgnr commented Mar 5, 2017

@fitzgen, I'm still reading the source, will get into actual writing by tonight. Is there any deadline for completion?
LIBCLANG_PATH was peculiar to solve during building with cargo.

@fitzgen
Copy link
Member Author

fitzgen commented Mar 6, 2017

@basic-bgnr no deadline, this is just a useful little feature, not anything anyone is blocked on.

LIBCLANG_PATH was peculiar to solve during building with cargo.

Did you end up getting a build + tests up and running OK? Is there anything we should add/change in CONTRIBUTING.md to make this process more clear?

Note that this is only needed if you're running bindgen with a libclang that isn't the system libclang or isn't on the system lib path.

@basic-bgnr
Copy link
Contributor

@fitzgen sorry, the issue was not with building but running. Nothing too much of hassle, but i had to create symbolic link of libclang-3.8.so.1 (on my current machine) to libclang.so.1 to get it running.

@fitzgen
Copy link
Member Author

fitzgen commented Mar 15, 2017

@basic-bgnr how are things going? Any questions I can answer for you?

@basic-bgnr
Copy link
Contributor

@fitzgen nothing right now. Just wondering whether my solution is little bit on the ugly side. How long do you think in terms of LOC should the solution be?

@fitzgen
Copy link
Member Author

fitzgen commented Mar 15, 2017

@basic-bgnr I'm not sure, but I suspect there might be a fair bit of boilerplate. If you want more specific feedback, its easiest to open a work-in-progress PR so we can talk about the code there.

@basic-bgnr
Copy link
Contributor

@fitzgen ok

@basic-bgnr
Copy link
Contributor

@fitzgen, The RegexSet struct has private field items which contains all the string args. Should I implement a getter function or simply make the field pub. ?

@fitzgen
Copy link
Member Author

fitzgen commented Mar 20, 2017

@basic-bgnr a getter that returns immutable references is probably best.

@fitzgen
Copy link
Member Author

fitzgen commented Apr 6, 2017

@basic-bgnr how are things going? Anything I can do to help?

@basic-bgnr
Copy link
Contributor

@fitzgen, I am out of country for days. I'll push the commit within 4-5 days. Thank you.

bors-servo pushed a commit that referenced this issue Apr 13, 2017
Issue #548 : Added command line flag generation method to Builder

1. Added new method `command_line_flags` to `Builder` to generate
   list of command line arguments supplied.[file: src/lib.rs]

2. Added new method `get_set` and `get_items` method to `RegexSet`
   to return immutable reference to it's fields.[file: src/regex_set.rs]

3. Added simple test case for `command_line_flags` method.[file: src/lib.rs]
@fitzgen
Copy link
Member Author

fitzgen commented May 1, 2017

This has been fixed.

@fitzgen fitzgen closed this as completed May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants