| ... | ... | @@ -204,10 +204,10 @@ pub const Builder = struct { |
| 204 | 204 | pub fn resolveInstallPrefix(self: *Builder, install_prefix: ?[]const u8, dir_list: DirList) void { |
| 205 | 205 | if (self.dest_dir) |dest_dir| { |
| 206 | 206 | self.install_prefix = install_prefix orelse "/usr"; |
| 207 | | self.install_path = fs.path.join(self.allocator, &[_][]const u8{ dest_dir, self.install_prefix }) catch unreachable; |
| 207 | self.install_path = self.pathJoin(&[_][]const u8{ dest_dir, self.install_prefix }); |
| 208 | 208 | } else { |
| 209 | 209 | self.install_prefix = install_prefix orelse |
| 210 | | (fs.path.join(self.allocator, &[_][]const u8{ self.build_root, "zig-out" }) catch unreachable); |
| 210 | (self.pathJoin(&[_][]const u8{ self.build_root, "zig-out" })); |
| 211 | 211 | self.install_path = self.install_prefix; |
| 212 | 212 | } |
| 213 | 213 | |
| ... | ... | @@ -230,9 +230,9 @@ pub const Builder = struct { |
| 230 | 230 | h_list[1] = dir; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | | self.lib_dir = fs.path.join(self.allocator, &lib_list) catch unreachable; |
| 234 | | self.exe_dir = fs.path.join(self.allocator, &exe_list) catch unreachable; |
| 235 | | self.h_dir = fs.path.join(self.allocator, &h_list) catch unreachable; |
| 233 | self.lib_dir = self.pathJoin(&lib_list); |
| 234 | self.exe_dir = self.pathJoin(&exe_list); |
| 235 | self.h_dir = self.pathJoin(&h_list); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | fn convertOptionalPathToFileSource(path: ?[]const u8) ?FileSource { |
| ... | ... | @@ -1086,6 +1086,11 @@ pub const Builder = struct { |
| 1086 | 1086 | return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable; |
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | /// Shorthand for `std.fs.path.join(builder.allocator, paths) catch unreachable` |
| 1090 | pub fn pathJoin(self: *Builder, paths: []const []const u8) []u8 { |
| 1091 | return fs.path.join(self.allocator, paths) catch unreachable; |
| 1092 | } |
| 1093 | |
| 1089 | 1094 | pub fn fmt(self: *Builder, comptime format: []const u8, args: anytype) []u8 { |
| 1090 | 1095 | return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable; |
| 1091 | 1096 | } |
| ... | ... | @@ -1098,7 +1103,7 @@ pub const Builder = struct { |
| 1098 | 1103 | if (fs.path.isAbsolute(name)) { |
| 1099 | 1104 | return name; |
| 1100 | 1105 | } |
| 1101 | | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ |
| 1106 | const full_path = self.pathJoin(&[_][]const u8{ |
| 1102 | 1107 | search_prefix, |
| 1103 | 1108 | "bin", |
| 1104 | 1109 | self.fmt("{s}{s}", .{ name, exe_extension }), |
| ... | ... | @@ -1113,7 +1118,7 @@ pub const Builder = struct { |
| 1113 | 1118 | } |
| 1114 | 1119 | var it = mem.tokenize(u8, PATH, &[_]u8{fs.path.delimiter}); |
| 1115 | 1120 | while (it.next()) |path| { |
| 1116 | | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ |
| 1121 | const full_path = self.pathJoin(&[_][]const u8{ |
| 1117 | 1122 | path, |
| 1118 | 1123 | self.fmt("{s}{s}", .{ name, exe_extension }), |
| 1119 | 1124 | }); |
| ... | ... | @@ -1126,7 +1131,7 @@ pub const Builder = struct { |
| 1126 | 1131 | return name; |
| 1127 | 1132 | } |
| 1128 | 1133 | for (paths) |path| { |
| 1129 | | const full_path = try fs.path.join(self.allocator, &[_][]const u8{ |
| 1134 | const full_path = self.pathJoin(&[_][]const u8{ |
| 1130 | 1135 | path, |
| 1131 | 1136 | self.fmt("{s}{s}", .{ name, exe_extension }), |
| 1132 | 1137 | }); |
| ... | ... | @@ -1225,7 +1230,7 @@ pub const Builder = struct { |
| 1225 | 1230 | .bin => self.exe_dir, |
| 1226 | 1231 | .lib => self.lib_dir, |
| 1227 | 1232 | .header => self.h_dir, |
| 1228 | | .custom => |path| fs.path.join(self.allocator, &[_][]const u8{ self.install_path, path }) catch unreachable, |
| 1233 | .custom => |path| self.pathJoin(&[_][]const u8{ self.install_path, path }), |
| 1229 | 1234 | }; |
| 1230 | 1235 | return fs.path.resolve( |
| 1231 | 1236 | self.allocator, |
| ... | ... | @@ -1701,11 +1706,9 @@ pub const LibExeObjStep = struct { |
| 1701 | 1706 | } |
| 1702 | 1707 | } |
| 1703 | 1708 | if (self.output_dir != null) { |
| 1704 | | self.output_lib_path_source.path = |
| 1705 | | fs.path.join( |
| 1706 | | self.builder.allocator, |
| 1709 | self.output_lib_path_source.path = self.builder.pathJoin( |
| 1707 | 1710 | &[_][]const u8{ self.output_dir.?, self.out_lib_filename }, |
| 1708 | | ) catch unreachable; |
| 1711 | ); |
| 1709 | 1712 | } |
| 1710 | 1713 | } |
| 1711 | 1714 | } |
| ... | ... | @@ -2132,14 +2135,14 @@ pub const LibExeObjStep = struct { |
| 2132 | 2135 | const triplet = try self.target.vcpkgTriplet(allocator, if (linkage == .static) .Static else .Dynamic); |
| 2133 | 2136 | defer self.builder.allocator.free(triplet); |
| 2134 | 2137 | |
| 2135 | | const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" }); |
| 2138 | const include_path = self.pathJoin(&[_][]const u8{ root, "installed", triplet, "include" }); |
| 2136 | 2139 | errdefer allocator.free(include_path); |
| 2137 | 2140 | try self.include_dirs.append(IncludeDir{ .raw_path = include_path }); |
| 2138 | 2141 | |
| 2139 | | const lib_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "lib" }); |
| 2142 | const lib_path = self.pathJoin(&[_][]const u8{ root, "installed", triplet, "lib" }); |
| 2140 | 2143 | try self.lib_paths.append(lib_path); |
| 2141 | 2144 | |
| 2142 | | self.vcpkg_bin_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "bin" }); |
| 2145 | self.vcpkg_bin_path = self.pathJoin(&[_][]const u8{ root, "installed", triplet, "bin" }); |
| 2143 | 2146 | }, |
| 2144 | 2147 | } |
| 2145 | 2148 | } |
| ... | ... | @@ -2639,11 +2642,11 @@ pub const LibExeObjStep = struct { |
| 2639 | 2642 | |
| 2640 | 2643 | for (builder.search_prefixes.items) |search_prefix| { |
| 2641 | 2644 | try zig_args.append("-L"); |
| 2642 | | try zig_args.append(try fs.path.join(builder.allocator, &[_][]const u8{ |
| 2645 | try zig_args.append(builder.pathJoin(&[_][]const u8{ |
| 2643 | 2646 | search_prefix, "lib", |
| 2644 | 2647 | })); |
| 2645 | 2648 | try zig_args.append("-isystem"); |
| 2646 | | try zig_args.append(try fs.path.join(builder.allocator, &[_][]const u8{ |
| 2649 | try zig_args.append(builder.pathJoin(&[_][]const u8{ |
| 2647 | 2650 | search_prefix, "include", |
| 2648 | 2651 | })); |
| 2649 | 2652 | } |
| ... | ... | @@ -2748,26 +2751,20 @@ pub const LibExeObjStep = struct { |
| 2748 | 2751 | |
| 2749 | 2752 | // Update generated files |
| 2750 | 2753 | if (self.output_dir != null) { |
| 2751 | | self.output_path_source.path = |
| 2752 | | fs.path.join( |
| 2753 | | self.builder.allocator, |
| 2754 | self.output_path_source.path = builder.pathJoin( |
| 2754 | 2755 | &[_][]const u8{ self.output_dir.?, self.out_filename }, |
| 2755 | | ) catch unreachable; |
| 2756 | ); |
| 2756 | 2757 | |
| 2757 | 2758 | if (self.emit_h) { |
| 2758 | | self.output_h_path_source.path = |
| 2759 | | fs.path.join( |
| 2760 | | self.builder.allocator, |
| 2759 | self.output_h_path_source.path = builder.pathJoin( |
| 2761 | 2760 | &[_][]const u8{ self.output_dir.?, self.out_h_filename }, |
| 2762 | | ) catch unreachable; |
| 2761 | ); |
| 2763 | 2762 | } |
| 2764 | 2763 | |
| 2765 | 2764 | if (self.target.isWindows() or self.target.isUefi()) { |
| 2766 | | self.output_pdb_path_source.path = |
| 2767 | | fs.path.join( |
| 2768 | | self.builder.allocator, |
| 2765 | self.output_pdb_path_source.path = builder.pathJoin( |
| 2769 | 2766 | &[_][]const u8{ self.output_dir.?, self.out_pdb_filename }, |
| 2770 | | ) catch unreachable; |
| 2767 | ); |
| 2771 | 2768 | } |
| 2772 | 2769 | } |
| 2773 | 2770 | |
| ... | ... | @@ -2948,11 +2945,11 @@ pub const InstallDirStep = struct { |
| 2948 | 2945 | } |
| 2949 | 2946 | } |
| 2950 | 2947 | |
| 2951 | | const full_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ |
| 2948 | const full_path = self.builder.pathJoin(&[_][]const u8{ |
| 2952 | 2949 | full_src_dir, entry.path, |
| 2953 | 2950 | }); |
| 2954 | 2951 | |
| 2955 | | const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ |
| 2952 | const dest_path = self.builder.pathJoin(&[_][]const u8{ |
| 2956 | 2953 | dest_prefix, entry.path, |
| 2957 | 2954 | }); |
| 2958 | 2955 | |