| ... | @@ -3552,7 +3552,7 @@ fn buildOutputType( | ... | @@ -3552,7 +3552,7 @@ fn buildOutputType( |
| 3552 | if (test_exec_args.items.len == 0 and target.ofmt == .c) default_exec_args: { | 3552 | if (test_exec_args.items.len == 0 and target.ofmt == .c) default_exec_args: { |
| 3553 | // Default to using `zig run` to execute the produced .c code from `zig test`. | 3553 | // Default to using `zig run` to execute the produced .c code from `zig test`. |
| 3554 | const c_code_loc = emit_bin_loc orelse break :default_exec_args; | 3554 | const c_code_loc = emit_bin_loc orelse break :default_exec_args; |
| 3555 | const c_code_directory = c_code_loc.directory orelse comp.bin_file.options.emit.?.directory; | 3555 | const c_code_directory = c_code_loc.directory orelse comp.bin_file.?.emit.directory; |
| 3556 | const c_code_path = try fs.path.join(arena, &[_][]const u8{ | 3556 | const c_code_path = try fs.path.join(arena, &[_][]const u8{ |
| 3557 | c_code_directory.path orelse ".", c_code_loc.basename, | 3557 | c_code_directory.path orelse ".", c_code_loc.basename, |
| 3558 | }); | 3558 | }); |
| ... | @@ -3921,7 +3921,7 @@ fn serve( | ... | @@ -3921,7 +3921,7 @@ fn serve( |
| 3921 | continue; | 3921 | continue; |
| 3922 | } | 3922 | } |
| 3923 | | 3923 | |
| 3924 | if (comp.bin_file.options.output_mode == .Exe) { | 3924 | if (comp.config.output_mode == .Exe) { |
| 3925 | try comp.makeBinFileWritable(); | 3925 | try comp.makeBinFileWritable(); |
| 3926 | } | 3926 | } |
| 3927 | | 3927 | |
| ... | @@ -3971,7 +3971,7 @@ fn serve( | ... | @@ -3971,7 +3971,7 @@ fn serve( |
| 3971 | try comp.hotCodeSwap(main_progress_node, pid); | 3971 | try comp.hotCodeSwap(main_progress_node, pid); |
| 3972 | try serveUpdateResults(&server, comp); | 3972 | try serveUpdateResults(&server, comp); |
| 3973 | } else { | 3973 | } else { |
| 3974 | if (comp.bin_file.options.output_mode == .Exe) { | 3974 | if (comp.config.output_mode == .Exe) { |
| 3975 | try comp.makeBinFileWritable(); | 3975 | try comp.makeBinFileWritable(); |
| 3976 | } | 3976 | } |
| 3977 | try comp.update(main_progress_node); | 3977 | try comp.update(main_progress_node); |
| ... | @@ -4067,13 +4067,14 @@ fn serveUpdateResults(s: *Server, comp: *Compilation) !void { | ... | @@ -4067,13 +4067,14 @@ fn serveUpdateResults(s: *Server, comp: *Compilation) !void { |
| 4067 | // system depends on that fact. So, until the protocol is changed to | 4067 | // system depends on that fact. So, until the protocol is changed to |
| 4068 | // reflect this, this logic only needs to ensure that emit_bin_path is | 4068 | // reflect this, this logic only needs to ensure that emit_bin_path is |
| 4069 | // emitted for at least one thing, if there are any artifacts. | 4069 | // emitted for at least one thing, if there are any artifacts. |
| 4070 | if (comp.bin_file.options.emit) |emit| { | 4070 | if (comp.bin_file) |lf| { |
| | 4071 | const emit = lf.emit; |
| 4071 | const full_path = try emit.directory.join(gpa, &.{emit.sub_path}); | 4072 | const full_path = try emit.directory.join(gpa, &.{emit.sub_path}); |
| 4072 | defer gpa.free(full_path); | 4073 | defer gpa.free(full_path); |
| 4073 | try s.serveEmitBinPath(full_path, .{ | 4074 | try s.serveEmitBinPath(full_path, .{ |
| 4074 | .flags = .{ .cache_hit = comp.last_update_was_cache_hit }, | 4075 | .flags = .{ .cache_hit = comp.last_update_was_cache_hit }, |
| 4075 | }); | 4076 | }); |
| 4076 | } else if (comp.bin_file.options.docs_emit) |emit| { | 4077 | } else if (comp.docs_emit) |emit| { |
| 4077 | const full_path = try emit.directory.join(gpa, &.{emit.sub_path}); | 4078 | const full_path = try emit.directory.join(gpa, &.{emit.sub_path}); |
| 4078 | defer gpa.free(full_path); | 4079 | defer gpa.free(full_path); |
| 4079 | try s.serveEmitBinPath(full_path, .{ | 4080 | try s.serveEmitBinPath(full_path, .{ |
| ... | @@ -4148,11 +4149,11 @@ fn runOrTest( | ... | @@ -4148,11 +4149,11 @@ fn runOrTest( |
| 4148 | runtime_args_start: ?usize, | 4149 | runtime_args_start: ?usize, |
| 4149 | link_libc: bool, | 4150 | link_libc: bool, |
| 4150 | ) !void { | 4151 | ) !void { |
| 4151 | const exe_emit = comp.bin_file.options.emit orelse return; | 4152 | const lf = comp.bin_file orelse return; |
| 4152 | // A naive `directory.join` here will indeed get the correct path to the binary, | 4153 | // A naive `directory.join` here will indeed get the correct path to the binary, |
| 4153 | // however, in the case of cwd, we actually want `./foo` so that the path can be executed. | 4154 | // however, in the case of cwd, we actually want `./foo` so that the path can be executed. |
| 4154 | const exe_path = try fs.path.join(arena, &[_][]const u8{ | 4155 | const exe_path = try fs.path.join(arena, &[_][]const u8{ |
| 4155 | exe_emit.directory.path orelse ".", exe_emit.sub_path, | 4156 | lf.emit.directory.path orelse ".", lf.emit.sub_path, |
| 4156 | }); | 4157 | }); |
| 4157 | | 4158 | |
| 4158 | var argv = std.ArrayList([]const u8).init(gpa); | 4159 | var argv = std.ArrayList([]const u8).init(gpa); |
| ... | @@ -4244,7 +4245,7 @@ fn runOrTestHotSwap( | ... | @@ -4244,7 +4245,7 @@ fn runOrTestHotSwap( |
| 4244 | all_args: []const []const u8, | 4245 | all_args: []const []const u8, |
| 4245 | runtime_args_start: ?usize, | 4246 | runtime_args_start: ?usize, |
| 4246 | ) !std.ChildProcess.Id { | 4247 | ) !std.ChildProcess.Id { |
| 4247 | const exe_emit = comp.bin_file.options.emit.?; | 4248 | const lf = comp.bin_file.?; |
| 4248 | | 4249 | |
| 4249 | const exe_path = switch (builtin.target.os.tag) { | 4250 | const exe_path = switch (builtin.target.os.tag) { |
| 4250 | // On Windows it seems impossible to perform an atomic rename of a file that is currently | 4251 | // On Windows it seems impossible to perform an atomic rename of a file that is currently |
| ... | @@ -4252,16 +4253,16 @@ fn runOrTestHotSwap( | ... | @@ -4252,16 +4253,16 @@ fn runOrTestHotSwap( |
| 4252 | // tmp zig-cache and use it to spawn the child process. This way we are free to update | 4253 | // tmp zig-cache and use it to spawn the child process. This way we are free to update |
| 4253 | // the binary with each requested hot update. | 4254 | // the binary with each requested hot update. |
| 4254 | .windows => blk: { | 4255 | .windows => blk: { |
| 4255 | try exe_emit.directory.handle.copyFile(exe_emit.sub_path, comp.local_cache_directory.handle, exe_emit.sub_path, .{}); | 4256 | try lf.emit.directory.handle.copyFile(lf.emit.sub_path, comp.local_cache_directory.handle, lf.emit.sub_path, .{}); |
| 4256 | break :blk try fs.path.join(gpa, &[_][]const u8{ | 4257 | break :blk try fs.path.join(gpa, &[_][]const u8{ |
| 4257 | comp.local_cache_directory.path orelse ".", exe_emit.sub_path, | 4258 | comp.local_cache_directory.path orelse ".", lf.emit.sub_path, |
| 4258 | }); | 4259 | }); |
| 4259 | }, | 4260 | }, |
| 4260 | | 4261 | |
| 4261 | // A naive `directory.join` here will indeed get the correct path to the binary, | 4262 | // A naive `directory.join` here will indeed get the correct path to the binary, |
| 4262 | // however, in the case of cwd, we actually want `./foo` so that the path can be executed. | 4263 | // however, in the case of cwd, we actually want `./foo` so that the path can be executed. |
| 4263 | else => try fs.path.join(gpa, &[_][]const u8{ | 4264 | else => try fs.path.join(gpa, &[_][]const u8{ |
| 4264 | exe_emit.directory.path orelse ".", exe_emit.sub_path, | 4265 | lf.emit.directory.path orelse ".", lf.emit.sub_path, |
| 4265 | }), | 4266 | }), |
| 4266 | }; | 4267 | }; |
| 4267 | defer gpa.free(exe_path); | 4268 | defer gpa.free(exe_path); |
| ... | @@ -4367,7 +4368,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati | ... | @@ -4367,7 +4368,7 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, fancy_output: ?*Compilati |
| 4367 | assert(comp.c_source_files.len == 1); | 4368 | assert(comp.c_source_files.len == 1); |
| 4368 | const c_source_file = comp.c_source_files[0]; | 4369 | const c_source_file = comp.c_source_files[0]; |
| 4369 | | 4370 | |
| 4370 | const translated_zig_basename = try std.fmt.allocPrint(arena, "{s}.zig", .{comp.bin_file.options.root_name}); | 4371 | const translated_zig_basename = try std.fmt.allocPrint(arena, "{s}.zig", .{comp.root_name}); |
| 4371 | | 4372 | |
| 4372 | var man: Cache.Manifest = comp.obtainCObjectCacheManifest(); | 4373 | var man: Cache.Manifest = comp.obtainCObjectCacheManifest(); |
| 4373 | man.want_shared_lock = false; | 4374 | man.want_shared_lock = false; |
| ... | @@ -5450,11 +5451,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi | ... | @@ -5450,11 +5451,8 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 5450 | }; | 5451 | }; |
| 5451 | try comp.makeBinFileExecutable(); | 5452 | try comp.makeBinFileExecutable(); |
| 5452 | | 5453 | |
| 5453 | const emit = comp.bin_file.options.emit.?; | 5454 | const emit = comp.bin_file.?.emit; |
| 5454 | child_argv.items[argv_index_exe] = try emit.directory.join( | 5455 | child_argv.items[argv_index_exe] = try emit.directory.join(arena, &.{emit.sub_path}); |
| 5455 | arena, | | |
| 5456 | &[_][]const u8{emit.sub_path}, | | |
| 5457 | ); | | |
| 5458 | | 5456 | |
| 5459 | break :argv child_argv.items; | 5457 | break :argv child_argv.items; |
| 5460 | }; | 5458 | }; |