67 Commits

Author SHA1 Message Date
a30054014 c1e7498e84 rust-bindgen相关依赖兼容性适配
Signed-off-by: a30054014 <aipeng3@huawei.com>
2025-04-19 16:11:11 +08:00
oh_ci 39e4f73eb8 回退 'Pull Request !9 : bindgen升级0.70.1版本' 2025-04-19 06:22:12 +00:00
月出皎兮 83fcd6d5e2 bindgen升级0.70.1版本
Signed-off-by: 月出皎兮 <xietingwei@h-partners.com>
2025-04-15 20:47:01 +08:00
Christian Poveda Ruiz bd14f85019 Generate extern wrappers for inlined functions (#2335)
* 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-07 10:13:48 -05:00
Christian Poveda Ruiz 0cbd492cc5 Introduce DeriveInfo (#2355)
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-21 10:38:42 -05:00
Christian Poveda 1213b3dfb1 split the repo into a workspace
remove `clap` dependency 🎉

update the book installation instructions
2022-10-04 20:47:17 -05:00
Darren Kulp 6f33a637b6 Skip input headers in Linguist statistics
[skip ci]
2022-06-05 19:47:20 +02:00
Darren Kulp 7ada9e1891 tests: Remove testing_only_libclang_4 and expectations 2022-03-15 03:54:37 +01:00
Darren Kulp d326a62e80 tests: Remove clang-3.9 expectations 2022-02-18 19:33:25 +01:00
Jake Merdich 15bb6abfd4 Allow fully-qualified derives
Adding a custom derive like "serde::Deserialize" results in a panic complaining
that it is not a valid Ident. Derive params are not identifiers, so treat it as
a token stream instead.
2022-02-18 19:32:08 +01:00
MikuroXina 009a7ca6e3 Remove deprecation and Replace 2021-12-29 20:39:01 +01:00
MikuroXina 7b4142f8d5 Replace generate with gen in test 2021-12-29 20:39:01 +01:00
Eric Seppanen 80f64637f5 allow custom derives on enums
Custom derives are just as useful on enums as they are on structs; not
supporting this was an oversight.

Adds a test that will fail to compile if the custom derive doesn't work
on enums. This test fails without the codegen fix.
2021-11-26 02:33:39 +01:00
Eric Seppanen 41163f9d25 add test for add_derives
This test derives PartialEq for the Test struct, and then attempts to
use that by calling assert_ne! on two Test instances. If the derive
callback doesn't work, no PartialEq will be present and the test will
fail to compile.
2021-07-16 21:23:05 +02:00
Adam Perry 7ca46f6f26 Integration test include directory paths for depfiles. 2021-04-24 00:51:44 +02:00
Marcel Hlopko 7a595a5429 Rename whitelist -> allowlist and blacklist -> blocklist
For the commandline arguments I added undocumented aliases to old flags,
to stay backwards compatible.
2021-02-18 17:25:13 +01:00
Emilio Cobos Álvarez 64b8d36338 codegen: Track union layout more accurately.
Instead of always generating the _bindgen_union_align method (which
shouldn't be needed at all for Rust structs, since the struct layout
tracker already deals with adding repr(align) as necessary) make sure to
visit all fields appropriately to generate the correct alignment.
2021-02-07 23:10:28 +01:00
Corey Farwell 74da49b507 Run tests on AArch64 2021-02-04 16:46:38 +01:00
Corey Farwell c6eb7c9d12 Add failing regression test for #1973. 2021-01-30 16:48:20 +01:00
Emilio Cobos Álvarez 259be1235f ci: Switch most CI to GitHub actions. 2020-12-26 19:01:53 +01:00
Emilio Cobos Álvarez cd27daf3be tests: Remove unnecessary system header include that makes macos unhappy 2020-12-26 19:01:53 +01:00
Emilio Cobos Álvarez 6f3a1187f1 integration: Forward some features to bindgen. 2020-12-26 19:01:53 +01:00
Emilio Cobos Álvarez bdf9b16d66 comp: Fix bitfields to allow underaligned fields after them to take padding space.
Fixes #1947.

There are two separate issues here: First, the change in comp.rs ensures
that we don't round up the amount of storage to the alignment of the
bitfield. That generates the "expected" output in #1947
(`__BindgenBitfieldUnit<[u8; 3], u16>`).

But that's still not enough to fix that test-case because
__BindgenBitfieldUnit would be aligned and have padding, and Rust won't
put the extra field in the padding.

In order to ensure the bitfield starts at the right alignment, but that
Rust can put stuff in the extra field, we need to make a breaking change
and split the generated fields in two: One preceding that guarantees
alignment, and the actual storage, bit-aligned.

This keeps the existing behavior while fixing that test-case.
2020-12-20 21:29:47 +01:00
Youmu 4656d34773 Add integration test for name matching 2020-09-15 00:18:51 +02:00
Darren Kulp 8b3f66138f Remove testing_only_libclang_3_8 and expectations 2020-07-20 18:55:10 +02:00
Darren Kulp 21b1159f48 Introduce tests for functional macros 2020-06-21 01:40:52 +02:00
Alan Egerton fae2f4731c Refined test to verify type of resulting integer 2020-06-15 21:53:48 +01:00
Alan Egerton c7d4707912 Added tests 2020-06-15 21:30:19 +01:00
Emilio Cobos Álvarez 3bf614824b bindgen-integration: Reformat crate too.
Cleanup a bit the reformatted bits while at it.
2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez 821cc7ef1a Add llvm 9.0 to CI. 2019-10-14 14:15:46 +02:00
Emilio Cobos Álvarez 8473e70ede integration: Fix integration tests with rust 1.33.
Alignment arrays are not needed anymore, since we have repr(align).
2019-03-04 03:54:18 +01:00
Emilio Cobos Álvarez 67b72182cc While at it, gcc -> cc in the integration tests. 2018-11-30 11:59:50 +01:00
Emilio Cobos Álvarez 98929bbd8c Rustfmt the bindgen-integration crate. 2018-11-30 06:22:37 +01:00
Emilio Cobos Álvarez b72575fdc5 Add a test for the interaction between blacklisting and parse callbacks. 2018-11-30 06:21:44 +01:00
chrysn bbaf6c6b6c Integration tests for str_macro callbacks 2018-11-26 16:00:22 +01:00
Sébastien Duquette 2f0aea26ce Add tests for renamed structure items 2018-11-10 20:32:29 -05:00
Sébastien Duquette 5820d34edb Add integration tests 2018-11-10 19:16:54 -05:00
Emilio Cobos Álvarez 349cfe86a4 ir: Don't assume wchar is 2 bytes.
Fixes #1345
2018-07-05 02:32:28 +02:00
Emilio Cobos Álvarez ee83df787f Add tests for the new option. 2018-05-03 04:52:24 +02:00
Emilio Cobos Álvarez 7c3e8aeda9 Now that we have stuff that depends on libclang-5 we need to do this. 2018-04-03 11:27:46 +02:00
bors-servo 1686d9f838 Auto merge of #1243 - emilio:parse-callbacks, r=fitzgen
callbacks: Introduce MacroParsingBehavior to allow ignoring macros.

This is symmetric, yet less powerful, than enum_variant_behavior.

Fixes #687.
2018-01-31 11:26:31 -06:00
Emilio Cobos Álvarez 8cf8aaff90 callbacks: Introduce MacroParsingBehavior to allow ignoring macros.
This is symmetric, yet less powerful, than enum_variant_behavior.

Fixes #687.
2018-01-31 00:00:57 +01:00
Emilio Cobos Álvarez 5eb46a96b1 ir: Choose the right mangling for destructors on all codepaths.
Fixes #1133.
2018-01-29 15:48:34 +01:00
Emilio Cobos Álvarez 604989c361 Don't generate symbols for pure virtual functions.
Fixes #1197.
2017-12-29 17:18:20 +01:00
Nick Fitzgerald c930acc14f Support bitfield allocation units larger than 64 bits
Individual bitfields are still limited to at most 64 bits, but this
restriction can be weakened when Rust supports u128.

This implements issue #816.

Usage notes:

* Since common code is added to each generated binding, a program which uses
  more than one binding may need to work around the duplication by including
  each binding in its own module.
* The values created by bitfield allocation unit constructors can be assigned
  directly to the corresponding struct fields with no need for transmutation.

Implementation notes:

__BindgenBitfieldUnit represents a bitfield allocation unit using a Storage
type accessible as a slice of u8. The alignment of the unit is inherited from
an Align type by virtue of the field:

align: [Align; 0],

The position of this field in the struct is irrelevant.

The alignment of the Storage type is intended to be no larger than the
alignment of the Align type, which will be true if the Storage type is, for
example, an array of u8.

Although the double underscore (__) prefix is reserved for implementations of
C++, there are precedents for this convention elsewhere in bindgen and so the
convention is adopted here too.

Acknowledgement:

Thanks to @fitzgen for an initial implementation of __BindgenBitfieldUnit and
code to integrate it into bindgen.
2017-11-21 13:55:00 +00:00
Glyn Normington 74e43dfadc Improve documentation of the integration tests
Also:
* disable rustfmt in the integration test, to avoid it causing problems, since
  it is not needed.
* note the need to rebuild bindgen when running a single test.
2017-11-16 16:55:22 +00:00
Sergey Pepyakin dad0c81e70 Handle explicit align=1. 2017-10-11 18:24:12 +03:00
Cldfire 3f922d96c5 Make bindgen generate enums as constants by default
Also simplifies the logic that determines which enum variation gets chosen.
2017-09-11 13:11:44 -04:00
bors-servo bf9d2bce48 Auto merge of #763 - rigelk:757-unstable-defaults, r=emilio,fitzgen
switch defaults from generating unstable Rust to generating stable Rust

As said in the issue:
- changing the Builder::no_unstable_rust method to the Builder::unstable_rust method
- changing the --no-unstable-rust flag to a --unstable-rust flag in src/options.rs
- changing bindgen-flags header in the test headers to remove the --no-unstable-rust flag
- removing --no-unstable-rust flag in ./test/test-one.sh

Fixes #757

r? @fitzgen
2017-06-19 15:45:08 -07:00
Pierre-Antoine Rault bafc48dc48 switch defaults from generating unstable Rust to generating stable Rust
- changing the Builder::no_unstable_rust method to the Builder::unstable_rust method
- changing the --no-unstable-rust flag to a --unstable-rust flag in src/options.rs
- changing bindgen-flags header in the test headers to remove the --no-unstable-rust flag

Fixes #757
2017-06-19 23:35:07 +02:00