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 {
805805 return name;
806806 }
807807 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| {
809809 return real_path;
810810 } else |_| {
811811 continue;
......@@ -817,10 +817,10 @@ pub const Builder = struct {
817817 if (fs.path.isAbsolute(name)) {
818818 return name;
819819 }
820 var it = mem.tokenize(PATH, []u8{fs.path.delimiter});
820 var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
821821 while (it.next()) |path| {
822822 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| {
824824 return real_path;
825825 } else |_| {
826826 continue;
......@@ -834,7 +834,7 @@ pub const Builder = struct {
834834 }
835835 for (paths) |path| {
836836 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| {
838838 return real_path;
839839 } else |_| {
840840 continue;
......@@ -904,6 +904,15 @@ pub const Builder = struct {
904904 }
905905};
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
907916pub const Version = struct {
908917 major: u32,
909918 minor: u32,