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
Allow packages to access build_options
#9623
Conversation
Imho this is a anti-pattern and The nicer solution here is to create a pub fn build(b: *Builder) !void {
const build_options = b.createBuildOptions();
build_options.add([]const u8, string, "This is a string");
const git_pkg = std.build.Pkg{
.name = "git",
.path = .{ .path = prefix_path ++ "src/git.zig" },
.dependencies = &[_]std.build.Pkg{
.{ .name = "build_options", .path = build_options.getSource() },
},
};
} With this, you can make as many |
I've mostly implemented the suggested change, however ive run into something im not 100% happy with. Status quo outputs build options to a file called I will push the changes soon for review. |
Just don't care. Output the build options into This allows you to have guaranteed non-conflicting build option files |
While this is an improvement in terms of flexibility, using the newer version of the API in the use case I needed this for has made the code much more messy. Is it actually worth the breaking change for everyone currently using build_options? whereas the initial commit in this PR would not impact anyone except the people already working around the issue that it fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it actually worth the breaking change for everyone currently using build_options?
Yes - the way I originally coded build_options
meant that at some point we would have to break things in a messy way like this. I apologize for that. But the sooner the better.
Although I have some requested changes, I'm really glad that you're making these long overdue changes. Thank you for taking the time to do this.
Side note-
using the newer version of the API in the use case I needed this for has made the code much more messy.
may I see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant, thank you!
I'm currently getting around this limitation by using an ugly hack
this will fix #5375