talvdav
December 16, 2024, 3:09pm
1
Hi all,
i never really used c and no next to nothing about project with more than a main.c file.
I tried to build the graphics tool kit tcl/tk and after a while i got errors that the “tkUuid.h” file is missing, there is however a tkUuid.h.in file.
When i tried to build wx widgets a came across the same issue.
My question is: how do you get the .h file from the .h.in file?
dimdin
December 16, 2024, 3:20pm
2
You can use addConfigHeader
to generate the .h
file from a .h.in
file.
In the resulting ConfigHeader
call the addValues
to configure the parameters.
Finally call addConfigHeader
.
Example usage:
const config_h = b.addConfigHeader(.{
.style = .blank,
.include_path = "config.h",
}, .{
.FFMPEG_CONFIGURATION = "",
.FFMPEG_LICENSE = "LGPL version 2.1 or later",
.CONFIG_THIS_YEAR = 2024,
.FFMPEG_DATADIR = "/dev/null",
.AVCONV_DATADIR = "/dev/null",
.CC_IDENT = "clang 17.0.4 (CLANG)",
.OS_NAME = .linux,
.EXTERN_PREFIX = switch (t.os.tag) {
.macos => "_",
else => "",
},
.BUILDSUF = "",
.SLIBSUF = t.os.tag.dynamicLibSuffix(),
.HAVE_MMX2 = have_x86_feat(t, .mmx),
.SWS_MAX_FILTER_SIZE = 256,
});
This file has been truncated. show original
4 Likes
Explanations of config header generation is in the Build System Tips and Tricks Doc on Ziggit as well!
1 Like
To expand upon this post:
.in
files usually represent files that contain placeholder values that should be modified by the build system depending on which build options the user specified. Different build systems use different syntaxes:
Autoconf uses #undef FOO
.
CMake uses #cmakedefine FOO
and @FOO@
.
Meson uses #mesondefine FOO
and @FOO@
(Zig does not yet support this syntax).
To determine which style
to specify, look at which build system the upstream project uses (or go by the syntax of the .in
file).
Note that this project linked by @dimdin uses the .blank
style, which just writes the names and values to a new file line by line instead of modifying an existing .in
file. For an example of the .autoconf
style, see
https://github.com/allyourcodebase/cpython/blob/3b579aeb401290e483bbe2c6e0d26f4679d2bf8a/build.zig#L33
and the corresponding .in
file
https://github.com/allyourcodebase/cpython/blob/3b579aeb401290e483bbe2c6e0d26f4679d2bf8a/pyconfig.h.in .
2 Likes