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

(Maybe?) port binding generator to Rust libclang #127

Closed
tgolsson opened this issue Mar 4, 2021 · 5 comments
Closed

(Maybe?) port binding generator to Rust libclang #127

tgolsson opened this issue Mar 4, 2021 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@tgolsson
Copy link
Member

tgolsson commented Mar 4, 2021

The current binding generator in C++ is hard to compile and use, which increases friction if we want to upgrade PhysX version of expose more functionality.

I tried using the approximately equivalent Python libclang bindings to regenerate a 1:1 match of the current output but found that some info was missing around inheritance and fields, which would've lead to a complete breakage of physx-sys, which would be a hard sell.

We should investigate whether the Rust libclangd can be used to generate a more similar version of the bindings and struct-tests.

@tgolsson tgolsson added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers question Further information is requested labels Mar 4, 2021
@Hentropy
Copy link
Contributor

Hentropy commented Apr 7, 2021

Has bindgen been looked at? It can generate C++ bindings with the major restrictions being around templates.

@tgolsson
Copy link
Member Author

tgolsson commented Apr 7, 2021

Ping @h3r2tic, who wrote the current impl. Did you investigate that?

@h3r2tic
Copy link
Contributor

h3r2tic commented Apr 7, 2021

Yup! It was the first thing I tried, and at least back then bindgen gave up on most of PhysX. I don't think it had any way of handling ABI differences between platforms either.

@Hentropy
Copy link
Contributor

Hentropy commented Apr 7, 2021

Digging into bindgen for C++ a bit more, this issue pops out because physx-sys had an issue like that, as well as an issue similar to what @tgolsson encountered with fields. This PR proposes changing bindgen from libclang to libtooling to resolve those issues because the latter exposes the information necessary to generate bindings appropriately, but it appears to have stalled. One of the issues raised on that PR was build difficulties, like the ones raised in this issue. The issues @h3r2tic mentioned are fixable via a pretty hefty bindings.h but that may be preferable to duplicating translation code.

Another option is generating a cxx::bridge, perhaps using bindgen since cxx has at least some support for that. However, cxx is still somewhat immature so I'm not sure how viable it is for something as beefy as PhysX.

@Jake-Shadle
Copy link
Member

#183 transitioned pxbind to a Rust project that just clang's AST JSON output, much easier and no requirements on big clunky libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants