aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-01-19 12:14:30 -0800
committerGitHub <noreply@github.com>2024-01-19 12:14:30 -0800
commitd7b6d637df5b94ec07cf017fa742e8c34a4b9433 (patch)
treeb4a589f9628d97f7dca0e3da389b4b5f77fa9545 /lib/std/Build.zig
parent3c16e8037261e2f19e4a4daf9c88453ec11281b3 (diff)
parent96e54e70175881573de2cd1a5e031e391e166f6a (diff)
downloadzig-d7b6d637df5b94ec07cf017fa742e8c34a4b9433.tar.gz
zig-d7b6d637df5b94ec07cf017fa742e8c34a4b9433.zip
Merge pull request #18615 from ziglang/langref
miscellaneous documentation changes
Diffstat (limited to 'lib/std/Build.zig')
-rw-r--r--lib/std/Build.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
index 91d047096d..59dee7d89d 100644
--- a/lib/std/Build.zig
+++ b/lib/std/Build.zig
@@ -599,6 +599,11 @@ pub fn resolveInstallPrefix(self: *Build, install_prefix: ?[]const u8, dir_list:
self.h_dir = self.pathJoin(&h_list);
}
+/// Create a set of key-value pairs that can be converted into a Zig source
+/// file and then inserted into a Zig compilation's module table for importing.
+/// In other words, this provides a way to expose build.zig values to Zig
+/// source code with `@import`.
+/// Related: `Module.addOptions`.
pub fn addOptions(self: *Build) *Step.Options {
return Step.Options.create(self);
}
@@ -1031,6 +1036,11 @@ fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror!
// TODO remove empty directories
}
+/// Creates a configuration option to be passed to the build.zig script.
+/// When a user directly runs `zig build`, they can set these options with `-D` arguments.
+/// When a project depends on a Zig package as a dependency, it programmatically sets
+/// these options when calling the dependency's build.zig script as a function.
+/// `null` is returned when an option is left to default.
pub fn option(self: *Build, comptime T: type, name_raw: []const u8, description_raw: []const u8) ?T {
const name = self.dupe(name_raw);
const description = self.dupe(description_raw);