Add CompileStep APIs to Build.Module.
Closes #14719. Adding these APIs to Build.Module allows for needed include paths and libraries to be declared at the module's creation site (in the dependency) rather than in the dependee's code.
var mod = b.addModule(.{
.name = "mymodule",
.source_file = "...",
});
mod.addIncludePath(include_dir);
I'm not sure of the full set of CompileStep functions that need to be ported to Build.Module, but I made a start on the most obvious ones.
Functions added to Build.Module so far:
-
addIncludePath -
addConfigHeader -
addLibraryPath -
linkLibC -
linkLibCpp -
linkLibrary -
linkSystemLibrary -
linkSystemLibraryNeeded -
linkSystemLibraryWeak -
linkSystemLibraryName -
linkSystemLibraryNeededName -
linkSystemLibraryWeakName -
installHeader -
installConfigHeader -
installHeadersDirectory -
installHeadersDirectoryOptions -
installLibraryHeaders -
linkFramework -
linkFrameworkNeeded -
linkFrameworkWeak -
addSystemIncludePath -
addRPath -
addFrameworkPath -
linkSystemLibraryPkgConfigOnly -
linkSystemLibraryNeededPkgConfigOnly
Great, looking forward to having this! Thanks for having addModule() return the module as well.
From the compiler meeting this week, it sounds like Module should have installHeader() and friends too.
Is this ready for review?
Is this ready for review?
Yes, I think so. Soliciting some more reviews was on my to-do list for this evening. Thanks for the reminder
Since the issues are so similar, I've also added an addOptions function to Module, which closes #14979.
I will take this from here - thank you
Sounds good. I've been on work travel for most of the past few weeks, so I haven't had a chance to resolve conflicts. I'm back now, so just let me know if there's anything else I can do on this. Otherwise I'll leave it to you.
Hi! Andrew's comments here tie into some changes I was planning on doing to the CLI, where you pass a main module instead of a main file - I was actually waiting on a few changes, this PR included, just to avoid potential nasty merges.
@andrewrk, what're the chances of intern-pool-2 being looked at soon? One of the genuinely very confusing things when working on said CLI rework was the current overloading of the term "module" in the compiler source, since it turned into a semi-major rework of module lifetimes; so if it's possible to get on with renaming Module any time soon that would be fantastic. But if that'll still be a wait, I can push ahead with the CLI changes anyway and just hope I don't go insane :p
#16172 might be fixed by this?