1039 Commits

Author SHA1 Message Date
Jonathan Schwender
25132a3690 Add --depfile option
Add an option to output a depfile for outside build-systems to learn
the source file dependencies of the bindings.
This can be used by 3rd party build system integrations to only rerun
bindgen when necessary.

Testing is done via CMake integration tests, since CMake
is a 3rd party buildsystem which supports depfiles.
2023-05-29 18:56:53 +02:00
Jonathan Schwender
cb42a00ab6 Improve cbindgen detection in tests
Since our MSRV is now Rust 1.54, we can rely on cargo setting `CARGO_BIN_EXE_cbindgen`
to the cbindgen path in integration tests.
This is more reliable than guessing the path, since cargo knows where it placed the bin.
2023-05-29 18:56:53 +02:00
Emilio Cobos Álvarez
ea6e886f7b ci: Try to fix github actions.
Fixes #836
2023-05-29 18:10:25 +02:00
Emilio Cobos Álvarez
2ac467796f
Update lockfile. 2023-05-29 17:31:51 +02:00
Emilio Cobos Álvarez
3680e4d539
Bump version. 2023-05-29 17:15:36 +02:00
Emilio Cobos Álvarez
f97e4c2945
Don't enforce a particular tempfile version for people depending on cbindgen via crates.io / git. 2023-05-29 17:13:09 +02:00
Emilio Cobos Álvarez
288073a7c1
Revert tempfile update to avoid tons of duplicate outdated deps. 2023-05-29 14:41:59 +02:00
Owen Phillips
44f8c4f722 Bump version. 2023-05-29 14:37:34 +02:00
Wei Zhang
52a65e5be3 docs: update version to 0.24.0
Signed-off-by: Wei Zhang <kweizh@gmail.com>
2023-03-29 22:24:27 +02:00
Jonathan Schwender
3770faef73 CI: Fix warnings in Github actions
Fixes the following warning:

> Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2, actions-rs/cargo@v1, actions-rs/toolchain@v1. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

Steps:
- upgrade checkout to v3
- Replace the actions-rs/cargo action, by simply calling cargo from the commandline.
  I don't see why one would want to involve a node.js action there in the first place.
- Replace the actions-rs/toolchain with dtolnays version, which uses the shell instead
  of node.js
2023-03-10 13:42:09 +01:00
Jonathan Schwender
36ebe9a4a6 CI: Install toolchain in one step
Instead of two steps installing the toolchain, do it one step.
Removes the unmaintained action-rs/toolchain action.
Installs stable clippy instead of nightly clippy.
2023-03-08 16:59:28 +01:00
Jonathan Schwender
09c386c98f Fix clippy: the following explicit lifetimes could be elided 2023-03-08 16:59:28 +01:00
Jonathan Schwender
06e28c41aa Fix clippy: stripping a prefix manually 2023-03-08 16:59:28 +01:00
Jonathan Schwender
ee2223fa13 Fix clippy: match expression looks like matches! macro 2023-03-08 16:59:28 +01:00
Jonathan Schwender
fb1fdc8aed Fix clippy warning (1.40 -> 1.54)
The clippy.toml suppresses warnings added in newer rust versions,
so fixing the documented MSRV also shows new warnings.
2023-03-08 16:59:28 +01:00
Jonathan Schwender
b566c3c064 Fix documented MSRV
The MSRV was updated to 1.54 in commit d4e508d.
Update the MSRV specified in the Readme badge and in the clippy.toml
to match the actual MSRV.
2023-03-08 16:59:28 +01:00
Alex Touchet
55e24c5090 Replace Travis CI references and update some formatting 2023-03-08 16:08:13 +01:00
Romain Malmain
b6e73017e6 Moved expand infinite recursion fix. 2022-11-14 12:08:08 +01:00
Ian Hobson
317412c5a9 Add with_cpp_compat to the builder 2022-11-10 14:25:55 +01:00
Emilio Cobos Álvarez
66bc17facf
Add a test for function pointer text wrapping. 2022-11-10 14:23:33 +01:00
Emilio Cobos Álvarez
d8660bb01f
Avoid doing double the work when measuring. 2022-11-10 14:23:33 +01:00
Emilio Cobos Álvarez
e0eaecfdf7
Fix clippy nits. 2022-11-10 14:23:33 +01:00
Thibaut Lorrain
5fd38d5417
Better line breaking in function pointer types
The current implementation never goes to a new line when writing a
function pointer type, this can lead to long, difficult to read lines.

The goal of this change is to make that a bit more sensible.

Here is a rust code example

```
   1   │ pub type MyCallback = Option<unsafe extern "C" fn(a: usize, b: usize)>;
   2   │
   3   │ pub type MyOtherCallback =
   4   │     Option<unsafe extern "C" fn(a: usize, lot: usize, of: usize, args: usize)>;
   5   │
   6   │ #[no_mangle]
   7   │ pub extern "C" fn my_function(a: MyCallback, b: MyOtherCallback) {}
```

right when generating the corresponing C header we get

```
   1   │ #include <stdarg.h>
   2   │ #include <stdbool.h>
   3   │ #include <stdint.h>
   4   │ #include <stdlib.h>
   5   │
   6   │ typedef void (*MyCallback)(uintptr_t a, uintptr_t b);
   7   │
   8   │ typedef void (*MyOtherCallback)(uintptr_t a, uintptr_t lot, uintptr_t of, uintptr_t args);
   9   │
  10   │ void my_function(MyCallback a, MyOtherCallback b);
```

line 8 here is already quite long and will be even longer if we add new
args to `MyOtherCallback`

With the changes in this commit, we now get

```
   1   │ #include <stdarg.h>
   2   │ #include <stdbool.h>
   3   │ #include <stdint.h>
   4   │ #include <stdlib.h>
   5   │
   6   │ typedef void (*MyCallback)(uintptr_t a, uintptr_t b);
   7   │
   8   │ typedef void (*MyOtherCallback)(uintptr_t a,
   9   │                                 uintptr_t lot,
  10   │                                 uintptr_t of,
  11   │                                 uintptr_t args);
  12   │
  13   │ void my_function(MyCallback a, MyOtherCallback b);
```

which is way better and more scalable if new args are atted to
`MyOtherCallback`

The behavior is configurable using the already existing `fn.args`
configuration parameter. In this case setting it to `Horizontal` gives
back the same .h as previously and setting it to `Vertical` makes the
generator go to a new line even for the shorter `MyCallback`
declaration:

```
   1   │ #include <stdarg.h>
   2   │ #include <stdbool.h>
   3   │ #include <stdint.h>
   4   │ #include <stdlib.h>
   5   │
   6   │ typedef void (*MyCallback)(uintptr_t a,
   7   │                            uintptr_t b);
   8   │
   9   │ typedef void (*MyOtherCallback)(uintptr_t a,
  10   │                                 uintptr_t lot,
  11   │                                 uintptr_t of,
  12   │                                 uintptr_t args);
  13   │
  14   │ void my_function(MyCallback a,
  15   │                  MyOtherCallback b);
```

Closes #793
2022-11-10 14:23:33 +01:00
novafacing
a2bda0a1de Correct wrong property in docs toml example 2022-10-17 19:31:19 +02:00
messense
cc8cced7e8 Add maturin to examples
190759e804/src/module_writer.rs (L461-L498)
2022-10-17 09:24:05 +02:00
Andrew Kane
a643506874 Add Homebrew instructions to readme [skip ci] 2022-10-11 00:32:43 +02:00
Emilio Cobos Álvarez
ae321d80ff Drive-by clippy fixes. 2022-08-30 15:47:58 +02:00
Emilio Cobos Álvarez
47b1d1de1e Handle never type in return position consistently.
Fixes #779
2022-08-30 15:47:58 +02:00
Emilio Cobos Álvarez
f43ccfc047
Bump version. 2022-06-09 22:35:48 +02:00
Emilio Cobos Álvarez
116a18c2fd tests: Add a test for struct constants going through typedefs. 2022-06-09 21:10:33 +02:00
Emilio Cobos Álvarez
fc981892ea bindings: Peel through typedefs for struct constant generation.
This allows the workaround in #767 to work.
2022-06-09 21:10:33 +02:00
Emilio Cobos Álvarez
4b30c56928
Rustfmt recent changes. 2022-06-07 21:38:56 +02:00
Emilio Cobos Álvarez
3d06ae1fc4
Version bump. 2022-06-07 21:34:55 +02:00
Emilio Cobos Álvarez
80da6045ec
bitflags: Be explicit in binary operators and such.
This allows having explicit + default constructor without build issues.
2022-06-07 21:32:28 +02:00
Emilio Cobos Álvarez
9855f90b65 Version bump. 2022-06-07 18:48:48 +02:00
Emilio Cobos Álvarez
5da3715187 constant: Add support for unary negation. 2022-06-07 18:48:48 +02:00
Emilio Cobos Álvarez
021d09db2b bitflags: Make more operations constexpr. 2022-06-07 18:48:48 +02:00
Emilio Cobos Álvarez
2e2c87e58a
Fix changelog typo. 2022-06-07 16:20:24 +02:00
Emilio Cobos Álvarez
b9a2209228 Version bump. 2022-06-07 16:19:40 +02:00
Emilio Cobos Álvarez
597b033ccf constant: Support suffixes for integers that otherwise would be narrowed. 2022-06-07 16:19:40 +02:00
Jason Orendorff
a79a10d9a6 Fix specialization of SomeType<N> when N is a const parameter.
Fixes #761.
2022-05-25 10:41:44 +02:00
Jason Orendorff
13b31ddcc2 Minor refactor of ConstExpr::load(). 2022-05-25 10:40:32 +02:00
Jason Orendorff
dde68cc439 Support char-like byte literals. 2022-05-25 10:40:32 +02:00
Jason Orendorff
caf69c8800 Support bool and char literals as arguments to const generics. 2022-05-25 10:40:32 +02:00
Jason Orendorff
eb5c979912 Rename ArrayLength to ConstExpr. 2022-05-25 10:40:32 +02:00
Jason Orendorff
c732069b2e New type GenericParam represents a generic parameter. 2022-05-09 16:13:39 +02:00
Jason Orendorff
13c0a4a2e8 New type GenericArguments represents actual arguments to generics. 2022-05-09 16:13:39 +02:00
Emilio Cobos Álvarez
798cfab52b v0.23.0 2022-04-21 18:48:00 +02:00
Emilio Cobos Álvarez
305ccfe746 constant: Make const.allow_constexpr default to true. 2022-04-21 18:48:00 +02:00
Emilio Cobos Álvarez
15e1131160 constant: Allow more constexpr constants. 2022-04-21 18:48:00 +02:00