| author | |
| committer | |
| log | 2b78a90424ee47ee1a9ef590dcf517026d0f13d1 |
| tree | 3ac725d29461fafd3076fca688cd6fa78928564a |
| parent | 53766e7a3a5c7141a64e21c30540f9ed571cdfdd |
| signature | Commit is signed but in an unrecognized format. |
std/os/child_process.zig: windows
test/cli.zig: godbolt;
doc/docgen.zig10 files changed, 101 insertions(+), 78 deletions(-)
build.zig+8-8| ... | @@ -16,7 +16,7 @@ pub fn build(b: *Builder) !void { | ... | @@ -16,7 +16,7 @@ pub fn build(b: *Builder) !void { |
| 16 | var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig"); | 16 | var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig"); |
| 17 | 17 | ||
| 18 | const rel_zig_exe = try os.path.relative(b.allocator, b.build_root, b.zig_exe); | 18 | const rel_zig_exe = try os.path.relative(b.allocator, b.build_root, b.zig_exe); |
| 19 | const langref_out_path = os.path.join(b.allocator, b.cache_root, "langref.html") catch unreachable; | 19 | const langref_out_path = os.path.join(b.allocator, [][]const u8{ b.cache_root, "langref.html" }) catch unreachable; |
| 20 | var docgen_cmd = b.addCommand(null, b.env_map, [][]const u8{ | 20 | var docgen_cmd = b.addCommand(null, b.env_map, [][]const u8{ |
| 21 | docgen_exe.getOutputPath(), | 21 | docgen_exe.getOutputPath(), |
| 22 | rel_zig_exe, | 22 | rel_zig_exe, |
| ... | @@ -125,13 +125,13 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void { | ... | @@ -125,13 +125,13 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void { |
| 125 | for (dep.libdirs.toSliceConst()) |lib_dir| { | 125 | for (dep.libdirs.toSliceConst()) |lib_dir| { |
| 126 | lib_exe_obj.addLibPath(lib_dir); | 126 | lib_exe_obj.addLibPath(lib_dir); |
| 127 | } | 127 | } |
| 128 | const lib_dir = os.path.join(b.allocator, dep.prefix, "lib") catch unreachable; | 128 | const lib_dir = os.path.join(b.allocator, [][]const u8{dep.prefix, "lib"}) catch unreachable; |
| 129 | for (dep.system_libs.toSliceConst()) |lib| { | 129 | for (dep.system_libs.toSliceConst()) |lib| { |
| 130 | const static_bare_name = if (mem.eql(u8, lib, "curses")) | 130 | const static_bare_name = if (mem.eql(u8, lib, "curses")) |
| 131 | ([]const u8)("libncurses.a") | 131 | ([]const u8)("libncurses.a") |
| 132 | else | 132 | else |
| 133 | b.fmt("lib{}.a", lib); | 133 | b.fmt("lib{}.a", lib); |
| 134 | const static_lib_name = os.path.join(b.allocator, lib_dir, static_bare_name) catch unreachable; | 134 | const static_lib_name = os.path.join(b.allocator, [][]const u8{lib_dir, static_bare_name}) catch unreachable; |
| 135 | const have_static = fileExists(static_lib_name) catch unreachable; | 135 | const have_static = fileExists(static_lib_name) catch unreachable; |
| 136 | if (have_static) { | 136 | if (have_static) { |
| 137 | lib_exe_obj.addObjectFile(static_lib_name); | 137 | lib_exe_obj.addObjectFile(static_lib_name); |
| ... | @@ -159,7 +159,7 @@ fn fileExists(filename: []const u8) !bool { | ... | @@ -159,7 +159,7 @@ fn fileExists(filename: []const u8) !bool { |
| 159 | 159 | ||
| 160 | fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_name: []const u8) void { | 160 | fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_name: []const u8) void { |
| 161 | const lib_prefix = if (lib_exe_obj.target.isWindows()) "" else "lib"; | 161 | const lib_prefix = if (lib_exe_obj.target.isWindows()) "" else "lib"; |
| 162 | lib_exe_obj.addObjectFile(os.path.join(b.allocator, cmake_binary_dir, "zig_cpp", b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt())) catch unreachable); | 162 | lib_exe_obj.addObjectFile(os.path.join(b.allocator, [][]const u8{ cmake_binary_dir, "zig_cpp", b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt()) }) catch unreachable); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | const LibraryDep = struct { | 165 | const LibraryDep = struct { |
| ... | @@ -235,8 +235,8 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { | ... | @@ -235,8 +235,8 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { |
| 235 | pub fn installStdLib(b: *Builder, stdlib_files: []const u8) void { | 235 | pub fn installStdLib(b: *Builder, stdlib_files: []const u8) void { |
| 236 | var it = mem.split(stdlib_files, ";"); | 236 | var it = mem.split(stdlib_files, ";"); |
| 237 | while (it.next()) |stdlib_file| { | 237 | while (it.next()) |stdlib_file| { |
| 238 | const src_path = os.path.join(b.allocator, "std", stdlib_file) catch unreachable; | 238 | const src_path = os.path.join(b.allocator, [][]const u8{"std", stdlib_file}) catch unreachable; |
| 239 | const dest_path = os.path.join(b.allocator, "lib", "zig", "std", stdlib_file) catch unreachable; | 239 | const dest_path = os.path.join(b.allocator, [][]const u8{"lib", "zig", "std", stdlib_file}) catch unreachable; |
| 240 | b.installFile(src_path, dest_path); | 240 | b.installFile(src_path, dest_path); |
| 241 | } | 241 | } |
| 242 | } | 242 | } |
| ... | @@ -244,8 +244,8 @@ pub fn installStdLib(b: *Builder, stdlib_files: []const u8) void { | ... | @@ -244,8 +244,8 @@ pub fn installStdLib(b: *Builder, stdlib_files: []const u8) void { |
| 244 | pub fn installCHeaders(b: *Builder, c_header_files: []const u8) void { | 244 | pub fn installCHeaders(b: *Builder, c_header_files: []const u8) void { |
| 245 | var it = mem.split(c_header_files, ";"); | 245 | var it = mem.split(c_header_files, ";"); |
| 246 | while (it.next()) |c_header_file| { | 246 | while (it.next()) |c_header_file| { |
| 247 | const src_path = os.path.join(b.allocator, "c_headers", c_header_file) catch unreachable; | 247 | const src_path = os.path.join(b.allocator, [][]const u8{"c_headers", c_header_file}) catch unreachable; |
| 248 | const dest_path = os.path.join(b.allocator, "lib", "zig", "include", c_header_file) catch unreachable; | 248 | const dest_path = os.path.join(b.allocator, [][]const u8{"lib", "zig", "include", c_header_file}) catch unreachable; |
| 249 | b.installFile(src_path, dest_path); | 249 | b.installFile(src_path, dest_path); |
| 250 | } | 250 | } |
| 251 | } | 251 | } |
doc/docgen.zig+5-5| ... | @@ -990,13 +990,13 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var | ... | @@ -990,13 +990,13 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 990 | try tokenizeAndPrint(tokenizer, out, code.source_token); | 990 | try tokenizeAndPrint(tokenizer, out, code.source_token); |
| 991 | try out.write("</pre>"); | 991 | try out.write("</pre>"); |
| 992 | const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", code.name); | 992 | const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", code.name); |
| 993 | const tmp_source_file_name = try os.path.join(allocator, tmp_dir_name, name_plus_ext); | 993 | const tmp_source_file_name = try os.path.join(allocator, [][]const u8{ tmp_dir_name, name_plus_ext }); |
| 994 | try io.writeFile(tmp_source_file_name, trimmed_raw_source); | 994 | try io.writeFile(tmp_source_file_name, trimmed_raw_source); |
| 995 | 995 | ||
| 996 | switch (code.id) { | 996 | switch (code.id) { |
| 997 | Code.Id.Exe => |expected_outcome| { | 997 | Code.Id.Exe => |expected_outcome| { |
| 998 | const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext); | 998 | const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext); |
| 999 | const tmp_bin_file_name = try os.path.join(allocator, tmp_dir_name, name_plus_bin_ext); | 999 | const tmp_bin_file_name = try os.path.join(allocator, [][]const u8{ tmp_dir_name, name_plus_bin_ext }); |
| 1000 | var build_args = std.ArrayList([]const u8).init(allocator); | 1000 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1001 | defer build_args.deinit(); | 1001 | defer build_args.deinit(); |
| 1002 | try build_args.appendSlice([][]const u8{ | 1002 | try build_args.appendSlice([][]const u8{ |
| ... | @@ -1024,7 +1024,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var | ... | @@ -1024,7 +1024,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1024 | } | 1024 | } |
| 1025 | for (code.link_objects) |link_object| { | 1025 | for (code.link_objects) |link_object| { |
| 1026 | const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", link_object, obj_ext); | 1026 | const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", link_object, obj_ext); |
| 1027 | const full_path_object = try os.path.join(allocator, tmp_dir_name, name_with_ext); | 1027 | const full_path_object = try os.path.join(allocator, [][]const u8{ tmp_dir_name, name_with_ext }); |
| 1028 | try build_args.append("--object"); | 1028 | try build_args.append("--object"); |
| 1029 | try build_args.append(full_path_object); | 1029 | try build_args.append(full_path_object); |
| 1030 | try out.print(" --object {}", name_with_ext); | 1030 | try out.print(" --object {}", name_with_ext); |
| ... | @@ -1216,12 +1216,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var | ... | @@ -1216,12 +1216,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1216 | }, | 1216 | }, |
| 1217 | Code.Id.Obj => |maybe_error_match| { | 1217 | Code.Id.Obj => |maybe_error_match| { |
| 1218 | const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, obj_ext); | 1218 | const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, obj_ext); |
| 1219 | const tmp_obj_file_name = try os.path.join(allocator, tmp_dir_name, name_plus_obj_ext); | 1219 | const tmp_obj_file_name = try os.path.join(allocator, [][]const u8{ tmp_dir_name, name_plus_obj_ext }); |
| 1220 | var build_args = std.ArrayList([]const u8).init(allocator); | 1220 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1221 | defer build_args.deinit(); | 1221 | defer build_args.deinit(); |
| 1222 | 1222 | ||
| 1223 | const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", code.name); | 1223 | const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", code.name); |
| 1224 | const output_h_file_name = try os.path.join(allocator, tmp_dir_name, name_plus_h_ext); | 1224 | const output_h_file_name = try os.path.join(allocator, [][]const u8{ tmp_dir_name, name_plus_h_ext }); |
| 1225 | 1225 | ||
| 1226 | try build_args.appendSlice([][]const u8{ | 1226 | try build_args.appendSlice([][]const u8{ |
| 1227 | zig_exe, | 1227 | zig_exe, |
std/build.zig+17-17| ... | @@ -145,8 +145,8 @@ pub const Builder = struct { | ... | @@ -145,8 +145,8 @@ pub const Builder = struct { |
| 145 | 145 | ||
| 146 | pub fn setInstallPrefix(self: *Builder, maybe_prefix: ?[]const u8) void { | 146 | pub fn setInstallPrefix(self: *Builder, maybe_prefix: ?[]const u8) void { |
| 147 | self.prefix = maybe_prefix orelse "/usr/local"; // TODO better default | 147 | self.prefix = maybe_prefix orelse "/usr/local"; // TODO better default |
| 148 | self.lib_dir = os.path.join(self.allocator, self.prefix, "lib") catch unreachable; | 148 | self.lib_dir = os.path.join(self.allocator, [][]const u8{self.prefix, "lib"}) catch unreachable; |
| 149 | self.exe_dir = os.path.join(self.allocator, self.prefix, "bin") catch unreachable; | 149 | self.exe_dir = os.path.join(self.allocator, [][]const u8{self.prefix, "bin"}) catch unreachable; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { | 152 | pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| ... | @@ -666,7 +666,7 @@ pub const Builder = struct { | ... | @@ -666,7 +666,7 @@ pub const Builder = struct { |
| 666 | if (os.path.isAbsolute(name)) { | 666 | if (os.path.isAbsolute(name)) { |
| 667 | return name; | 667 | return name; |
| 668 | } | 668 | } |
| 669 | const full_path = try os.path.join(self.allocator, search_prefix, "bin", self.fmt("{}{}", name, exe_extension)); | 669 | const full_path = try os.path.join(self.allocator, [][]const u8{search_prefix, "bin", self.fmt("{}{}", name, exe_extension)}); |
| 670 | if (os.path.real(self.allocator, full_path)) |real_path| { | 670 | if (os.path.real(self.allocator, full_path)) |real_path| { |
| 671 | return real_path; | 671 | return real_path; |
| 672 | } else |_| { | 672 | } else |_| { |
| ... | @@ -681,7 +681,7 @@ pub const Builder = struct { | ... | @@ -681,7 +681,7 @@ pub const Builder = struct { |
| 681 | } | 681 | } |
| 682 | var it = mem.split(PATH, []u8{os.path.delimiter}); | 682 | var it = mem.split(PATH, []u8{os.path.delimiter}); |
| 683 | while (it.next()) |path| { | 683 | while (it.next()) |path| { |
| 684 | const full_path = try os.path.join(self.allocator, path, self.fmt("{}{}", name, exe_extension)); | 684 | const full_path = try os.path.join(self.allocator, [][]const u8{path, self.fmt("{}{}", name, exe_extension)}); |
| 685 | if (os.path.real(self.allocator, full_path)) |real_path| { | 685 | if (os.path.real(self.allocator, full_path)) |real_path| { |
| 686 | return real_path; | 686 | return real_path; |
| 687 | } else |_| { | 687 | } else |_| { |
| ... | @@ -695,7 +695,7 @@ pub const Builder = struct { | ... | @@ -695,7 +695,7 @@ pub const Builder = struct { |
| 695 | return name; | 695 | return name; |
| 696 | } | 696 | } |
| 697 | for (paths) |path| { | 697 | for (paths) |path| { |
| 698 | const full_path = try os.path.join(self.allocator, path, self.fmt("{}{}", name, exe_extension)); | 698 | const full_path = try os.path.join(self.allocator, [][]const u8{path, self.fmt("{}{}", name, exe_extension)}); |
| 699 | if (os.path.real(self.allocator, full_path)) |real_path| { | 699 | if (os.path.real(self.allocator, full_path)) |real_path| { |
| 700 | return real_path; | 700 | return real_path; |
| 701 | } else |_| { | 701 | } else |_| { |
| ... | @@ -1095,7 +1095,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1095,7 +1095,7 @@ pub const LibExeObjStep = struct { |
| 1095 | } | 1095 | } |
| 1096 | 1096 | ||
| 1097 | pub fn getOutputPath(self: *LibExeObjStep) []const u8 { | 1097 | pub fn getOutputPath(self: *LibExeObjStep) []const u8 { |
| 1098 | return if (self.output_path) |output_path| output_path else os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename) catch unreachable; | 1098 | return if (self.output_path) |output_path| output_path else os.path.join(self.builder.allocator, [][]const u8{self.builder.cache_root, self.out_filename}) catch unreachable; |
| 1099 | } | 1099 | } |
| 1100 | 1100 | ||
| 1101 | pub fn setOutputHPath(self: *LibExeObjStep, file_path: []const u8) void { | 1101 | pub fn setOutputHPath(self: *LibExeObjStep, file_path: []const u8) void { |
| ... | @@ -1108,7 +1108,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1108,7 +1108,7 @@ pub const LibExeObjStep = struct { |
| 1108 | } | 1108 | } |
| 1109 | 1109 | ||
| 1110 | pub fn getOutputHPath(self: *LibExeObjStep) []const u8 { | 1110 | pub fn getOutputHPath(self: *LibExeObjStep) []const u8 { |
| 1111 | return if (self.output_h_path) |output_h_path| output_h_path else os.path.join(self.builder.allocator, self.builder.cache_root, self.out_h_filename) catch unreachable; | 1111 | return if (self.output_h_path) |output_h_path| output_h_path else os.path.join(self.builder.allocator, [][]const u8{self.builder.cache_root, self.out_h_filename}) catch unreachable; |
| 1112 | } | 1112 | } |
| 1113 | 1113 | ||
| 1114 | pub fn addAssemblyFile(self: *LibExeObjStep, path: []const u8) void { | 1114 | pub fn addAssemblyFile(self: *LibExeObjStep, path: []const u8) void { |
| ... | @@ -1208,7 +1208,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1208,7 +1208,7 @@ pub const LibExeObjStep = struct { |
| 1208 | } | 1208 | } |
| 1209 | 1209 | ||
| 1210 | if (self.build_options_contents.len() > 0) { | 1210 | if (self.build_options_contents.len() > 0) { |
| 1211 | const build_options_file = try os.path.join(builder.allocator, builder.cache_root, builder.fmt("{}_build_options.zig", self.name)); | 1211 | const build_options_file = try os.path.join(builder.allocator, [][]const u8{builder.cache_root, builder.fmt("{}_build_options.zig", self.name)}); |
| 1212 | try std.io.writeFile(build_options_file, self.build_options_contents.toSliceConst()); | 1212 | try std.io.writeFile(build_options_file, self.build_options_contents.toSliceConst()); |
| 1213 | try zig_args.append("--pkg-begin"); | 1213 | try zig_args.append("--pkg-begin"); |
| 1214 | try zig_args.append("build_options"); | 1214 | try zig_args.append("build_options"); |
| ... | @@ -1455,7 +1455,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1455,7 +1455,7 @@ pub const LibExeObjStep = struct { |
| 1455 | cc_args.append("-c") catch unreachable; | 1455 | cc_args.append("-c") catch unreachable; |
| 1456 | cc_args.append(abs_source_file) catch unreachable; | 1456 | cc_args.append(abs_source_file) catch unreachable; |
| 1457 | 1457 | ||
| 1458 | const cache_o_src = os.path.join(builder.allocator, builder.cache_root, source_file) catch unreachable; | 1458 | const cache_o_src = os.path.join(builder.allocator, [][]const u8{builder.cache_root, source_file}) catch unreachable; |
| 1459 | if (os.path.dirname(cache_o_src)) |cache_o_dir| { | 1459 | if (os.path.dirname(cache_o_src)) |cache_o_dir| { |
| 1460 | try builder.makePath(cache_o_dir); | 1460 | try builder.makePath(cache_o_dir); |
| 1461 | } | 1461 | } |
| ... | @@ -1507,7 +1507,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1507,7 +1507,7 @@ pub const LibExeObjStep = struct { |
| 1507 | cc_args.append("-current_version") catch unreachable; | 1507 | cc_args.append("-current_version") catch unreachable; |
| 1508 | cc_args.append(builder.fmt("{}.{}.{}", self.version.major, self.version.minor, self.version.patch)) catch unreachable; | 1508 | cc_args.append(builder.fmt("{}.{}.{}", self.version.major, self.version.minor, self.version.patch)) catch unreachable; |
| 1509 | 1509 | ||
| 1510 | const install_name = builder.pathFromRoot(os.path.join(builder.allocator, builder.cache_root, self.major_only_filename) catch unreachable); | 1510 | const install_name = builder.pathFromRoot(os.path.join(builder.allocator, [][]const u8{builder.cache_root, self.major_only_filename}) catch unreachable); |
| 1511 | cc_args.append("-install_name") catch unreachable; | 1511 | cc_args.append("-install_name") catch unreachable; |
| 1512 | cc_args.append(install_name) catch unreachable; | 1512 | cc_args.append(install_name) catch unreachable; |
| 1513 | } else { | 1513 | } else { |
| ... | @@ -1573,7 +1573,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1573,7 +1573,7 @@ pub const LibExeObjStep = struct { |
| 1573 | cc_args.append("-c") catch unreachable; | 1573 | cc_args.append("-c") catch unreachable; |
| 1574 | cc_args.append(abs_source_file) catch unreachable; | 1574 | cc_args.append(abs_source_file) catch unreachable; |
| 1575 | 1575 | ||
| 1576 | const cache_o_src = os.path.join(builder.allocator, builder.cache_root, source_file) catch unreachable; | 1576 | const cache_o_src = os.path.join(builder.allocator, [][]const u8{builder.cache_root, source_file}) catch unreachable; |
| 1577 | if (os.path.dirname(cache_o_src)) |cache_o_dir| { | 1577 | if (os.path.dirname(cache_o_src)) |cache_o_dir| { |
| 1578 | try builder.makePath(cache_o_dir); | 1578 | try builder.makePath(cache_o_dir); |
| 1579 | } | 1579 | } |
| ... | @@ -1721,7 +1721,7 @@ pub const TestStep = struct { | ... | @@ -1721,7 +1721,7 @@ pub const TestStep = struct { |
| 1721 | return output_path; | 1721 | return output_path; |
| 1722 | } else { | 1722 | } else { |
| 1723 | const basename = self.builder.fmt("test{}", self.target.exeFileExt()); | 1723 | const basename = self.builder.fmt("test{}", self.target.exeFileExt()); |
| 1724 | return os.path.join(self.builder.allocator, self.builder.cache_root, basename) catch unreachable; | 1724 | return os.path.join(self.builder.allocator, [][]const u8{self.builder.cache_root, basename}) catch unreachable; |
| 1725 | } | 1725 | } |
| 1726 | } | 1726 | } |
| 1727 | 1727 | ||
| ... | @@ -1930,13 +1930,13 @@ const InstallArtifactStep = struct { | ... | @@ -1930,13 +1930,13 @@ const InstallArtifactStep = struct { |
| 1930 | .builder = builder, | 1930 | .builder = builder, |
| 1931 | .step = Step.init(builder.fmt("install {}", artifact.step.name), builder.allocator, make), | 1931 | .step = Step.init(builder.fmt("install {}", artifact.step.name), builder.allocator, make), |
| 1932 | .artifact = artifact, | 1932 | .artifact = artifact, |
| 1933 | .dest_file = os.path.join(builder.allocator, dest_dir, artifact.out_filename) catch unreachable, | 1933 | .dest_file = os.path.join(builder.allocator, [][]const u8{dest_dir, artifact.out_filename}) catch unreachable, |
| 1934 | }) catch unreachable; | 1934 | }) catch unreachable; |
| 1935 | self.step.dependOn(&artifact.step); | 1935 | self.step.dependOn(&artifact.step); |
| 1936 | builder.pushInstalledFile(self.dest_file); | 1936 | builder.pushInstalledFile(self.dest_file); |
| 1937 | if (self.artifact.kind == LibExeObjStep.Kind.Lib and !self.artifact.static) { | 1937 | if (self.artifact.kind == LibExeObjStep.Kind.Lib and !self.artifact.static) { |
| 1938 | builder.pushInstalledFile(os.path.join(builder.allocator, builder.lib_dir, artifact.major_only_filename) catch unreachable); | 1938 | builder.pushInstalledFile(os.path.join(builder.allocator, [][]const u8{builder.lib_dir, artifact.major_only_filename}) catch unreachable); |
| 1939 | builder.pushInstalledFile(os.path.join(builder.allocator, builder.lib_dir, artifact.name_only_filename) catch unreachable); | 1939 | builder.pushInstalledFile(os.path.join(builder.allocator, [][]const u8{builder.lib_dir, artifact.name_only_filename}) catch unreachable); |
| 1940 | } | 1940 | } |
| 1941 | return self; | 1941 | return self; |
| 1942 | } | 1942 | } |
| ... | @@ -2092,13 +2092,13 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj | ... | @@ -2092,13 +2092,13 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2092 | const out_dir = os.path.dirname(output_path) orelse "."; | 2092 | const out_dir = os.path.dirname(output_path) orelse "."; |
| 2093 | const out_basename = os.path.basename(output_path); | 2093 | const out_basename = os.path.basename(output_path); |
| 2094 | // sym link for libfoo.so.1 to libfoo.so.1.2.3 | 2094 | // sym link for libfoo.so.1 to libfoo.so.1.2.3 |
| 2095 | const major_only_path = os.path.join(allocator, out_dir, filename_major_only) catch unreachable; | 2095 | const major_only_path = os.path.join(allocator, [][]const u8{out_dir, filename_major_only}) catch unreachable; |
| 2096 | os.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { | 2096 | os.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { |
| 2097 | warn("Unable to symlink {} -> {}\n", major_only_path, out_basename); | 2097 | warn("Unable to symlink {} -> {}\n", major_only_path, out_basename); |
| 2098 | return err; | 2098 | return err; |
| 2099 | }; | 2099 | }; |
| 2100 | // sym link for libfoo.so to libfoo.so.1 | 2100 | // sym link for libfoo.so to libfoo.so.1 |
| 2101 | const name_only_path = os.path.join(allocator, out_dir, filename_name_only) catch unreachable; | 2101 | const name_only_path = os.path.join(allocator, [][]const u8{out_dir, filename_name_only}) catch unreachable; |
| 2102 | os.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { | 2102 | os.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { |
| 2103 | warn("Unable to symlink {} -> {}\n", name_only_path, filename_major_only); | 2103 | warn("Unable to symlink {} -> {}\n", name_only_path, filename_major_only); |
| 2104 | return err; | 2104 | return err; |
std/debug/index.zig+1-1| ... | @@ -1290,7 +1290,7 @@ const LineNumberProgram = struct { | ... | @@ -1290,7 +1290,7 @@ const LineNumberProgram = struct { |
| 1290 | return error.InvalidDebugInfo; | 1290 | return error.InvalidDebugInfo; |
| 1291 | } else | 1291 | } else |
| 1292 | self.include_dirs[file_entry.dir_index]; | 1292 | self.include_dirs[file_entry.dir_index]; |
| 1293 | const file_name = try os.path.join(self.file_entries.allocator, dir_name, file_entry.file_name); | 1293 | const file_name = try os.path.join(self.file_entries.allocator, [][]const u8{dir_name, file_entry.file_name}); |
| 1294 | errdefer self.file_entries.allocator.free(file_name); | 1294 | errdefer self.file_entries.allocator.free(file_name); |
| 1295 | return LineInfo{ | 1295 | return LineInfo{ |
| 1296 | .line = if (self.prev_line >= 0) @intCast(usize, self.prev_line) else 0, | 1296 | .line = if (self.prev_line >= 0) @intCast(usize, self.prev_line) else 0, |
std/event/fs.zig+1-1| ... | @@ -1339,7 +1339,7 @@ async fn testFsWatchCantFail(loop: *Loop, result: *(anyerror!void)) void { | ... | @@ -1339,7 +1339,7 @@ async fn testFsWatchCantFail(loop: *Loop, result: *(anyerror!void)) void { |
| 1339 | } | 1339 | } |
| 1340 | 1340 | ||
| 1341 | async fn testFsWatch(loop: *Loop) !void { | 1341 | async fn testFsWatch(loop: *Loop) !void { |
| 1342 | const file_path = try os.path.join(loop.allocator, test_tmp_dir, "file.txt"); | 1342 | const file_path = try os.path.join(loop.allocator, [][]const u8{test_tmp_dir, "file.txt"}); |
| 1343 | defer loop.allocator.free(file_path); | 1343 | defer loop.allocator.free(file_path); |
| 1344 | 1344 | ||
| 1345 | const contents = | 1345 | const contents = |
std/os/child_process.zig+1-1| ... | @@ -596,7 +596,7 @@ pub const ChildProcess = struct { | ... | @@ -596,7 +596,7 @@ pub const ChildProcess = struct { |
| 596 | 596 | ||
| 597 | var it = mem.split(PATH, ";"); | 597 | var it = mem.split(PATH, ";"); |
| 598 | while (it.next()) |search_path| { | 598 | while (it.next()) |search_path| { |
| 599 | const joined_path = try os.path.join(self.allocator, search_path, app_name); | 599 | const joined_path = try os.path.join(self.allocator, [][]const u8{ search_path, app_name }); |
| 600 | defer self.allocator.free(joined_path); | 600 | defer self.allocator.free(joined_path); |
| 601 | 601 | ||
| 602 | const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, app_name); | 602 | const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, app_name); |
std/os/get_app_data_dir.zig+3-3| ... | @@ -30,7 +30,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD | ... | @@ -30,7 +30,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 30 | error.OutOfMemory => return error.OutOfMemory, | 30 | error.OutOfMemory => return error.OutOfMemory, |
| 31 | }; | 31 | }; |
| 32 | defer allocator.free(global_dir); | 32 | defer allocator.free(global_dir); |
| 33 | return os.path.join(allocator, global_dir, appname); | 33 | return os.path.join(allocator, [][]const u8{global_dir, appname}); |
| 34 | }, | 34 | }, |
| 35 | os.windows.E_OUTOFMEMORY => return error.OutOfMemory, | 35 | os.windows.E_OUTOFMEMORY => return error.OutOfMemory, |
| 36 | else => return error.AppDataDirUnavailable, | 36 | else => return error.AppDataDirUnavailable, |
| ... | @@ -41,14 +41,14 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD | ... | @@ -41,14 +41,14 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD |
| 41 | // TODO look in /etc/passwd | 41 | // TODO look in /etc/passwd |
| 42 | return error.AppDataDirUnavailable; | 42 | return error.AppDataDirUnavailable; |
| 43 | }; | 43 | }; |
| 44 | return os.path.join(allocator, home_dir, "Library", "Application Support", appname); | 44 | return os.path.join(allocator, [][]const u8{home_dir, "Library", "Application Support", appname}); |
| 45 | }, | 45 | }, |
| 46 | builtin.Os.linux, builtin.Os.freebsd => { | 46 | builtin.Os.linux, builtin.Os.freebsd => { |
| 47 | const home_dir = os.getEnvPosix("HOME") orelse { | 47 | const home_dir = os.getEnvPosix("HOME") orelse { |
| 48 | // TODO look in /etc/passwd | 48 | // TODO look in /etc/passwd |
| 49 | return error.AppDataDirUnavailable; | 49 | return error.AppDataDirUnavailable; |
| 50 | }; | 50 | }; |
| 51 | return os.path.join(allocator, home_dir, ".local", "share", appname); | 51 | return os.path.join(allocator, [][]const u8{home_dir, ".local", "share", appname}); |
| 52 | }, | 52 | }, |
| 53 | else => @compileError("Unsupported OS"), | 53 | else => @compileError("Unsupported OS"), |
| 54 | } | 54 | } |
std/os/path.zig+51-28| ... | @@ -35,38 +35,61 @@ pub fn isSep(byte: u8) bool { | ... | @@ -35,38 +35,61 @@ pub fn isSep(byte: u8) bool { |
| 35 | 35 | ||
| 36 | /// Naively combines a series of paths with the native path seperator. | 36 | /// Naively combines a series of paths with the native path seperator. |
| 37 | /// Allocates memory for the result, which must be freed by the caller. | 37 | /// Allocates memory for the result, which must be freed by the caller. |
| 38 | pub fn join(allocator: *Allocator, paths: ...) ![]u8 { | 38 | |
| 39 | if (is_windows) { | 39 | pub fn join(allocator: *Allocator, paths: []const []const u8) ![]u8 { |
| 40 | return joinWindows(allocator, paths); | 40 | assert(paths.len >= 1); |
| 41 | } else { | 41 | var total_paths_len: usize = paths.len; // 1 sep per path |
| 42 | return joinPosix(allocator, paths); | 42 | { |
| 43 | var path_i: usize = 0; | ||
| 44 | while (path_i < paths.len) : (path_i += 1) { | ||
| 45 | const arg = ([]const u8)(paths[path_i]); | ||
| 46 | total_paths_len += arg.len; | ||
| 47 | } | ||
| 43 | } | 48 | } |
| 44 | } | ||
| 45 | 49 | ||
| 46 | pub fn joinWindows(allocator: *Allocator, paths: ...) ![]u8 { | 50 | const buf = try allocator.alloc(u8, total_paths_len); |
| 47 | return mem.join(allocator, sep_windows, paths); | 51 | errdefer allocator.free(buf); |
| 48 | } | 52 | |
| 53 | var buf_index: usize = 0; | ||
| 54 | var path_i: usize = 0; | ||
| 55 | while (true) { | ||
| 56 | const arg = ([]const u8)(paths[path_i]); | ||
| 57 | path_i += 1; | ||
| 58 | mem.copy(u8, buf[buf_index..], arg); | ||
| 59 | buf_index += arg.len; | ||
| 60 | if (path_i >= paths.len) break; | ||
| 61 | if (buf_index > 0 and buf[buf_index - 1] != sep) { | ||
| 62 | buf[buf_index] = sep; | ||
| 63 | buf_index += 1; | ||
| 64 | } | ||
| 65 | } | ||
| 49 | 66 | ||
| 50 | pub fn joinPosix(allocator: *Allocator, paths: ...) ![]u8 { | 67 | return allocator.shrink(u8, buf, buf_index); |
| 51 | return mem.join(allocator, sep_posix, paths); | ||
| 52 | } | 68 | } |
| 53 | 69 | ||
| 54 | test "os.path.join" { | 70 | test "os.path.join" { |
| 55 | assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\a\\b", "c"), "c:\\a\\b\\c")); | 71 | switch (builtin.os) { |
| 56 | assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\a\\b\\", "c"), "c:\\a\\b\\c")); | 72 | Os.windows => { |
| 57 | 73 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"c:\\a\\b", "c"}), "c:\\a\\b\\c")); | |
| 58 | assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\", "a", "b\\", "c"), "c:\\a\\b\\c")); | 74 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"c:\\a\\b\\", "c"}), "c:\\a\\b\\c")); |
| 59 | assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\a\\", "b\\", "c"), "c:\\a\\b\\c")); | 75 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"c:\\", "a", "b\\", "c"}), "c:\\a\\b\\c")); |
| 60 | 76 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"c:\\a\\", "b\\", "c"}), "c:\\a\\b\\c")); | |
| 61 | assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig"), "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig")); | 77 | assert(mem.eql(u8, try join( debug.global_allocator |
| 62 | 78 | , [][]const u8{ "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std" | |
| 63 | assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/a/b", "c"), "/a/b/c")); | 79 | , "io.zig"}) |
| 64 | assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/a/b/", "c"), "/a/b/c")); | 80 | , "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig")); |
| 65 | 81 | }, | |
| 66 | assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/", "a", "b/", "c"), "/a/b/c")); | 82 | else => { |
| 67 | assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/a/", "b/", "c"), "/a/b/c")); | 83 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"/a/b", "c"}), "/a/b/c")); |
| 68 | 84 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"/a/b/", "c"}), "/a/b/c")); | |
| 69 | assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/home/andy/dev/zig/build/lib/zig/std", "io.zig"), "/home/andy/dev/zig/build/lib/zig/std/io.zig")); | 85 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"/", "a", "b/", "c"}), "/a/b/c")); |
| 86 | assert(mem.eql(u8, try join(debug.global_allocator, [][]const u8{"/a/", "b/", "c"}), "/a/b/c")); | ||
| 87 | assert(mem.eql(u8, try join( debug.global_allocator | ||
| 88 | , [][]const u8{ "/home/andy/dev/zig/build/lib/zig/std" | ||
| 89 | , "io.zig"}) | ||
| 90 | , "/home/andy/dev/zig/build/lib/zig/std/io.zig")); | ||
| 91 | } | ||
| 92 | } | ||
| 70 | } | 93 | } |
| 71 | 94 | ||
| 72 | pub fn isAbsolute(path: []const u8) bool { | 95 | pub fn isAbsolute(path: []const u8) bool { |
| ... | @@ -598,7 +621,7 @@ test "os.path.resolveWindows" { | ... | @@ -598,7 +621,7 @@ test "os.path.resolveWindows" { |
| 598 | const parsed_cwd = windowsParsePath(cwd); | 621 | const parsed_cwd = windowsParsePath(cwd); |
| 599 | { | 622 | { |
| 600 | const result = testResolveWindows([][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }); | 623 | const result = testResolveWindows([][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }); |
| 601 | const expected = try join(debug.global_allocator, parsed_cwd.disk_designator, "usr\\local\\lib\\zig\\std\\array_list.zig"); | 624 | const expected = try join(debug.global_allocator, [][]const u8{ parsed_cwd.disk_designator, "usr\\local\\lib\\zig\\std\\array_list.zig"}); |
| 602 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { | 625 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { |
| 603 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); | 626 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); |
| 604 | } | 627 | } |
| ... | @@ -606,7 +629,7 @@ test "os.path.resolveWindows" { | ... | @@ -606,7 +629,7 @@ test "os.path.resolveWindows" { |
| 606 | } | 629 | } |
| 607 | { | 630 | { |
| 608 | const result = testResolveWindows([][]const u8{ "usr/local", "lib\\zig" }); | 631 | const result = testResolveWindows([][]const u8{ "usr/local", "lib\\zig" }); |
| 609 | const expected = try join(debug.global_allocator, cwd, "usr\\local\\lib\\zig"); | 632 | const expected = try join(debug.global_allocator, [][]const u8{ cwd, "usr\\local\\lib\\zig" }); |
| 610 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { | 633 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { |
| 611 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); | 634 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); |
| 612 | } | 635 | } |
test/cli.zig+3-3| ... | @@ -29,7 +29,7 @@ pub fn main() !void { | ... | @@ -29,7 +29,7 @@ pub fn main() !void { |
| 29 | }); | 29 | }); |
| 30 | const zig_exe = try os.path.resolve(a, zig_exe_rel); | 30 | const zig_exe = try os.path.resolve(a, zig_exe_rel); |
| 31 | 31 | ||
| 32 | const dir_path = try os.path.join(a, cache_root, "clitest"); | 32 | const dir_path = try os.path.join(a, [][]const u8{ cache_root, "clitest" }); |
| 33 | const TestFn = fn ([]const u8, []const u8) anyerror!void; | 33 | const TestFn = fn ([]const u8, []const u8) anyerror!void; |
| 34 | const test_fns = []TestFn{ | 34 | const test_fns = []TestFn{ |
| 35 | testZigInitLib, | 35 | testZigInitLib, |
| ... | @@ -99,8 +99,8 @@ fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void { | ... | @@ -99,8 +99,8 @@ fn testZigInitExe(zig_exe: []const u8, dir_path: []const u8) !void { |
| 99 | fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void { | 99 | fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void { |
| 100 | if (builtin.os != builtin.Os.linux or builtin.arch != builtin.Arch.x86_64) return; | 100 | if (builtin.os != builtin.Os.linux or builtin.arch != builtin.Arch.x86_64) return; |
| 101 | 101 | ||
| 102 | const example_zig_path = try os.path.join(a, dir_path, "example.zig"); | 102 | const example_zig_path = try os.path.join(a, [][]const u8{ dir_path, "example.zig" }); |
| 103 | const example_s_path = try os.path.join(a, dir_path, "example.s"); | 103 | const example_s_path = try os.path.join(a, [][]const u8{ dir_path, "example.s" }); |
| 104 | 104 | ||
| 105 | try std.io.writeFile(example_zig_path, | 105 | try std.io.writeFile(example_zig_path, |
| 106 | \\// Type your code here, or load an example. | 106 | \\// Type your code here, or load an example. |
test/tests.zig+11-11| ... | @@ -420,7 +420,7 @@ pub const CompareOutputContext = struct { | ... | @@ -420,7 +420,7 @@ pub const CompareOutputContext = struct { |
| 420 | pub fn addCase(self: *CompareOutputContext, case: TestCase) void { | 420 | pub fn addCase(self: *CompareOutputContext, case: TestCase) void { |
| 421 | const b = self.b; | 421 | const b = self.b; |
| 422 | 422 | ||
| 423 | const root_src = os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename) catch unreachable; | 423 | const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, case.sources.items[0].filename}) catch unreachable; |
| 424 | 424 | ||
| 425 | switch (case.special) { | 425 | switch (case.special) { |
| 426 | Special.Asm => { | 426 | Special.Asm => { |
| ... | @@ -433,7 +433,7 @@ pub const CompareOutputContext = struct { | ... | @@ -433,7 +433,7 @@ pub const CompareOutputContext = struct { |
| 433 | exe.addAssemblyFile(root_src); | 433 | exe.addAssemblyFile(root_src); |
| 434 | 434 | ||
| 435 | for (case.sources.toSliceConst()) |src_file| { | 435 | for (case.sources.toSliceConst()) |src_file| { |
| 436 | const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable; | 436 | const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; |
| 437 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); | 437 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 438 | exe.step.dependOn(&write_src.step); | 438 | exe.step.dependOn(&write_src.step); |
| 439 | } | 439 | } |
| ... | @@ -457,7 +457,7 @@ pub const CompareOutputContext = struct { | ... | @@ -457,7 +457,7 @@ pub const CompareOutputContext = struct { |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | for (case.sources.toSliceConst()) |src_file| { | 459 | for (case.sources.toSliceConst()) |src_file| { |
| 460 | const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable; | 460 | const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; |
| 461 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); | 461 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 462 | exe.step.dependOn(&write_src.step); | 462 | exe.step.dependOn(&write_src.step); |
| 463 | } | 463 | } |
| ... | @@ -480,7 +480,7 @@ pub const CompareOutputContext = struct { | ... | @@ -480,7 +480,7 @@ pub const CompareOutputContext = struct { |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | for (case.sources.toSliceConst()) |src_file| { | 482 | for (case.sources.toSliceConst()) |src_file| { |
| 483 | const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable; | 483 | const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; |
| 484 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); | 484 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 485 | exe.step.dependOn(&write_src.step); | 485 | exe.step.dependOn(&write_src.step); |
| 486 | } | 486 | } |
| ... | @@ -552,8 +552,8 @@ pub const CompileErrorContext = struct { | ... | @@ -552,8 +552,8 @@ pub const CompileErrorContext = struct { |
| 552 | const self = @fieldParentPtr(CompileCmpOutputStep, "step", step); | 552 | const self = @fieldParentPtr(CompileCmpOutputStep, "step", step); |
| 553 | const b = self.context.b; | 553 | const b = self.context.b; |
| 554 | 554 | ||
| 555 | const root_src = os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename) catch unreachable; | 555 | const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, self.case.sources.items[0].filename}) catch unreachable; |
| 556 | const obj_path = os.path.join(b.allocator, b.cache_root, "test.o") catch unreachable; | 556 | const obj_path = os.path.join(b.allocator, [][]const u8{b.cache_root, "test.o"}) catch unreachable; |
| 557 | 557 | ||
| 558 | var zig_args = ArrayList([]const u8).init(b.allocator); | 558 | var zig_args = ArrayList([]const u8).init(b.allocator); |
| 559 | zig_args.append(b.zig_exe) catch unreachable; | 559 | zig_args.append(b.zig_exe) catch unreachable; |
| ... | @@ -700,7 +700,7 @@ pub const CompileErrorContext = struct { | ... | @@ -700,7 +700,7 @@ pub const CompileErrorContext = struct { |
| 700 | self.step.dependOn(&compile_and_cmp_errors.step); | 700 | self.step.dependOn(&compile_and_cmp_errors.step); |
| 701 | 701 | ||
| 702 | for (case.sources.toSliceConst()) |src_file| { | 702 | for (case.sources.toSliceConst()) |src_file| { |
| 703 | const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable; | 703 | const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; |
| 704 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); | 704 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 705 | compile_and_cmp_errors.step.dependOn(&write_src.step); | 705 | compile_and_cmp_errors.step.dependOn(&write_src.step); |
| 706 | } | 706 | } |
| ... | @@ -830,7 +830,7 @@ pub const TranslateCContext = struct { | ... | @@ -830,7 +830,7 @@ pub const TranslateCContext = struct { |
| 830 | const self = @fieldParentPtr(TranslateCCmpOutputStep, "step", step); | 830 | const self = @fieldParentPtr(TranslateCCmpOutputStep, "step", step); |
| 831 | const b = self.context.b; | 831 | const b = self.context.b; |
| 832 | 832 | ||
| 833 | const root_src = os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename) catch unreachable; | 833 | const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, self.case.sources.items[0].filename}) catch unreachable; |
| 834 | 834 | ||
| 835 | var zig_args = ArrayList([]const u8).init(b.allocator); | 835 | var zig_args = ArrayList([]const u8).init(b.allocator); |
| 836 | zig_args.append(b.zig_exe) catch unreachable; | 836 | zig_args.append(b.zig_exe) catch unreachable; |
| ... | @@ -963,7 +963,7 @@ pub const TranslateCContext = struct { | ... | @@ -963,7 +963,7 @@ pub const TranslateCContext = struct { |
| 963 | self.step.dependOn(&translate_c_and_cmp.step); | 963 | self.step.dependOn(&translate_c_and_cmp.step); |
| 964 | 964 | ||
| 965 | for (case.sources.toSliceConst()) |src_file| { | 965 | for (case.sources.toSliceConst()) |src_file| { |
| 966 | const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable; | 966 | const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; |
| 967 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); | 967 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 968 | translate_c_and_cmp.step.dependOn(&write_src.step); | 968 | translate_c_and_cmp.step.dependOn(&write_src.step); |
| 969 | } | 969 | } |
| ... | @@ -1076,7 +1076,7 @@ pub const GenHContext = struct { | ... | @@ -1076,7 +1076,7 @@ pub const GenHContext = struct { |
| 1076 | 1076 | ||
| 1077 | pub fn addCase(self: *GenHContext, case: *const TestCase) void { | 1077 | pub fn addCase(self: *GenHContext, case: *const TestCase) void { |
| 1078 | const b = self.b; | 1078 | const b = self.b; |
| 1079 | const root_src = os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename) catch unreachable; | 1079 | const root_src = os.path.join(b.allocator, [][]const u8{b.cache_root, case.sources.items[0].filename}) catch unreachable; |
| 1080 | 1080 | ||
| 1081 | const mode = builtin.Mode.Debug; | 1081 | const mode = builtin.Mode.Debug; |
| 1082 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", case.name, @tagName(mode)) catch unreachable; | 1082 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", case.name, @tagName(mode)) catch unreachable; |
| ... | @@ -1088,7 +1088,7 @@ pub const GenHContext = struct { | ... | @@ -1088,7 +1088,7 @@ pub const GenHContext = struct { |
| 1088 | obj.setBuildMode(mode); | 1088 | obj.setBuildMode(mode); |
| 1089 | 1089 | ||
| 1090 | for (case.sources.toSliceConst()) |src_file| { | 1090 | for (case.sources.toSliceConst()) |src_file| { |
| 1091 | const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable; | 1091 | const expanded_src_path = os.path.join(b.allocator, [][]const u8{b.cache_root, src_file.filename}) catch unreachable; |
| 1092 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); | 1092 | const write_src = b.addWriteFile(expanded_src_path, src_file.source); |
| 1093 | obj.step.dependOn(&write_src.step); | 1093 | obj.step.dependOn(&write_src.step); |
| 1094 | } | 1094 | } |