Skip to content

Conversation

bavshin-f5
Copy link
Member

Nginx has various configuration options that may affect the availability of functions, constants and structure fields. This is not something that can be detected at runtime, as an attempt to use a symbol unavailable in the bindings would result in compilation error.

This PR introduces translation of a limited subset of NGX_... macros to the Rust cfg flags, allowing conditional checks like #[cfg(ngx_feature = "debug")].

There's no publicly available code that uses these flags yet, but I already need the functionality for some WIP stuff.

@bavshin-f5 bavshin-f5 force-pushed the ngx-feature-checks branch 3 times, most recently from daf6dba to 3e57973 Compare November 15, 2024 05:45
Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

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

Looks good.

The example build script converts `DEP_NGINX_FEATURES`, `DEP_NGINX_OS`
and `DEP_NGINX_VERSION_NUMBER` received from `nginx-sys` to the `cfg`
values for conditional compilation.

See tests for usage examples.
The flags set in cargo config will be ignored if the `RUSTFLAGS` is set.
Document cargo metadata variables set by the build script.
@bavshin-f5 bavshin-f5 merged commit 85570e2 into nginx:master Nov 22, 2024
10 checks passed
@bavshin-f5 bavshin-f5 deleted the ngx-feature-checks branch November 22, 2024 06:08
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.

2 participants