diff options
author | Christian Poveda Ruiz <31802960+pvdrz@users.noreply.github.com> | 2022-11-02 15:30:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 15:30:34 -0500 |
commit | 9c32b460481903d90c6ac5df277bfa853a0558d8 (patch) | |
tree | 6ee9ed2f853a78942314fb71df3868b89125cc86 /bindgen-cli/options.rs | |
parent | a673a6bc9b83675a7468379e79dcf5d5659c4623 (diff) |
Add the `--override-abi` option (#2329)
* Add the `--override-abi` option.
This option can be used from the CLI with the <abi>:<regex> syntax and
it overrides the ABI of a function if it matches <regex>.
Fixes #2257
Diffstat (limited to 'bindgen-cli/options.rs')
-rw-r--r-- | bindgen-cli/options.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bindgen-cli/options.rs b/bindgen-cli/options.rs index 5c3960e9..c186cfd9 100644 --- a/bindgen-cli/options.rs +++ b/bindgen-cli/options.rs @@ -568,6 +568,12 @@ where Arg::new("merge-extern-blocks") .long("merge-extern-blocks") .help("Deduplicates extern blocks."), + Arg::new("override-abi") + .long("override-abi") + .help("Overrides the ABI of functions matching <regex>. The <override> value must be of the shape <abi>:<regex> where <abi> can be one of C, stdcall, fastcall, thiscall, aapcs or win64.") + .value_name("override") + .multiple_occurrences(true) + .number_of_values(1), Arg::new("V") .long("version") .help("Prints the version, and exits"), @@ -1088,5 +1094,17 @@ where builder = builder.merge_extern_blocks(true); } + if let Some(abi_overrides) = matches.values_of("override-abi") { + for abi_override in abi_overrides { + let (regex, abi_str) = abi_override + .rsplit_once("=") + .expect("Invalid ABI override: Missing `=`"); + let abi = abi_str + .parse() + .unwrap_or_else(|err| panic!("Invalid ABI override: {}", err)); + builder = builder.override_abi(abi, regex); + } + } + Ok((builder, output, verbose)) } |