| ... | @@ -599,6 +599,11 @@ pub fn resolveInstallPrefix(self: *Build, install_prefix: ?[]const u8, dir_list: | ... | @@ -599,6 +599,11 @@ pub fn resolveInstallPrefix(self: *Build, install_prefix: ?[]const u8, dir_list: |
| 599 | self.h_dir = self.pathJoin(&h_list); | 599 | self.h_dir = self.pathJoin(&h_list); |
| 600 | } | 600 | } |
| 601 | | 601 | |
| | 602 | /// Create a set of key-value pairs that can be converted into a Zig source |
| | 603 | /// file and then inserted into a Zig compilation's module table for importing. |
| | 604 | /// In other words, this provides a way to expose build.zig values to Zig |
| | 605 | /// source code with `@import`. |
| | 606 | /// Related: `Module.addOptions`. |
| 602 | pub fn addOptions(self: *Build) *Step.Options { | 607 | pub fn addOptions(self: *Build) *Step.Options { |
| 603 | return Step.Options.create(self); | 608 | return Step.Options.create(self); |
| 604 | } | 609 | } |
| ... | @@ -1031,6 +1036,11 @@ fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror! | ... | @@ -1031,6 +1036,11 @@ fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror! |
| 1031 | // TODO remove empty directories | 1036 | // TODO remove empty directories |
| 1032 | } | 1037 | } |
| 1033 | | 1038 | |
| | 1039 | /// Creates a configuration option to be passed to the build.zig script. |
| | 1040 | /// When a user directly runs `zig build`, they can set these options with `-D` arguments. |
| | 1041 | /// When a project depends on a Zig package as a dependency, it programmatically sets |
| | 1042 | /// these options when calling the dependency's build.zig script as a function. |
| | 1043 | /// `null` is returned when an option is left to default. |
| 1034 | pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_raw: []const u8) ?T { | 1044 | pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_raw: []const u8) ?T { |
| 1035 | const name = self.dupe(name_raw); | 1045 | const name = self.dupe(name_raw); |
| 1036 | const description = self.dupe(description_raw); | 1046 | const description = self.dupe(description_raw); |