authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-02 15:49:16-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-08-02 15:49:16-07:00
log1823a5979ad444a59a05dfa381d1dc88348cbd74
treeeb1ddb255813c8fc18f57aba2ee797c983802b48
parentb2d94f9af2968e01bd3d8db38c9ae1992bbd3678
parent723aea8369375d17d19bc1e6d02dbf6eb4d9ba49
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2985 from fengb/fix-build-references

Fix build references

1 files changed, 16 insertions(+), 16 deletions(-)

std/build.zig+16-16
...@@ -805,11 +805,7 @@ pub const Builder = struct {...@@ -805,11 +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 return fs.realpathAlloc(self.allocator, full_path) catch continue;
809 return real_path;
810 } else |_| {
811 continue;
812 }
813 }809 }
814 }810 }
815 if (self.env_map.get("PATH")) |PATH| {811 if (self.env_map.get("PATH")) |PATH| {
...@@ -817,14 +813,10 @@ pub const Builder = struct {...@@ -817,14 +813,10 @@ pub const Builder = struct {
817 if (fs.path.isAbsolute(name)) {813 if (fs.path.isAbsolute(name)) {
818 return name;814 return name;
819 }815 }
820 var it = mem.tokenize(PATH, []u8{fs.path.delimiter});816 var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
821 while (it.next()) |path| {817 while (it.next()) |path| {
822 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });818 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| {819 return fs.realpathAlloc(self.allocator, full_path) catch continue;
824 return real_path;
825 } else |_| {
826 continue;
827 }
828 }820 }
829 }821 }
830 }822 }
...@@ -834,11 +826,7 @@ pub const Builder = struct {...@@ -834,11 +826,7 @@ pub const Builder = struct {
834 }826 }
835 for (paths) |path| {827 for (paths) |path| {
836 const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });828 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| {829 return fs.realpathAlloc(self.allocator, full_path) catch continue;
838 return real_path;
839 } else |_| {
840 continue;
841 }
842 }830 }
843 }831 }
844 return error.FileNotFound;832 return error.FileNotFound;
...@@ -904,6 +892,15 @@ pub const Builder = struct {...@@ -904,6 +892,15 @@ pub const Builder = struct {
904 }892 }
905};893};
906894
895test "builder.findProgram compiles" {
896 //allocator: *Allocator,
897 //zig_exe: []const u8,
898 //build_root: []const u8,
899 //cache_root: []const u8,
900 const builder = try Builder.create(std.heap.direct_allocator, "zig", "zig-cache", "zig-cache");
901 _ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null;
902}
903
907pub const Version = struct {904pub const Version = struct {
908 major: u32,905 major: u32,
909 minor: u32,906 minor: u32,
...@@ -1122,6 +1119,9 @@ pub const Target = union(enum) {...@@ -1122,6 +1119,9 @@ pub const Target = union(enum) {
1122 }1119 }
11231120
1124 pub fn libPrefix(self: Target) []const u8 {1121 pub fn libPrefix(self: Target) []const u8 {
1122 if (self.isWasm()) {
1123 return "";
1124 }
1125 switch (self.getAbi()) {1125 switch (self.getAbi()) {
1126 .msvc => return "",1126 .msvc => return "",
1127 else => return "lib",1127 else => return "lib",