authorgravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2023-03-17 15:09:26+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-17 15:54:09-04:00
log9f2aa3fbeec451021837ca6bca2baa47302f0468
tree0e12d0e9526606bb69f66a91bddd56d4cda39bba
parent2089b3f193beaef6debc5671ca6d1f6fc028db8d

Build.zig_exe: make it sentinel-aware

This is useful for tests that want to `execve` zig directly. The string is already null-terminated, so this will just expose it as such, removing an extra allocation from the test. Will be used in #14462

2 files changed, 4 insertions(+), 4 deletions(-)

lib/build_runner.zig+2-2
...@@ -1008,13 +1008,13 @@ fn usageAndErr(builder: *std.Build, already_ran_build: bool, out_stream: anytype...@@ -1008,13 +1008,13 @@ fn usageAndErr(builder: *std.Build, already_ran_build: bool, out_stream: anytype
1008 process.exit(1);1008 process.exit(1);
1009}1009}
10101010
1011fn nextArg(args: [][]const u8, idx: *usize) ?[]const u8 {1011fn nextArg(args: [][:0]const u8, idx: *usize) ?[:0]const u8 {
1012 if (idx.* >= args.len) return null;1012 if (idx.* >= args.len) return null;
1013 defer idx.* += 1;1013 defer idx.* += 1;
1014 return args[idx.*];1014 return args[idx.*];
1015}1015}
10161016
1017fn argsRest(args: [][]const u8, idx: usize) ?[][]const u8 {1017fn argsRest(args: [][:0]const u8, idx: usize) ?[][:0]const u8 {
1018 if (idx >= args.len) return null;1018 if (idx >= args.len) return null;
1019 return args[idx..];1019 return args[idx..];
1020}1020}
lib/std/Build.zig+2-2
...@@ -60,7 +60,7 @@ verbose_cimport: bool,...@@ -60,7 +60,7 @@ verbose_cimport: bool,
60verbose_llvm_cpu_features: bool,60verbose_llvm_cpu_features: bool,
61reference_trace: ?u32 = null,61reference_trace: ?u32 = null,
62invalid_user_input: bool,62invalid_user_input: bool,
63zig_exe: []const u8,63zig_exe: [:0]const u8,
64default_step: *Step,64default_step: *Step,
65env_map: *EnvMap,65env_map: *EnvMap,
66top_level_steps: std.StringArrayHashMapUnmanaged(*TopLevelStep),66top_level_steps: std.StringArrayHashMapUnmanaged(*TopLevelStep),
...@@ -184,7 +184,7 @@ pub const DirList = struct {...@@ -184,7 +184,7 @@ pub const DirList = struct {
184184
185pub fn create(185pub fn create(
186 allocator: Allocator,186 allocator: Allocator,
187 zig_exe: []const u8,187 zig_exe: [:0]const u8,
188 build_root: Cache.Directory,188 build_root: Cache.Directory,
189 cache_root: Cache.Directory,189 cache_root: Cache.Directory,
190 global_cache_root: Cache.Directory,190 global_cache_root: Cache.Directory,