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

std.Build.Step.ConfigHeader: Add support for Autoconf-style @FOO@ variables #22794

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cbilz
Copy link
Contributor

@cbilz cbilz commented Feb 6, 2025

Autoconf configuration header templates often use #undef directives as substitution hooks, which we already support via ConfigHeader.Style.autoconf. However, many projects, particularly those using Gnulib, additionally rely on @FOO@-style output variables for header configuration. While some of these cases can be handled using Style.cmake, this fails when the template happens to contain strings like ${FOO}.

For example, the Gnulib header template lib/unistd.in.h uses @FOO@-style substitutions, but also happens to contain the string ${LOGNAME-$USER} in a code comment. This is misinterpreted as a substitution hook by Style.cmake. Attempting to work around this by adding a value like .{ @."LOGNAME-$USER" = ... } to ConfigHeader fails because Style.cmake rejects the invalid $ character in the variable name.

To resolve this issue, this pull request adds a new Style.autoconf_at specifically for @FOO@-style substitutions as used by Autoconf. Additionally, Style.autoconf is renamed to Style.autoconf_undef for clarity. The new Style.autoconf_at is similar to Style.cmake, but does not perform ${} or #cmakedefine substitutions, enabling the correct configuration of headers like the one described above.

cbilz added 2 commits February 6, 2025 17:04
Add the new style `Style.autoconf_at`. Rename the existing
`Style.autoconf` (which uses `#undef` directives) to
`Style.autoconf_undef`.
cbilz added a commit to cbilz/gnu-m4-zig that referenced this pull request Feb 9, 2025
There were a few configuration value conflicts between `config.h` and
the Gnulib headers, so it made sense to draw their values from different
pools.

The Gnulib headers use `@FOO@`-style substitution hooks. So far, we used
`ConfigHeader.Style.cmake` to configure these, but this fails for
`unistd.h`, see ziglang/zig#22794.

Further, we add a function that allows build-time configuration of
`ConfigHeader` values, see ziglang/zig#22795.
This is more convenient and should improve overall build times as
comptime is still relatively slow.

We use a modified version of `ConfigHeader` until these pull requests
are merged.
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.

1 participant