Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove serde_derive dependency, inlining expanded impls into source code #222

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 77 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ travis-ci = { repository = "eqrion/cbindgen" }
[dependencies]
clap = "2"
log = "0.4"
serde = {version = "1.0", features = ["derive"]}
# See issue #203 and README.serde_derive
# serde = {version = "1.0", features = ["derive"]}
serde = {version = "1.0"}
serde_json = "1.0"
tempfile = "3.0"
toml = "0.4"

# Workaround for #203 -- use a version that depends on different syn, quote, and
# proc-macro2 than we do, so their use of proc-macro doesn't infect our binary.
[dependencies.serde_derive]
version = "=1.0.58"

[dependencies.syn]
version = "0.14.0"
default-features = false
Expand All @@ -40,3 +37,7 @@ doc = false
[lib]
name = "cbindgen"
path = "src/lib.rs"

# See issue #203 and README.serde_derive
[features]
serde_derive = []
25 changes: 25 additions & 0 deletions README.serde_derive
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
See issue #203 for background on why this exists.

To update the `impl`s for (1) changes to data structures or (2) updates to `serde` you'll need to do this manual process.

1. Uncomment the `serde` dependency with `features = ["derive"]`
2. Comment out the `serde` dependency without `features = ["derive"]`
3. Run `cbindgen` through `cargo expand`

```bash
cargo +nightly rustc --lib --features serde_derive -p cbindgen -- -Z unstable-options --pretty=expanded > expanded.rs
```

Note the `--features serde_derive`. This activates `#[serde]` configuration attributes so that `serde_derive` generates correct impls. These attributes cannot be left enabled by default as the rust compiler will complain.

4. Open `expanded.rs`
5. Find the appropriate `impl`s and copy and paste them into the appropriate `mod`s.
1. Keep the `impl`s in source file order
2. Unindent the `impl`s to be aligned properly
6. Update the comments with the version of `serde_derive` used to generate the `impl`s
1. You can find this in `Cargo.lock`
7. Revert the changes to `Cargo.toml`
8. Delete `expanded.rs`
9. Test your changes

This is very unfortunate, but it's better than keeping a stale dependency on `serde_derive`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I disagree with this FWIW.

627 changes: 625 additions & 2 deletions src/bindgen/cargo/cargo_lock.rs

Large diffs are not rendered by default.

2,110 changes: 2,105 additions & 5 deletions src/bindgen/cargo/cargo_metadata.rs

Large diffs are not rendered by default.

429 changes: 427 additions & 2 deletions src/bindgen/cargo/cargo_toml.rs

Large diffs are not rendered by default.

Loading