Commit Graph

21 Commits

Author SHA1 Message Date
Christian Poveda Ruiz
2be14a3345
Generate extern wrappers for inlined functions ()
* Generate extern wrappers for inlined functions

If bindgen finds an inlined function and the
`--generate-extern-functions` options is enabled, then:

- It will generate two new source and header files with external
  functions that wrap the inlined functions.
- Rerun `Bindings::generate` using the new header file to include these
  wrappers in the generated bindings.

The following additional options were added:
- `--extern-function-suffix=<suffix>`: Adds <suffix> to the name of each
  external wrapper function (`__extern` is used by default).
- `--extern-functions-file-name=<name>`: Uses <name> as the file name
  for the header and source files (`extern` is used by default).
- `--extern-function-directory=<dir>`: Creates the source and header
  files inside <dir> (`/tmp/bindgen` is used by default).

The C code serialization is experimental and only supports a very
limited set of C functions.

Fixes .

---------

Co-authored-by: Amanjeev Sethi <aj@amanjeev.com>
2023-02-07 10:13:48 -05:00
Josh Guilfoyle
a7ff8e1360
Add *-espidf target triple mappings ()
Fixes .

This makes it possible to workaround cc/bindgen issues with esp-rs
projects by using only environment varaibles (TARGET_CC, CLANG_PATH,
etc).  Without this, it requires modifying each crate's build.rs that
you try to depend on to add a target option passed along to clang.
2023-01-25 17:54:19 -05:00
Dan Dumont
bca47cd9c2
Implement cli option for custom derive ()
* custom derives after DeriveInfo

* Introduce `TypeKind` instead of `CompKind`

* Add tests

* Emit CLI flags for callbacks

* update changelog

* run rustfmt

* fix tests

* fix features

Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
2023-01-20 15:12:42 -05:00
Christian Poveda Ruiz
87b535c3c1
Extend documentation about deprecation of wildcard patterns () 2022-12-15 16:02:28 -05:00
Christian Poveda Ruiz
c17c292c73
Fix clippy warnings () 2022-12-09 16:15:59 -05:00
Christian Poveda Ruiz
95fd17b874
Remove traits that have a single implementation () 2022-11-24 11:17:08 -05:00
Christian Poveda Ruiz
73f33e5a02
Fix clippy warnings () 2022-11-24 10:50:15 -05:00
Christian Poveda Ruiz
7e4174990c
Deprecate Rust targets lower or equal than 1.30 () 2022-11-22 12:31:14 -05:00
Christian Poveda Ruiz
046d6f9eea
Add --wrap-unsafe-ops option ()
This reverts commit e8ffb42ab6 and adds a new `--wrap-unsafe-ops` option as a workaround.
2022-11-22 11:41:32 -05:00
Christian Poveda Ruiz
f160d11d56
Add ParseCallbacks::process_comment ()
This method can be used to process comments and replace them with whatever the user wants.
2022-11-22 11:25:13 -05:00
Christian Poveda Ruiz
8fe230830f
Remove deprecated methods () 2022-11-17 10:02:29 -05:00
Christian Poveda Ruiz
678daf56a2
document regex arguments handling () 2022-11-14 12:34:05 -05:00
Christian Poveda Ruiz
4574d766d5
Document and test allowlisting and blocklisting methods () 2022-11-11 13:01:53 -05:00
Christian Poveda Ruiz
bae6170907
Clean the implementation of Default for BindgenOptions ()
* Clean the implementation of `Default` for `BindgenOptions`
2022-11-04 13:08:14 -05:00
Christian Poveda Ruiz
9c32b46048
Add the --override-abi option ()
* 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 
2022-11-02 15:30:34 -05:00
Christian Poveda Ruiz
a673a6bc9b
Allow callback composition ()
* Allow callback composition

Store all the callbacks added to the builder in a `Vec` so bindgen
invokes each one of them in a last-to-first manner.
2022-11-02 13:46:22 -05:00
Christian Poveda Ruiz
83426897af
Fix clippy warnings () 2022-11-02 13:32:32 -05:00
Christian Poveda Ruiz
a2fe04cbaf
Add a mechanism to rerun bindgen with the same user options ()
* Run `Bindings::generate` again if required.

This adds a mechanism so `bindgen` is able to run `Bindings::generate`
multiple times with the same user input if the `generate_static_inline`
option is enabled and `GenerateResult::ShouldRestart` is returned by
`Bindings::generate`.

This is done to eventually solve  which would require to check for
any static inline functions and generate a new header file to be used as
an extra input and run `Bindings::generate` again.
2022-11-01 08:49:57 -05:00
Christian Poveda
0142c0aaf7 Use panic hooks instead of using catch_unwind
One of the advantages of doing this is that `ParseCallbacks` no longer
needs to implement `UnwindSafe` which means that users can rely on
`RefCell` and `Cell` to extract information from the callbacks.

Users relying on `catch_unwind` can still achieve similar behavior using
`std:🧵:spawn`.

Fixes .
2022-10-22 13:11:45 +02:00
Christian Poveda
46cd3af9c6
Implement Clone for Builder
This is done by moving all the remaining `Builder` state into
`BindgenOptions` so any internal logic that affects `Builder` state only
runs once the builder is consumed by `Builder::generate`:

- move `input_headers` to `BindgenOptions`.
- move `input_header_contents` to `BindgenOptions`.
- derive `Clone` for `Builder`.
2022-10-07 14:10:24 -05:00
Christian Poveda
0296f9e86c
split the repo into a workspace
remove `clap` dependency 🎉

update the book installation instructions
2022-10-04 20:47:17 -05:00