diff options
| author | Benjamin Feng <benjamin.feng@glassdoor.com> | 2019-07-31 21:26:39 -0500 |
|---|---|---|
| committer | Benjamin Feng <benjamin.feng@glassdoor.com> | 2019-07-31 21:26:39 -0500 |
| commit | e40513e97ff57960165b30a6b9fecfaad95bd1aa (patch) | |
| tree | e2770c3ef21e5f2a57e964b09e836ff20b2c09a8 /std/build.zig | |
| parent | d6d0bb054219da26a55f880f48f00902a4fbaf56 (diff) | |
| download | zig-e40513e97ff57960165b30a6b9fecfaad95bd1aa.tar.gz zig-e40513e97ff57960165b30a6b9fecfaad95bd1aa.zip | |
Add builder.findProgram test and fix references
Diffstat (limited to 'std/build.zig')
| -rw-r--r-- | std/build.zig | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/std/build.zig b/std/build.zig index 3a0c34c8d1..acd3a1e33b 100644 --- a/std/build.zig +++ b/std/build.zig @@ -805,7 +805,7 @@ pub const Builder = struct { return name; } const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) }); - if (fs.path.real(self.allocator, full_path)) |real_path| { + if (fs.realpathAlloc(self.allocator, full_path)) |real_path| { return real_path; } else |_| { continue; @@ -817,10 +817,10 @@ pub const Builder = struct { if (fs.path.isAbsolute(name)) { return name; } - var it = mem.tokenize(PATH, []u8{fs.path.delimiter}); + var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter}); while (it.next()) |path| { const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); - if (fs.path.real(self.allocator, full_path)) |real_path| { + if (fs.realpathAlloc(self.allocator, full_path)) |real_path| { return real_path; } else |_| { continue; @@ -834,7 +834,7 @@ pub const Builder = struct { } for (paths) |path| { const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); - if (fs.path.real(self.allocator, full_path)) |real_path| { + if (fs.realpathAlloc(self.allocator, full_path)) |real_path| { return real_path; } else |_| { continue; @@ -904,6 +904,15 @@ pub const Builder = struct { } }; +test "builder.findProgram compiles" { + //allocator: *Allocator, + //zig_exe: []const u8, + //build_root: []const u8, + //cache_root: []const u8, + const builder = try Builder.create(std.heap.direct_allocator, "zig", "zig-cache", "zig-cache"); + _ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null; +} + pub const Version = struct { major: u32, minor: u32, |
