Commit Graph

1060 Commits

Author SHA1 Message Date
Jonathan Schwender aeea9c67ff Fix swapping of >>= and <<= in constants
This should't change behavior in practice since using these in constants
doesn't seem possible.

Closes #850
2023-08-25 10:55:53 -04:00
Jonathan Schwender dd9a550152 Fix minimal Rust version in CI
The minimum rust version was bumped, so we need
to install the appropriate version in CI.
2023-08-25 16:47:30 +02:00
Jonathan Schwender 0529d215e7 Revert "Upgrade clap 3 to clap 4"
This reverts commit b734008c71.
2023-08-25 16:47:30 +02:00
Jonathan Schwender 289a31ba45 Fix clippy warning
Rust 1.72 added a new warning, which should have been ignored
by clippy, since clippy.toml is still st to 1.57.0
2023-08-25 16:47:30 +02:00
Jonathan Schwender 67fea1a1a2 Fix CI
Commit 667de09279
broke CI by adding rust-toolchain.toml, which changed
the default rust version to nightly.
Explicitly specify the rust version in CI to use the correct
toolchain.
2023-08-25 16:47:30 +02:00
Jonathan Schwender 80526e72f9 Update changelog for v0.25.0 2023-08-25 15:50:52 +02:00
Jonathan Schwender 1e2ffd4414 CI: Replace forbidden actions with cli code
the semver checks action and the release action are not
in the allow-list so replace them with their respective
cli counterparts.
These changes can only be tested by someone with permissions,
so the release part only releases a draft release for now.
2023-08-25 15:50:52 +02:00
Jonathan Schwender f61946b979 CI: Add semver checks to CI deploy job
This will fail creating a new github release, if the semver
action fails.
This would have caught #841.
2023-08-25 15:50:52 +02:00
boxdot b61aa2c330 msrv 1.64 2023-08-25 15:50:04 +02:00
boxdot b734008c71 Upgrade clap 3 to clap 4
This also removes the dependency on the unmaintained crate atty.

Closes #828
2023-08-25 15:50:04 +02:00
sevenc-nanashi 667de09279 Add: Add rust-toolchain.toml 2023-08-25 15:49:03 +02:00
sevenc-nanashi 1b7aab6a87 Add: Cython 3 fails test 2023-08-25 15:49:03 +02:00
sevenc-nanashi 85bed13893 Change: this project requires proc-macro2 1.0.60+ 2023-08-25 15:49:03 +02:00
Emilio Cobos Álvarez 0b43f0bc6c ci: Switch back to dtolnay/rust-toolchain action. 2023-06-07 17:39:59 +02:00
Emilio Cobos Álvarez e9e88b0ab0 Yank last version and bump for now (unpublished) 2023-06-01 10:23:21 +02:00
Jonathan Schwender cbd3541614 Bump version 2023-05-31 12:32:35 +02:00
Jonathan Schwender 927ecd95bf Update documented MSRV 2023-05-31 12:32:35 +02:00
Jonathan Schwender 166bcf307a Update Changelog 2023-05-31 12:32:35 +02:00
Ian Hobson 6165bbf021 Avoid 'duplicate package' warnings when depending on cbindgen via git
When specifying `cbindgen` as a dependency via git, several 'skipping duplicate
package' warnings pop up regarding some of the test crates.

The warning seems to be spurious given that the test packages aren't needed when
depending on `cbindgen` (see https://github.com/rust-lang/cargo/issues/10752),
but while a fix is being considered for Cargo, this commit disambiguates the
duplicated package names by referring to their relative paths.
2023-05-31 12:31:39 +02:00
Sjors Holtrop c8546ad42d Parse ... as a VaList 2023-05-29 21:33:25 +02:00
Jonathan Schwender 5778380ba1 Look for config files next to input files
Previously config files next to an explicit input file
could not be picked up, since the `from_root_or_default`
functions assumes the input path is a directory.
This is the case for all other usages of the function, but
in this case we know the input is a file, so we determine
the parent directory and look for the config file in that
directory. There can't be a folder with the same name
as the input file, so it's not possible that we won't
pick up any files anymore that we previously did.
2023-05-29 19:55:46 +02:00
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
https://github.com/PyO3/maturin/blob/190759e804e4d10ff7e2e747c8bd76c17d6ee812/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