summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-02-07Release 0.64.0 Request (#2399)v0.64.0Justin W Smith
Prepare 0.64.0 Release --------- Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
2023-02-07Generate extern wrappers for inlined functions (#2335)Christian Poveda Ruiz
* 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 #1090. --------- Co-authored-by: Amanjeev Sethi <aj@amanjeev.com>
2023-02-06Fix wrong entry in changelog (#2404)Christian Poveda Ruiz
2023-01-25Add *-espidf target triple mappings (#2397)Josh Guilfoyle
Fixes #2396. 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-20Implement cli option for custom derive (#2328)Dan Dumont
* 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-18Migrate CLI argument parse to the clap `derive` API (#2390)Christian Poveda Ruiz
* Migrate CLI argument parsing to the derive API * Fix docs * Fix tests * Use `override_usage` * Update changelog
2023-01-18Remove any references to `master` (#2391)Christian Poveda Ruiz
2023-01-16Add trigger for push to `main` branch for sync'ing with `master` (#2387)Amanjeev Sethi
* gh action for merging main to master on pr merge * remove pull_request as trigger. only use push, that is after merging the pull_request
2023-01-12Update to clap 4. (#2380)Andrew Walbran
* Update to clap 4. * Bump MSRV to minimum required by clap 4. * Mention clap update in CHANGELOG.
2023-01-10Document semantic difference between constructors and wrappers (#2385)Christian Poveda Ruiz
2023-01-08fix: test runner for fuzzy tests and update documentationAmanjeev Sethi
Signed-off-by: Amanjeev Sethi <aj@amanjeev.com>
2023-01-06codegen: Look through typedefs to detect void return type. (#2379)Emilio Cobos Álvarez
* codegen: Look through typedefs to detect void return type. And reuse a bit more code. Should fix #2377, but needs a test (can't run tests atm). * Add tests * Run rustfmt * Update changelog Co-authored-by: Christian Poveda <christian.poveda@ferrous-systems.com>
2022-12-16Run doctoc (#2376)Christian Poveda Ruiz
2022-12-15Document how to format code (#2375)Christian Poveda Ruiz
* Document how to format code * Fix typo * Fix formatting * Ignore code snippet
2022-12-15Extend documentation about deprecation of wildcard patterns (#2374)Christian Poveda Ruiz
2022-12-09Fix clippy warnings (#2371)Christian Poveda Ruiz
2022-12-07Bump `clang-sys` version (#2368)Christian Poveda Ruiz
* Bump `clang-sys` version * add libtinfo5 package to fix CI
2022-12-07codegen: Do generate field offset checks for classes with multiple bases.Emilio Cobos Álvarez
The bug only affects virtual inheritance, so instead disable layout tests in the test that we know is broken. Not generating layout tests is wrong anyways, because the offset would be wrong.
2022-11-28Document callback changes and avoid static lifetime (#2366)Christian Poveda Ruiz
2022-11-28Extend `generated_name_override` callback to variables (#2351)Justin W Smith
* This change updates `ParseCallbacks::generated_name_override` to accept a second parameter indicating the kind of item the name applies to (currently, either `Function` or `Var`). * A `CallbackItemKind` enum was added to serve as the type for this second parameter. * Tests have been updated to verify that the names of both function and variable can be updated by this callback.
2022-11-28Update CHANGELOG.md (#2365)Christian Poveda Ruiz
2022-11-28Fix name collision between C enum and typedef (#2326)David Tolnay
Fixes #2008. Example: ```c enum Enum { Variant }; typedef int16_t Enum; ``` This is valid and idiomatic C (though not valid C++). `cbindgen` uses this idiom as the default C translation of Rust enums, the equivalent of what would be `enum Enum : int16_t { Variant };` in C++. `bindgen header.h` before: ```rust pub const Enum_Variant: Enum = 0; pub type Enum = ::std::os::raw::c_uint; pub type Enum = i16; ``` ```console error[E0428]: the name `Enum` is defined multiple times --> generated.rs:3:1 | 2 | pub type Enum = ::std::os::raw::c_uint; | --------------------------------------- previous definition of the type `Enum` here 3 | pub type Enum = i16; | ^^^^^^^^^^^^^^^^^^^^ `Enum` redefined here | = note: `Enum` must be defined only once in the type namespace of this module ``` After: ```rust pub const Enum_Variant: Enum = 0; pub type Enum = i16; ```
2022-11-24Remove traits that have a single implementation (#2363)Christian Poveda Ruiz
2022-11-24Fix clippy warnings (#2362)Christian Poveda Ruiz
2022-11-23Escape method fragments that happen to be rust keywords (#2359)Christian Poveda Ruiz
2022-11-22CONTRIBUTING: Add docs for doing a release. (#2358)v0.63.0Emilio Cobos Álvarez
2022-11-22Release v0.63.0 (#2357)Christian Poveda Ruiz
2022-11-22Deprecate Rust targets lower or equal than `1.30` (#2356)Christian Poveda Ruiz
2022-11-22Add `--wrap-unsafe-ops` option (#2354)Christian Poveda Ruiz
This reverts commit e8ffb42ab66405ac56d04494a30e54b584f2d4dd and adds a new `--wrap-unsafe-ops` option as a workaround.
2022-11-22Add `ParseCallbacks::process_comment` (#2347)Christian Poveda Ruiz
This method can be used to process comments and replace them with whatever the user wants.
2022-11-21Introduce `DeriveInfo` (#2355)Christian Poveda Ruiz
This PR introduces a new non-exhaustive `struct` called `DeriveInfo` to be used as the sole argument of `ParseCallbacks::add_derives` with the purpose of being able to extend the information passed to this method in a backwards-compatible manner, meaning that adding new fields to `DeriveInfo` won't be a breaking change when releasing a new version.
2022-11-17Remove deprecated methods (#2346)Christian Poveda Ruiz
2022-11-17add LICENSE symlinks to all individually published cratesFabio Valentini
2022-11-17v0.62.0v0.62.0Emilio Cobos Álvarez
2022-11-14document regex arguments handling (#2345)Christian Poveda Ruiz
2022-11-11Document and test allowlisting and blocklisting methods (#2344)Christian Poveda Ruiz
2022-11-11Fix duplicated function names (#2341)Christian Poveda Ruiz
Even though this change does name deduplication in a slower way, it avoids name collisions without any breaking changes in the test suite. Fixes #2202
2022-11-10Handle the `const struct *` and `struct *` patterns (#2304)Christian Poveda Ruiz
Given that C keeps a different namespace for `struct`/`enum`/`union` and `typedef` aliases. The following patterns ```c typedef const struct foo { void *inner; } *foo; typedef struct bar { void *inner; } *bar; ``` are valid C code and produces both a `struct` and a pointer called `foo` and `bar` in different namespaces. Given that Rust does not make this distinction, we add the `_ptr` prefix to the pointer type aliases to avoid any name collisions.
2022-11-09Fix inline function identificationkohanis
2022-11-09ir: Don't crash with built-in unexposed types from libclang.Emilio Cobos Álvarez
This fixes #2325. The issue is that `__bf16` is not exposed at all by libclang, which causes us to crash. It's a bit of a shame libclang doesn't expose it but there's no rust equivalent I think, so this should be ok for now. Unfortunately no test because the header crashes older clang versions.
2022-11-04Fix clippy warnings (#2336)Christian Poveda Ruiz
2022-11-04Wrap `unsafe` function's bodies in `unsafe` blocks (#2266)Christian Poveda Ruiz
This guarantees that bindings generated by `bindgen` compile even if the `unsafe_op_in_unsafe_fn` lint is denied.
2022-11-04Clean the implementation of `Default` for `BindgenOptions` (#2332)Christian Poveda Ruiz
* Clean the implementation of `Default` for `BindgenOptions`
2022-11-04Add support for the `"C-unwind"` ABI (#2334)Christian Poveda Ruiz
* Add support for the `"C-unwind"` ABI This allows using `"C-unwind"` as an ABI override if the rust target is nightly.
2022-11-02Add the `--override-abi` option (#2329)Christian Poveda Ruiz
* 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
2022-11-02Allow callback composition (#2330)Christian Poveda Ruiz
* 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-02Fix clippy warnings (#2331)Christian Poveda Ruiz
2022-11-01Add a mechanism to rerun bindgen with the same user options (#2292)Christian Poveda Ruiz
* 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 #1090 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-01Add tutorial about non-system libraries (#2318)Christian Poveda Ruiz
* add tutorial about non-system libraries * fix broken comment * ignore code snippet
2022-10-31Replace confusing note in cpp.md on "RVO"Charlie Barto
The original commit adding this note referenced #778, but then went on to talk about how the problem was RVO and that the problem is not possible to solve in bindgen because bindgen can't know if RVO happened or not. However this is incorrect in several ways. The problem in #778 has nothing whatsoever to do with RVO but rather with bindgen simply not understanding the calling convention for passing or returning types that are "non trivial for the purposes of calls". This is completely consistent and does not depend on what the optimizer decided to do (after all, if callsite side calling-convention did depend on what the optimizer happened to do inside the function it would be impossible for C++ compilers to emit correct calls to external C++ functions!). You can see this quite clearly [here](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGIM6SuADJ4DJgAcj4ARpjEEgDspAAOqAqETgwe3r7%2ByanpAiFhkSwxcVyJdpgOGUIETMQEWT5%2BAVU1AnUNBEUR0bEJtvWNzTltwz2hfaUDFQCUtqhexMjsHAD06wDUACoAnkmYW3tLxFtoWFsIsZikWyRbtKhM6FuGW5iqrEn0AHQmGgAggoCMQvA4tgRMCCokwlFsTPErPEACImADMViBILBEKhIIRSIBgK2pMh0IIEDmGKxJLJ%2BMpaAYBIZ5gAbNTMcSyVsAG6oPDoABUkJpxMRaK5QIZWwUAEcvA1MFTCbSeTKCIjkZK1WTiJgCMsGKKpYCJeKgaECFsWExQiqtdz6RTIQj0SjZQqlVSxUCnaT9YbiMa0gAvTCoKgQBmc2kSjgLWicACsvD8HC0pFQnDc1msstOqwRZnRPFIBE0CYWAGsQOj0b9603my22fpOJI05Ws5xeAoQBpy5WFnBYEg0CwknRYuRKBOp/Q4sAFMwkgoEKgCKQsLy8KsAGp4TAAdwA8od02WaLQocR%2BxAot2oqEGntOGWJ2xBKeGLQ3xneCwW0jHEADtzwfUal5aFu0%2BaovChd9eCtTAkzA2g8CiYhXw8LBu1BPAWCQhYqAMZdDxPc9GCQmRBBEMR2CkWj5CUNRu10Lh9EMYw80sfRMP7SAFlQJJHAEfsOD7VDqjEvwIFcUY/E44IphKMo9BSNJZMUjT8lk3o1NmWxpI6BguhGTwWj0dpZPMyZin6cohm6HTOJBboDMciQFgUQtGMTFMuzA7MOC2VQAA42QAWjZSQtmAZBkC2aMwQYas5mS3BCAecxSzmXgKwAuYazrBsW3Kps2zQztSHTTMQr7AchyK0hR0QFBUEnacyAoCB526kBl1XddN23TBdwPI8zwvGjr1ve9HzA59mGIf8P06r8CB/P9uyA7jQMzfBIMcaCJMzODkAQtYyxQtDMwwrCcIwNZMwIojuATPgyIUCjpuoj7mPo8QmP4QRFBUdQwN0AIDCMFBeJsB7BKpLNRIyCSoqoBhUCi1DBUwKKmRxcEiDvKT7FklwGHcSycmU6nPJmJzNIKTJaaUvItIyRn1LckzbImVzjIp2oJh5oz3Is7IOcl%2Bzpl5ny/O89sOFTWruxCsLIpiuKEqSlKvDSjKICy0nizygrhxK%2BtGwq8qVZqureAa2wmsKrRipVswgvq3tmo9hZoLvDIQEkIA) Notice how the body of `main` is identical no matter if copy elision is enabled or not. To get `test` passed in a register you must remove the copy constructor. I spent a few hours being really confused by this note before I tracked down the original PR and realized what it was trying to talk about. Hopefully this saves the next person to come across it the same trouble. As an aside I suspect the clang c bindings can already give you information on special member functions and base classes, making it fairly easy to do this correctly. AFAICT bindgen already does not rely on llvm's code generation facilities to figure out the ABI of calls for C (except perhaps indirectly, via rustc), so this seems reasonable to just do in bindgen, explicitly.