Zig Version
0.15.2
Observed Behavior
There seems to be no way for the Zig build system to output the -include flag when compiling C files using std.Build.Module.
I am trying to port libvarlink to the Zig build system, but here it uses -include to include a generated config.h. std.Build.addConfigHeader() works fine for the first step, but std.Build.Module.addConfigHeader() results in a -I flag being emitted.
grep -R -- -include ./lib/std/Build/ shows no hits, while grep -R -- -I ./lib/std/Build/ shows the location where the IncludeDir from addConfigHeader() gets turned into a flag.
A snippet of what I am trying to do:
constconf=b.addConfigHeader(.{},.{._GNU_SOURCE=true,._XOPEN_SOURCE=700,.__SANE_USERSPACE_TYPES__=true,.VERSION=24,// TODO HACK});constlibvarlink=b.addLibrary(.{.name="varlink",.linkage=.static,.root_module=b.createModule(.{.target=target,.optimize=optimize,.link_libc=true,}),});libvarlink.root_module.addIncludePath(path_lib);libvarlink.root_module.addConfigHeader(conf);// <----- herelibvarlink.root_module.addIncludePath(org_varlink_service_varlink_c_inc.dirname());libvarlink.root_module.addCSourceFiles(.{.root=path_lib,.files=&libvarlink_sources,.flags=&c_args,});
This results in a commandline which looks like this:
/usr/bin/zig build-lib $cflags -- $sources -ODebug \
-I /path/to/libvarlink/lib \
-I .zig-cache/o/91dc822b657a41870790e8117c96fa43 \ # <----- here
-I .zig-cache/o/edca5716a462cf2f4c3412a050dc3b01 \
-Mroot -lc --cache-dir .zig-cache --global-cache-dir /path/to/.cache/zig --name varlink -static --zig-lib-dir /usr/lib/zig/ --listen=-
Question
Is this intended? It seems like zig build-lib does not support -include (throwing an error message).
### Zig Version
0.15.2
### Observed Behavior
There seems to be no way for the Zig build system to output the [`-include`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-include-file) flag when compiling C files using `std.Build.Module`.
I am trying to port [libvarlink](https://github.com/varlink/libvarlink) to the Zig build system, but [here](https://github.com/varlink/libvarlink/blob/4015824f4a408906e4be27d01008b399c0c1e9ec/meson.build#L63) it uses `-include` to include a generated `config.h`. `std.Build.addConfigHeader()` works fine for the first step, but `std.Build.Module.addConfigHeader()` results in a `-I` flag being emitted.
`grep -R -- -include ./lib/std/Build/` shows no hits, while `grep -R -- -I ./lib/std/Build/` shows the location where the `IncludeDir` from `addConfigHeader()` gets turned into a flag.
A snippet of what I am trying to do:
```zig
const conf = b.addConfigHeader(.{}, .{
._GNU_SOURCE = true,
._XOPEN_SOURCE = 700,
.__SANE_USERSPACE_TYPES__ = true,
.VERSION = 24, // TODO HACK
});
const libvarlink = b.addLibrary(.{
.name = "varlink",
.linkage = .static,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
}),
});
libvarlink.root_module.addIncludePath(path_lib);
libvarlink.root_module.addConfigHeader(conf); // <----- here
libvarlink.root_module.addIncludePath(org_varlink_service_varlink_c_inc.dirname());
libvarlink.root_module.addCSourceFiles(.{
.root = path_lib,
.files = &libvarlink_sources,
.flags = &c_args,
});
```
This results in a commandline which looks like this:
```sh
/usr/bin/zig build-lib $cflags -- $sources -ODebug \
-I /path/to/libvarlink/lib \
-I .zig-cache/o/91dc822b657a41870790e8117c96fa43 \ # <----- here
-I .zig-cache/o/edca5716a462cf2f4c3412a050dc3b01 \
-Mroot -lc --cache-dir .zig-cache --global-cache-dir /path/to/.cache/zig --name varlink -static --zig-lib-dir /usr/lib/zig/ --listen=-
```
### Question
Is this intended? It seems like `zig build-lib` does not support `-include` (throwing an error message).