Commit 3803776
committed
Rework how bindings are generated
It has been a few years since I have touched the xed-sys crate and
advancements to the rust ecosystem have made some of the hacks we used
to need obsolete. This commit reworks how and when bindings are
generated.
The new approach has two main advantages:
- With no extra features enabled the build script doesn't even have to
run bindgen at all. It can just use the bundled bindings directly.
- We no longer have to maintain a separate c2rust translation of a
subset of the functions exposed by XED. A new experimental feature in
bindgen can now do this (mostly) automatically.
I have also thrown in the enc2 feature that is in the process of being
introduced by #65. We do end up needing bindgen when the enc2 feature is
enabled as the generated bindings would be too large to submit to
crates.io. (They are >40MB!).
With that said, here's how things work now:
1. Bindings for the default featureset are generated in advance by
running `./generate.sh`. XED's headers don't contain any
platform-dependent code so this should remain portable to any
platforms where XED is supported.
2. When the bindgen feature is enabled we ignore the bindings from step
1 and instead generate them in build.rs.
With the new experimental --wrap-static-fns bindgen option we can drop
the janky c2rust step that translates versions of these functions to
rust so that they can be included. Instead bindgen generates an
additional C file that declares a set of new functions that forward to
the static functions, the generated bindings refer to these forwarding
functions instead of the original ones.1 parent 46ca346 commit 3803776
File tree
15 files changed
+25963
-2847
lines changed- build-tools
- src/bin
- src
- tests
15 files changed
+25963
-2847
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
20 | | - | |
| 34 | + | |
| 35 | + | |
21 | 36 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments