-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Currently it is not possible for an upstream package foo to add C header include paths to a Module it has defined — it's only possible to do this on CompileSteps. The effect of this is that if the package defines a module using @cImport(), a depending project bar that uses this module will fail to build because the headers aren't in its search path.
For now, the workaround in the dependee's build.zig is to call exe.addIncludePath(X) where X is the path to the globally cached package, e.g. ~/.cache/zig/p/hash-of-package/include.
It should be possible for bar to depend on foo without adding this include path. If bar does not call @cImport() directly itself, it should also not have to call exe.addIncludePath at all.
The suggested approach in today's meeting was to expand the API of Module to have (some of? *) the same APIs as CompileStep. This would allow the upstream foo to call mod.installHeadersDirectory() in build.zig, and then bar can use the foo module and find its headers.
*Note: I'm not sure which APIs should be copied from CompileStep. All of them? Just ones related to installing headers?