-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
std.Build.Step.ConfigHeader: Add support for Autoconf-style @FOO@ variables
#22794
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
Conversation
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.
Add the new style `Style.autoconf_at`. Rename the existing `Style.autoconf` (which uses `#undef` directives) to `Style.autoconf_undef`.
|
Thanks for the patch. Can you explain why it's a new style and not an enhancement of the already existing autoconf style? |
The user should have control over whether to expand If Example 1A header that uses Example 2A header that uses // Please contact john@email.com or doe@email.com.
Alternative interfaceAn alternative to adding separate pub const Style = union(enum) {
autoconf: struct {
file: std.Build.LazyPath,
mode: enum { at, undef },
},
//...
};Perhaps Let me know if I this looks better, and I can change it. |
|
Understood thank you. I did not know autoconf itself had two different styles to choose from. In this case, happy to accept your original patchset. |
|
FYI e47f340 |
Enabled by the merging of ziglang/zig#22794 and ziglang/zig#22795
Enabled by the merging of ziglang/zig#22794 and ziglang/zig#22795
Autoconf configuration header templates often use
#undefdirectives as substitution hooks, which we already support viaConfigHeader.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 usingStyle.cmake, this fails when the template happens to contain strings like${FOO}.For example, the Gnulib header template
lib/unistd.in.huses@FOO@-style substitutions, but also happens to contain the string${LOGNAME-$USER}in a code comment. This is misinterpreted as a substitution hook byStyle.cmake. Attempting to work around this by adding a value like.{ @."LOGNAME-$USER" = ... }toConfigHeaderfails becauseStyle.cmakerejects the invalid$character in the variable name.To resolve this issue, this pull request adds a new
Style.autoconf_atspecifically for@FOO@-style substitutions as used by Autoconf. Additionally,Style.autoconfis renamed toStyle.autoconf_undeffor clarity. The newStyle.autoconf_atis similar toStyle.cmake, but does not perform${}or#cmakedefinesubstitutions, enabling the correct configuration of headers like the one described above.