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

Add support for config files #2917

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add support for config files #2917

wants to merge 4 commits into from

Conversation

pvdrz
Copy link
Contributor

@pvdrz pvdrz commented Aug 30, 2024

This PR adds support for configuration files when using bindgen-cli.

The main motivation for this feature is that, with the growing number of options that bindgen has, it is hard to keep track on the options used in each invocation.

I decided to use TOML as it has become the de-facto configuration format in several Rust projects such as Cargo and Rustfmt.

To use this feature you can either pass the --config-path arguments to bindgen with the path to the configuration file, or create a bindgen.toml file in the current directory.

If you want to use this feature but you don't want to transcribe your CLI arguments by hand, you can use the --dump-config flag to dump the passed configuration into stdout.

If you want to keep using bindgen the old way, you can pass the --ignore-config flag. Which will ignore any configuration file, this includes both the --config-path argument and the default bindgen.toml file.

Fixes #1898 and #2508

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

This is great (lacking tests but that should be doable?), that said, why making it cli-only? It seems it might be worth making it usable from the library as well. That way we can possibly even replace the bindgen-flags: stuff. But anyways even cli-only it seems worth doing.

@pvdrz
Copy link
Contributor Author

pvdrz commented Sep 3, 2024

This is great (lacking tests but that should be doable?)

yeah testing this shouldn't be that hard.

that said, why making it cli-only? It seems it might be worth making it usable from the library as well.

this would have the extra hiccup of having to move BindgenOptions from bindgen-cli to bindgen and only make it public when the __cli feature is enabled. But it should be doable.

That way we can possibly even replace the bindgen-flags: stuff.

That would be cool but at the same time we need some kind of test for the CLI args so we can check the flags actually work.

But anyways even cli-only it seems worth doing.

🎉

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.

read arguments from response file
2 participants