authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2019-07-31 21:26:39-05:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2019-07-31 21:26:39-05:00
loge40513e97ff57960165b30a6b9fecfaad95bd1aa
treee2770c3ef21e5f2a57e964b09e836ff20b2c09a8
parentd6d0bb054219da26a55f880f48f00902a4fbaf56

Add builder.findProgram test and fix references


1 files changed, 13 insertions(+), 4 deletions(-)

std/build.zig+13-4
...@@ -805,7 +805,7 @@ pub const Builder = struct {...@@ -805,7 +805,7 @@ pub const Builder = struct {
805 return name;805 return name;
806 }806 }
807 const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });807 const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });
808 if (fs.path.real(self.allocator, full_path)) |real_path| {808 if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
809 return real_path;809 return real_path;
810 } else |_| {810 } else |_| {
811 continue;811 continue;
...@@ -817,10 +817,10 @@ pub const Builder = struct {...@@ -817,10 +817,10 @@ pub const Builder = struct {
817 if (fs.path.isAbsolute(name)) {817 if (fs.path.isAbsolute(name)) {
818 return name;818 return name;
819 }819 }
820 var it = mem.tokenize(PATH, []u8{fs.path.delimiter});820 var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
821 while (it.next()) |path| {821 while (it.next()) |path| {
822 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });822 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
823 if (fs.path.real(self.allocator, full_path)) |real_path| {823 if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
824 return real_path;824 return real_path;
825 } else |_| {825 } else |_| {
826 continue;826 continue;
...@@ -834,7 +834,7 @@ pub const Builder = struct {...@@ -834,7 +834,7 @@ pub const Builder = struct {
834 }834 }
835 for (paths) |path| {835 for (paths) |path| {
836 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });836 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
837 if (fs.path.real(self.allocator, full_path)) |real_path| {837 if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
838 return real_path;838 return real_path;
839 } else |_| {839 } else |_| {
840 continue;840 continue;
...@@ -904,6 +904,15 @@ pub const Builder = struct {...@@ -904,6 +904,15 @@ pub const Builder = struct {
904 }904 }
905};905};
906906
907test "builder.findProgram compiles" {
908 //allocator: *Allocator,
909 //zig_exe: []const u8,
910 //build_root: []const u8,
911 //cache_root: []const u8,
912 const builder = try Builder.create(std.heap.direct_allocator, "zig", "zig-cache", "zig-cache");
913 _ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null;
914}
915
907pub const Version = struct {916pub const Version = struct {
908 major: u32,917 major: u32,
909 minor: u32,918 minor: u32,