-
Notifications
You must be signed in to change notification settings - Fork 409
Add developer guideline notes for C/C++ bindings generation #688
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
Add developer guideline notes for C/C++ bindings generation #688
Conversation
Codecov Report
@@ Coverage Diff @@
## main #688 +/- ##
===========================================
+ Coverage 78.40% 91.85% +13.44%
===========================================
Files 55 35 -20
Lines 27568 19911 -7657
===========================================
- Hits 21616 18290 -3326
+ Misses 5952 1621 -4331
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to add this!
CONTRIBUTING.md
Outdated
pull requests keep the bindings up to date (and, thus, pass the bindings_check CI run). If you | ||
wish to ensure your PR passes the bindings generation phase, you should run the `genbindings.sh` | ||
script in the top of the directory tree to generate, build, and test C bindings on your local | ||
system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to test C bindings is explained in lightning-c-bindings/README.md
, even if is the explanation is still experimental itself ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
genbindings.sh does test the bindings :)
77b35bb
to
83b18e7
Compare
Also fixed it so that we really dont require bindings to pass pre-merge/cargo test. Especially given ##649, we dont want to have to wait just for new bindings generation. |
83b18e7
to
29fe59b
Compare
29fe59b
to
450391c
Compare
It looks like honggfuzz upstream is broken. Lets see what they say rust-fuzz/honggfuzz-rs#44 |
honggfuzz got a new release and is working again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on genbindings.sh
doing the building and testing long-term? Will there be a C test suite as this gets more mature and stable or will that be covered by more of the other language bindings that build on top of this with their own testing?
you likely don't need to worry about them, and during their early experimental phase we are not | ||
requiring that pull requests keep the bindings up to date (and, thus, pass the bindings_check CI | ||
run). If you wish to ensure your PR passes the bindings generation phase, you should run the | ||
`genbindings.sh` script in the top of the directory tree to generate, build, and test C bindings on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a lot of the build process uses shell scripts. What does the supported build platform matrix look like? Is all the tooling mostly focused on mac/linux or are there Windows use cases?
In general, how much of the entire project (lightning/tokio/c-bindings/etc) should be buildable on Mac and Windows? Trying to wrap my head around the supported platform matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I don't think we have anyone working with/spending too much time on Windows, but if you're less interested in testing and only want a shared library build, just running cargo build
in c-lightning-bindings
should work. Eventually it probably makes sense to spend some time on Windows but it hasn't been a priority.
you likely don't need to worry about them, and during their early experimental phase we are not | ||
requiring that pull requests keep the bindings up to date (and, thus, pass the bindings_check CI | ||
run). If you wish to ensure your PR passes the bindings generation phase, you should run the | ||
`genbindings.sh` script in the top of the directory tree to generate, build, and test C bindings on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running genbindings.sh
generates a few files that aren't in the .gitignore. Is it worth adding them?
c-bindings-gen/target/
lightning-c-bindings/target/
Should this end up in target/ or .gitignore?
lightning-c-bindings/include/lightningpp.hpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target
should definitely be in .gitignore, but at a high level our goal here is to check in the C bindings that are generated so that users don't theoretically need to run the generation scripts (ie can just cd lightning-c-bindings && cargo test
). CI tests that the versions in git are the same as the ones that are auto-generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. That makes sense why lightningpp.hpp
is outside of target. Thanks for the background.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified the target files are now ignored in 74cd3c9. Thanks!
@@ -127,6 +120,8 @@ jobs: | |||
apt-get -y install cargo valgrind lld git g++ clang | |||
- name: Checkout source code | |||
uses: actions/checkout@v2 | |||
- name: Sanity test bindings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative could be to also run genbindings.sh
with the continue-on-error
keyword. That way we could still see the output if it gets out of sync, but it doesn't prevent the job from failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure what the value would be - if the bindings fall out of sync, genbindings.sh
isn't going to give you a lot of useful output that cargo check
isn't? I added it in part to short-circuit all the /stuff/ if things are stale anyway (because the intent would be one of the full-timers or regular contributors can go fix it later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understanding the lifecycle for the generated code makes this clearer. I guess you would have to pair genbindings.sh
with a git diff
or something to show that "hey it's out of sync" since cargo check
doesn't always identify mismatches, but that isn't really the goal so it seems fine as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build script a bit further doesn't does do some git diff
stuff (though noting that the bindings aren't fully deterministic in terms of ordering, so letting that fluctuate a bit), but cargo check
is a much quicker way to get that.
genbindings.sh
Outdated
@@ -48,21 +48,21 @@ fi | |||
# Finally, sanity-check the generated C and C++ bindings with demo apps: | |||
|
|||
# Naively run the C demo app: | |||
gcc -Wall -g -pthread demo.c ../target/debug/liblightning.a -ldl | |||
gcc -Wall -g -pthread demo.c target/debug/liblightning.a -ldl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about splitting out the names, and paths into variables? I don't expect this file to change all that much, but it deduplicates a lot of the path names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I mean happy to do whatever, not sure its gonna change much independently though.
450391c
to
22211f9
Compare
ACK 74cd3c9
|
Until we get the bindings generation process super stable, let the bindings get stale with respect to the main repo while still letting `cargo check` pass.
This should fix lightningdevkit#689.
74cd3c9
to
3fa0548
Compare
Squashed the one fixup commit. |
No description provided.