Skip to content

feat(sys): import types from other -sys crates #173

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bavshin-f5
Copy link
Member

Currently, bindgen generates bindings for everything we include: OpenSSL, PCRE2, system headers. This approach has several drawbacks:

  • Lots of wasted code in bingings.rs.
  • The generated bindings are lacking compared to the corresponding crates where the owners have more time on fine tuning. It's a set of small but annoying things: integer constant types, missing inline functions, functional macros etc.
  • The types are not compatible: *mut nginx_sys::SSL_CTX is not the same type as *mut openssl_sys::SSL_CTX and requires unchecked pointer casts.

The code here attempts to solve this by blocklisting and replacing the external library types with types from libc, openssl-sys and pcre2-sys.

TODOs:

  • The list of libc types is platform- and feature-dependent. We must check the expand_definitions output to figure out what we can and should import.
  • pcre2 is too eager to attempt to build and link a static library from vendored code. Maybe we don't need that one.
  • Even more platform testing.

Bonus: since we're introducing a bindgen::callbacks::ParseCallbacks implementation, we can also start adjusting the types for NGX_OK/ERROR/etc... via ParseCallbacks::int_macro().

Fixes: #99

Leave only NGINX code and referenced types.
The change introduces an optional feature nginx-sys/openssl-sys that
replaces some generated types with corresponding imports from "libc".
The change introduces an optional feature nginx-sys/libc that replaces
some generated types with corresponding imports from "libc".
The change introduces an optional feature nginx-sys/pcre2-sys that
replaces some generated types with corresponding imports from
"pcre2-sys".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bindgen-generated types conflict with other -sys crates
1 participant