| ... | ... | @@ -207,6 +207,7 @@ pub fn make( |
| 207 | 207 | var owned_files: std.bit_set.Dynamic = .{}; |
| 208 | 208 | var inherit_files: std.ArrayList(Io.File) = .empty; |
| 209 | 209 | var protocol_args: std.ArrayList(u8) = .empty; |
| 210 | var input_dirs: std.ArrayList(Cache.Path) = .empty; |
| 210 | 211 | defer { |
| 211 | 212 | for (inherit_dirs.items, 0..) |inherit_dir, inherit_dir_index| |
| 212 | 213 | if (owned_dirs.isSet(inherit_dir_index)) inherit_dir.close(io); |
| ... | ... | @@ -217,6 +218,7 @@ pub fn make( |
| 217 | 218 | owned_files.deinit(gpa); |
| 218 | 219 | inherit_files.deinit(gpa); |
| 219 | 220 | protocol_args.deinit(gpa); |
| 221 | input_dirs.deinit(gpa); |
| 220 | 222 | } |
| 221 | 223 | switch (conf_run.flags.stdio) { |
| 222 | 224 | .infer_from_args, .inherit, .check => {}, |
| ... | ... | @@ -228,257 +230,264 @@ pub fn make( |
| 228 | 230 | argv_list.appendAssumeCapacity(try arena.print("--seed=0x{x}", .{graph.random_seed})); |
| 229 | 231 | argv_list.appendAssumeCapacity("--listen=-"); |
| 230 | 232 | }, |
| 231 | | .protocol => for (conf_run.args.slice[1..]) |arg_index| { |
| 232 | | const arg = arg_index.get(conf); |
| 233 | | switch (arg.flags.tag) { |
| 234 | | .string => { |
| 235 | | const string = arg.prefix.value.?.slice(conf); |
| 236 | | |
| 237 | | man.hash.addBytesZ(string); |
| 238 | | |
| 239 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + string.len + 1); |
| 240 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.string)); |
| 241 | | protocol_args.appendSliceAssumeCapacity(string); |
| 242 | | protocol_args.appendAssumeCapacity(0); |
| 243 | | }, |
| 244 | | .path_file => { |
| 245 | | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 246 | | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 247 | | const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index); |
| 248 | | |
| 249 | | try owned_files.resize(gpa, owned_files.bit_length + 1, true); |
| 250 | | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 251 | | const file = file_path.root_dir.handle.openFile(io, file_path.sub_path, .{}) catch |err| |
| 252 | | return step.fail(maker, "unable to open input file {qf}: {t}", .{ file_path, err }); |
| 253 | | inherit_files.appendAssumeCapacity(file); |
| 254 | | |
| 255 | | man.hash.addBytesZ(prefix); |
| 256 | | _ = try man.addInputPath(file_path, .{}); |
| 257 | | man.hash.addBytesZ(suffix); |
| 258 | | |
| 259 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 260 | | 1 + @sizeOf(Io.File.Handle) + |
| 261 | | 1 + suffix.len + 1); |
| 262 | | if (prefix.len > 0) { |
| 263 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 264 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 265 | | protocol_args.appendAssumeCapacity(0); |
| 266 | | } |
| 267 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_file)); |
| 268 | | const file_handle: *align(1) Io.File.Handle = |
| 269 | | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle))); |
| 270 | | file_handle.* = file.handle; |
| 271 | | if (suffix.len > 0) { |
| 272 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 273 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 274 | | protocol_args.appendAssumeCapacity(0); |
| 275 | | } |
| 276 | | }, |
| 277 | | .path_directory => { |
| 278 | | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 279 | | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 280 | | const dir_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index); |
| 281 | | |
| 282 | | const has_sub_path = dir_path.sub_path.len > 0; |
| 283 | | try owned_dirs.resize(gpa, owned_dirs.bit_length + 1, has_sub_path); |
| 284 | | try inherit_dirs.ensureUnusedCapacity(gpa, 1); |
| 285 | | const dir = if (has_sub_path) |
| 286 | | dir_path.root_dir.handle.openDir(io, dir_path.sub_path, .{ |
| 287 | | .iterate = true, |
| 288 | | }) catch |err| return step.fail(maker, "unable to open input dir {qf}: {t}", .{ dir_path, err }) |
| 289 | | else |
| 290 | | dir_path.root_dir.handle; |
| 291 | | inherit_dirs.appendAssumeCapacity(dir); |
| 292 | | |
| 293 | | man.hash.addBytesZ(prefix); |
| 294 | | man.hash.addOptionalBytes(dir_path.root_dir.path); |
| 295 | | man.hash.addBytes(dir_path.sub_path); |
| 296 | | man.hash.addBytesZ(suffix); |
| 297 | | |
| 298 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 299 | | 1 + @sizeOf(Io.Dir.Handle) + |
| 300 | | 1 + suffix.len + 1); |
| 301 | | if (prefix.len > 0) { |
| 302 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 303 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 304 | | protocol_args.appendAssumeCapacity(0); |
| 305 | | } |
| 306 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_dir)); |
| 307 | | const dir_handle: *align(1) Io.Dir.Handle = |
| 308 | | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.Dir.Handle))); |
| 309 | | dir_handle.* = dir.handle; |
| 310 | | if (suffix.len > 0) { |
| 311 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 312 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 313 | | protocol_args.appendAssumeCapacity(0); |
| 314 | | } |
| 315 | | }, |
| 316 | | .file_content => { |
| 317 | | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 318 | | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 319 | | const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index); |
| 320 | | |
| 321 | | try owned_files.resize(gpa, owned_files.bit_length + 1, true); |
| 322 | | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 323 | | const file = file_path.root_dir.handle.openFile(io, file_path.sub_path, .{}) catch |err| |
| 324 | | return step.fail(maker, "unable to open input file {qf}: {t}", .{ file_path, err }); |
| 325 | | inherit_files.appendAssumeCapacity(file); |
| 326 | | |
| 327 | | man.hash.addBytesZ(prefix); |
| 328 | | _ = try man.addInputPath(file_path, .{}); |
| 329 | | man.hash.addBytesZ(suffix); |
| 330 | | |
| 331 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 332 | | 1 + @sizeOf(Io.File.Handle) + |
| 333 | | 1 + suffix.len + 1); |
| 334 | | if (prefix.len > 0) { |
| 335 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 336 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 337 | | protocol_args.appendAssumeCapacity(0); |
| 338 | | } |
| 339 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_file_content)); |
| 340 | | const file_handle: *align(1) Io.File.Handle = |
| 341 | | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle))); |
| 342 | | file_handle.* = file.handle; |
| 343 | | if (suffix.len > 0) { |
| 344 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 345 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 346 | | protocol_args.appendAssumeCapacity(0); |
| 347 | | } |
| 348 | | }, |
| 349 | | .artifact => { |
| 350 | | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 351 | | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 352 | | const producer_index = arg.producer.value.?; |
| 353 | | const producer_step = producer_index.ptr(conf); |
| 354 | | const producer = producer_step.extended.get(conf.extra).compile; |
| 355 | | const producer_make_comp_step = maker.stepByIndex(producer_index); |
| 356 | | const producer_make_comp = &producer_make_comp_step.extended.compile; |
| 357 | | |
| 358 | | const file_path = producer_make_comp.installed_path orelse |
| 359 | | maker.generatedPath(producer.generated_bin.value.?); |
| 360 | | |
| 361 | | try owned_files.resize(gpa, owned_files.bit_length + 1, true); |
| 362 | | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 363 | | const file = file_path.root_dir.handle.openFile(io, file_path.sub_path, .{}) catch |err| |
| 364 | | return step.fail(maker, "unable to open input artifact {qf}: {t}", .{ file_path, err }); |
| 365 | | inherit_files.appendAssumeCapacity(file); |
| 366 | | |
| 367 | | man.hash.addBytesZ(prefix); |
| 368 | | _ = try man.addInputPath(file_path, .{}); |
| 369 | | man.hash.addBytesZ(suffix); |
| 370 | | |
| 371 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 372 | | 1 + @sizeOf(Io.File.Handle) + |
| 373 | | 1 + suffix.len + 1); |
| 374 | | if (prefix.len > 0) { |
| 375 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 376 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 377 | | protocol_args.appendAssumeCapacity(0); |
| 378 | | } |
| 379 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_file)); |
| 380 | | const file_handle: *align(1) Io.File.Handle = |
| 381 | | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle))); |
| 382 | | file_handle.* = file.handle; |
| 383 | | if (suffix.len > 0) { |
| 384 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 385 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 386 | | protocol_args.appendAssumeCapacity(0); |
| 387 | | } |
| 388 | | }, |
| 389 | | .output_file => { |
| 390 | | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 391 | | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 392 | | const basename = arg.basename.value.?.slice(conf); |
| 393 | | |
| 394 | | man.hash.addBytesZ(prefix); |
| 395 | | man.hash.addBytesZ(basename); |
| 396 | | man.hash.addBytesZ(suffix); |
| 397 | | assert(!arg.flags.dep_file); |
| 398 | | |
| 399 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 400 | | 1 + @sizeOf(Io.File.Handle) + |
| 401 | | 1 + suffix.len + 1); |
| 402 | | if (prefix.len > 0) { |
| 403 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 404 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 405 | | protocol_args.appendAssumeCapacity(0); |
| 406 | | } |
| 407 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.output_file)); |
| 408 | | |
| 409 | | // Add a placeholder into the argument list because we need the |
| 410 | | // manifest hash to be updated with all arguments before the |
| 411 | | // object directory is computed. |
| 412 | | try owned_files.resize(gpa, owned_files.bit_length + 1, false); |
| 413 | | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 414 | | try output_placeholders.append(gpa, .{ |
| 415 | | .index = @intCast(inherit_files.items.len), |
| 416 | | .offset = @intCast(protocol_args.items.len), |
| 417 | | .arg_index = arg_index, |
| 418 | | }); |
| 419 | | _ = inherit_files.addOneAssumeCapacity(); |
| 420 | | |
| 421 | | _ = protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle)); |
| 422 | | if (suffix.len > 0) { |
| 423 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 424 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 425 | | protocol_args.appendAssumeCapacity(0); |
| 426 | | } |
| 427 | | }, |
| 428 | | .output_directory => { |
| 429 | | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 430 | | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 431 | | const basename = arg.basename.value.?.slice(conf); |
| 432 | | |
| 433 | | man.hash.addBytesZ(prefix); |
| 434 | | man.hash.addBytesZ(basename); |
| 435 | | man.hash.addBytesZ(suffix); |
| 436 | | assert(!arg.flags.dep_file); |
| 437 | | |
| 438 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 439 | | 1 + @sizeOf(Io.Dir.Handle) + |
| 440 | | 1 + suffix.len + 1); |
| 441 | | if (prefix.len > 0) { |
| 442 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 443 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 233 | .protocol => { |
| 234 | try input_dirs.append(gpa, if (conf_run.cwd.value) |lazy_cwd| |
| 235 | try maker.resolveLazyPathIndex(arena, lazy_cwd, run_index) |
| 236 | else |
| 237 | .cwd()); |
| 238 | for (conf_run.args.slice[1..]) |arg_index| { |
| 239 | const arg = arg_index.get(conf); |
| 240 | switch (arg.flags.tag) { |
| 241 | .string => { |
| 242 | const string = arg.prefix.value.?.slice(conf); |
| 243 | |
| 244 | man.hash.addBytesZ(string); |
| 245 | |
| 246 | try protocol_args.ensureUnusedCapacity(gpa, 1 + string.len + 1); |
| 247 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.string)); |
| 248 | protocol_args.appendSliceAssumeCapacity(string); |
| 444 | 249 | protocol_args.appendAssumeCapacity(0); |
| 445 | | } |
| 446 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.output_dir)); |
| 447 | | |
| 448 | | // Add a placeholder into the argument list because we need the |
| 449 | | // manifest hash to be updated with all arguments before the |
| 450 | | // object directory is computed. |
| 451 | | try owned_dirs.resize(gpa, owned_dirs.bit_length + 1, false); |
| 452 | | try inherit_dirs.ensureUnusedCapacity(gpa, 1); |
| 453 | | try output_placeholders.append(gpa, .{ |
| 454 | | .index = @intCast(inherit_dirs.items.len), |
| 455 | | .offset = @intCast(protocol_args.items.len), |
| 456 | | .arg_index = arg_index, |
| 457 | | }); |
| 458 | | _ = inherit_dirs.addOneAssumeCapacity(); |
| 250 | }, |
| 251 | .path_file => { |
| 252 | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 253 | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 254 | const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index); |
| 255 | |
| 256 | try owned_files.resize(gpa, owned_files.bit_length + 1, true); |
| 257 | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 258 | const file = file_path.root_dir.handle.openFile(io, file_path.sub_path, .{}) catch |err| |
| 259 | return step.fail(maker, "unable to open input file {qf}: {t}", .{ file_path, err }); |
| 260 | inherit_files.appendAssumeCapacity(file); |
| 261 | |
| 262 | man.hash.addBytesZ(prefix); |
| 263 | _ = try man.addInputPath(file_path, .{}); |
| 264 | man.hash.addBytesZ(suffix); |
| 265 | |
| 266 | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 267 | 1 + @sizeOf(Io.File.Handle) + |
| 268 | 1 + suffix.len + 1); |
| 269 | if (prefix.len > 0) { |
| 270 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 271 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 272 | protocol_args.appendAssumeCapacity(0); |
| 273 | } |
| 274 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_file)); |
| 275 | const file_handle: *align(1) Io.File.Handle = |
| 276 | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle))); |
| 277 | file_handle.* = file.handle; |
| 278 | if (suffix.len > 0) { |
| 279 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 280 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 281 | protocol_args.appendAssumeCapacity(0); |
| 282 | } |
| 283 | }, |
| 284 | .path_directory => { |
| 285 | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 286 | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 287 | const dir_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index); |
| 288 | try input_dirs.append(gpa, dir_path); |
| 289 | |
| 290 | const has_sub_path = dir_path.sub_path.len > 0; |
| 291 | try owned_dirs.resize(gpa, owned_dirs.bit_length + 1, has_sub_path); |
| 292 | try inherit_dirs.ensureUnusedCapacity(gpa, 1); |
| 293 | const dir = if (has_sub_path) |
| 294 | dir_path.root_dir.handle.openDir(io, dir_path.sub_path, .{ |
| 295 | .iterate = true, |
| 296 | }) catch |err| return step.fail(maker, "unable to open input dir {qf}: {t}", .{ dir_path, err }) |
| 297 | else |
| 298 | dir_path.root_dir.handle; |
| 299 | inherit_dirs.appendAssumeCapacity(dir); |
| 300 | |
| 301 | man.hash.addBytesZ(prefix); |
| 302 | man.hash.addOptionalBytes(dir_path.root_dir.path); |
| 303 | man.hash.addBytes(dir_path.sub_path); |
| 304 | man.hash.addBytesZ(suffix); |
| 305 | |
| 306 | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 307 | 1 + @sizeOf(Io.Dir.Handle) + |
| 308 | 1 + suffix.len + 1); |
| 309 | if (prefix.len > 0) { |
| 310 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 311 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 312 | protocol_args.appendAssumeCapacity(0); |
| 313 | } |
| 314 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_dir)); |
| 315 | const dir_handle: *align(1) Io.Dir.Handle = |
| 316 | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.Dir.Handle))); |
| 317 | dir_handle.* = dir.handle; |
| 318 | if (suffix.len > 0) { |
| 319 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 320 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 321 | protocol_args.appendAssumeCapacity(0); |
| 322 | } |
| 323 | }, |
| 324 | .file_content => { |
| 325 | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 326 | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 327 | const file_path = try maker.resolveLazyPathIndex(arena, arg.path.value.?, run_index); |
| 328 | |
| 329 | try owned_files.resize(gpa, owned_files.bit_length + 1, true); |
| 330 | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 331 | const file = file_path.root_dir.handle.openFile(io, file_path.sub_path, .{}) catch |err| |
| 332 | return step.fail(maker, "unable to open input file {qf}: {t}", .{ file_path, err }); |
| 333 | inherit_files.appendAssumeCapacity(file); |
| 334 | |
| 335 | man.hash.addBytesZ(prefix); |
| 336 | _ = try man.addInputPath(file_path, .{}); |
| 337 | man.hash.addBytesZ(suffix); |
| 338 | |
| 339 | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 340 | 1 + @sizeOf(Io.File.Handle) + |
| 341 | 1 + suffix.len + 1); |
| 342 | if (prefix.len > 0) { |
| 343 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 344 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 345 | protocol_args.appendAssumeCapacity(0); |
| 346 | } |
| 347 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_file_content)); |
| 348 | const file_handle: *align(1) Io.File.Handle = |
| 349 | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle))); |
| 350 | file_handle.* = file.handle; |
| 351 | if (suffix.len > 0) { |
| 352 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 353 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 354 | protocol_args.appendAssumeCapacity(0); |
| 355 | } |
| 356 | }, |
| 357 | .artifact => { |
| 358 | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 359 | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 360 | const producer_index = arg.producer.value.?; |
| 361 | const producer_step = producer_index.ptr(conf); |
| 362 | const producer = producer_step.extended.get(conf.extra).compile; |
| 363 | const producer_make_comp_step = maker.stepByIndex(producer_index); |
| 364 | const producer_make_comp = &producer_make_comp_step.extended.compile; |
| 365 | |
| 366 | const file_path = producer_make_comp.installed_path orelse |
| 367 | maker.generatedPath(producer.generated_bin.value.?); |
| 368 | |
| 369 | try owned_files.resize(gpa, owned_files.bit_length + 1, true); |
| 370 | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 371 | const file = file_path.root_dir.handle.openFile(io, file_path.sub_path, .{}) catch |err| |
| 372 | return step.fail(maker, "unable to open input artifact {qf}: {t}", .{ file_path, err }); |
| 373 | inherit_files.appendAssumeCapacity(file); |
| 374 | |
| 375 | man.hash.addBytesZ(prefix); |
| 376 | _ = try man.addInputPath(file_path, .{}); |
| 377 | man.hash.addBytesZ(suffix); |
| 378 | |
| 379 | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 380 | 1 + @sizeOf(Io.File.Handle) + |
| 381 | 1 + suffix.len + 1); |
| 382 | if (prefix.len > 0) { |
| 383 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 384 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 385 | protocol_args.appendAssumeCapacity(0); |
| 386 | } |
| 387 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.input_file)); |
| 388 | const file_handle: *align(1) Io.File.Handle = |
| 389 | @ptrCast(protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle))); |
| 390 | file_handle.* = file.handle; |
| 391 | if (suffix.len > 0) { |
| 392 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 393 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 394 | protocol_args.appendAssumeCapacity(0); |
| 395 | } |
| 396 | }, |
| 397 | .output_file => { |
| 398 | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 399 | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 400 | const basename = arg.basename.value.?.slice(conf); |
| 401 | |
| 402 | man.hash.addBytesZ(prefix); |
| 403 | man.hash.addBytesZ(basename); |
| 404 | man.hash.addBytesZ(suffix); |
| 405 | assert(!arg.flags.dep_file); |
| 406 | |
| 407 | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 408 | 1 + @sizeOf(Io.File.Handle) + |
| 409 | 1 + suffix.len + 1); |
| 410 | if (prefix.len > 0) { |
| 411 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 412 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 413 | protocol_args.appendAssumeCapacity(0); |
| 414 | } |
| 415 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.output_file)); |
| 416 | |
| 417 | // Add a placeholder into the argument list because we need the |
| 418 | // manifest hash to be updated with all arguments before the |
| 419 | // object directory is computed. |
| 420 | try owned_files.resize(gpa, owned_files.bit_length + 1, false); |
| 421 | try inherit_files.ensureUnusedCapacity(gpa, 1); |
| 422 | try output_placeholders.append(gpa, .{ |
| 423 | .index = @intCast(inherit_files.items.len), |
| 424 | .offset = @intCast(protocol_args.items.len), |
| 425 | .arg_index = arg_index, |
| 426 | }); |
| 427 | _ = inherit_files.addOneAssumeCapacity(); |
| 459 | 428 | |
| 460 | | _ = protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.Dir.Handle)); |
| 461 | | if (suffix.len > 0) { |
| 462 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 463 | | protocol_args.appendSliceAssumeCapacity(prefix); |
| 464 | | protocol_args.appendAssumeCapacity(0); |
| 465 | | } |
| 466 | | }, |
| 467 | | .passthru => if (maker.run_args) |run_args| { |
| 468 | | man.hash.addListOfBytes(run_args); |
| 429 | _ = protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.File.Handle)); |
| 430 | if (suffix.len > 0) { |
| 431 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 432 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 433 | protocol_args.appendAssumeCapacity(0); |
| 434 | } |
| 435 | }, |
| 436 | .output_directory => { |
| 437 | const prefix = if (arg.prefix.value) |p| p.slice(conf) else ""; |
| 438 | const suffix = if (arg.suffix.value) |p| p.slice(conf) else ""; |
| 439 | const basename = arg.basename.value.?.slice(conf); |
| 440 | |
| 441 | man.hash.addBytesZ(prefix); |
| 442 | man.hash.addBytesZ(basename); |
| 443 | man.hash.addBytesZ(suffix); |
| 444 | assert(!arg.flags.dep_file); |
| 445 | |
| 446 | try protocol_args.ensureUnusedCapacity(gpa, 1 + prefix.len + 1 + |
| 447 | 1 + @sizeOf(Io.Dir.Handle) + |
| 448 | 1 + suffix.len + 1); |
| 449 | if (prefix.len > 0) { |
| 450 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.prefix)); |
| 451 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 452 | protocol_args.appendAssumeCapacity(0); |
| 453 | } |
| 454 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.output_dir)); |
| 455 | |
| 456 | // Add a placeholder into the argument list because we need the |
| 457 | // manifest hash to be updated with all arguments before the |
| 458 | // object directory is computed. |
| 459 | try owned_dirs.resize(gpa, owned_dirs.bit_length + 1, false); |
| 460 | try inherit_dirs.ensureUnusedCapacity(gpa, 1); |
| 461 | try output_placeholders.append(gpa, .{ |
| 462 | .index = @intCast(inherit_dirs.items.len), |
| 463 | .offset = @intCast(protocol_args.items.len), |
| 464 | .arg_index = arg_index, |
| 465 | }); |
| 466 | _ = inherit_dirs.addOneAssumeCapacity(); |
| 469 | 467 | |
| 470 | | for (run_args) |run_arg| { |
| 471 | | try protocol_args.ensureUnusedCapacity(gpa, 1 + run_arg.len + 1); |
| 472 | | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.string)); |
| 473 | | protocol_args.appendSliceAssumeCapacity(run_arg); |
| 474 | | protocol_args.appendAssumeCapacity(0); |
| 475 | | } |
| 476 | | }, |
| 477 | | .enable_darling => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_darling, arg.prefix.value, arg.suffix.value), |
| 478 | | .enable_qemu => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_qemu, arg.prefix.value, arg.suffix.value), |
| 479 | | .enable_rosetta => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_rosetta, arg.prefix.value, arg.suffix.value), |
| 480 | | .enable_wasmtime => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_wasmtime, arg.prefix.value, arg.suffix.value), |
| 481 | | .enable_wine => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_wine, arg.prefix.value, arg.suffix.value), |
| 468 | _ = protocol_args.addManyAsArrayAssumeCapacity(@sizeOf(Io.Dir.Handle)); |
| 469 | if (suffix.len > 0) { |
| 470 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.suffix)); |
| 471 | protocol_args.appendSliceAssumeCapacity(prefix); |
| 472 | protocol_args.appendAssumeCapacity(0); |
| 473 | } |
| 474 | }, |
| 475 | .passthru => if (maker.run_args) |run_args| { |
| 476 | man.hash.addListOfBytes(run_args); |
| 477 | |
| 478 | for (run_args) |run_arg| { |
| 479 | try protocol_args.ensureUnusedCapacity(gpa, 1 + run_arg.len + 1); |
| 480 | protocol_args.appendAssumeCapacity(@backingInt(std.zig.Client.Message.Arg.string)); |
| 481 | protocol_args.appendSliceAssumeCapacity(run_arg); |
| 482 | protocol_args.appendAssumeCapacity(0); |
| 483 | } |
| 484 | }, |
| 485 | .enable_darling => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_darling, arg.prefix.value, arg.suffix.value), |
| 486 | .enable_qemu => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_qemu, arg.prefix.value, arg.suffix.value), |
| 487 | .enable_rosetta => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_rosetta, arg.prefix.value, arg.suffix.value), |
| 488 | .enable_wasmtime => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_wasmtime, arg.prefix.value, arg.suffix.value), |
| 489 | .enable_wine => try thirdPartyToggleProtocol(gpa, &man.hash, &protocol_args, conf, graph.enable_wine, arg.prefix.value, arg.suffix.value), |
| 490 | } |
| 482 | 491 | } |
| 483 | 492 | }, |
| 484 | 493 | } |
| ... | ... | @@ -561,7 +570,7 @@ pub fn make( |
| 561 | 570 | .args = protocol_args.items, |
| 562 | 571 | } }, |
| 563 | 572 | }); |
| 564 | | try runCommand(arena, run, run_index, maker, progress_node, argv_list.items, inherit_dirs.items, inherit_files.items, protocol_args.items, has_side_effects, output_dir_path, null); |
| 573 | try runCommand(arena, run, run_index, maker, progress_node, argv_list.items, &.{}, &.{}, &.{}, &.{}, null, has_side_effects, output_dir_path, null); |
| 565 | 574 | if (!has_side_effects) try step.finalizeManifestAndWatch(maker, &man); |
| 566 | 575 | return; |
| 567 | 576 | } |
| ... | ... | @@ -581,7 +590,22 @@ pub fn make( |
| 581 | 590 | .args = protocol_args.items, |
| 582 | 591 | } }, |
| 583 | 592 | }); |
| 584 | | try runCommand(arena, run, run_index, maker, progress_node, argv_list.items, inherit_dirs.items, inherit_files.items, protocol_args.items, has_side_effects, tmp_dir_path, null); |
| 593 | try runCommand( |
| 594 | arena, |
| 595 | run, |
| 596 | run_index, |
| 597 | maker, |
| 598 | progress_node, |
| 599 | argv_list.items, |
| 600 | inherit_dirs.items, |
| 601 | inherit_files.items, |
| 602 | protocol_args.items, |
| 603 | input_dirs.items, |
| 604 | &man, |
| 605 | has_side_effects, |
| 606 | tmp_dir_path, |
| 607 | null, |
| 608 | ); |
| 585 | 609 | |
| 586 | 610 | for (output_placeholders.items) |placeholder| { |
| 587 | 611 | const arg = placeholder.arg_index.get(conf); |
| ... | ... | @@ -720,6 +744,8 @@ fn waitZigTest( |
| 720 | 744 | child: *process.Child, |
| 721 | 745 | progress_node: std.Progress.Node, |
| 722 | 746 | protocol_args: []const u8, |
| 747 | input_dirs: []const Cache.Path, |
| 748 | man: ?*Cache.Manifest, |
| 723 | 749 | multi_reader: *Io.File.MultiReader, |
| 724 | 750 | opt_metadata: *?TestMetadata, |
| 725 | 751 | results: *Step.TestResults, |
| ... | ... | @@ -900,6 +926,16 @@ fn waitZigTest( |
| 900 | 926 | |
| 901 | 927 | requestNextTest(&client, md, &sub_prog_node) catch |err| return .{ .write_failed = err }; |
| 902 | 928 | }, |
| 929 | .discovered_inputs => while (body_r.takeEnum( |
| 930 | std.zig.Server.Message.InputDir, |
| 931 | .little, |
| 932 | )) |input_dir| try man.?.addDiscoveredPath(.{ .discovered_path = .{ |
| 933 | .unresolved = try input_dirs[@backingInt(input_dir)] |
| 934 | .join(arena, try body_r.takeSentinel(0)), |
| 935 | } }) else |err| switch (err) { |
| 936 | else => |e| return e, |
| 937 | error.EndOfStream => {}, |
| 938 | }, |
| 903 | 939 | } |
| 904 | 940 | } |
| 905 | 941 | } |
| ... | ... | @@ -1463,6 +1499,8 @@ fn evalZigTest( |
| 1463 | 1499 | progress_node: std.Progress.Node, |
| 1464 | 1500 | spawn_options: process.SpawnOptions, |
| 1465 | 1501 | protocol_args: []const u8, |
| 1502 | input_dirs: []const Cache.Path, |
| 1503 | man: ?*Cache.Manifest, |
| 1466 | 1504 | fuzz_context: ?FuzzContext, |
| 1467 | 1505 | ) !void { |
| 1468 | 1506 | if (fuzz_context != null) { |
| ... | ... | @@ -1512,6 +1550,8 @@ fn evalZigTest( |
| 1512 | 1550 | &child, |
| 1513 | 1551 | progress_node, |
| 1514 | 1552 | protocol_args, |
| 1553 | input_dirs, |
| 1554 | man, |
| 1515 | 1555 | &multi_reader, |
| 1516 | 1556 | &test_metadata, |
| 1517 | 1557 | &test_results, |
| ... | ... | @@ -1932,7 +1972,7 @@ pub fn rerunInFuzzMode( |
| 1932 | 1972 | var rand_int: u64 = undefined; |
| 1933 | 1973 | io.random(@ptrCast(&rand_int)); |
| 1934 | 1974 | const tmp_dir_path = "tmp" ++ Dir.path.sep_str ++ std.fmt.hex(rand_int); |
| 1935 | | try runCommand(arena, run, run_index, maker, prog_node, argv_list.items, &.{}, &.{}, &.{}, has_side_effects, tmp_dir_path, .{ |
| 1975 | try runCommand(arena, run, run_index, maker, prog_node, argv_list.items, &.{}, &.{}, &.{}, &.{}, null, has_side_effects, tmp_dir_path, .{ |
| 1936 | 1976 | .fuzz = fuzz, |
| 1937 | 1977 | }); |
| 1938 | 1978 | } |
| ... | ... | @@ -2084,6 +2124,8 @@ fn runCommand( |
| 2084 | 2124 | inherit_dirs: []const Io.Dir, |
| 2085 | 2125 | inherit_files: []const Io.File, |
| 2086 | 2126 | protocol_args: []const u8, |
| 2127 | input_dirs: []const Cache.Path, |
| 2128 | man: ?*Cache.Manifest, |
| 2087 | 2129 | has_side_effects: bool, |
| 2088 | 2130 | output_dir_path: []const u8, |
| 2089 | 2131 | fuzz_context: ?FuzzContext, |
| ... | ... | @@ -2153,6 +2195,8 @@ fn runCommand( |
| 2153 | 2195 | inherit_dirs, |
| 2154 | 2196 | inherit_files, |
| 2155 | 2197 | protocol_args, |
| 2198 | input_dirs, |
| 2199 | man, |
| 2156 | 2200 | has_side_effects, |
| 2157 | 2201 | fuzz_context, |
| 2158 | 2202 | ) catch |err| term: { |
| ... | ... | @@ -2308,6 +2352,8 @@ fn runCommand( |
| 2308 | 2352 | inherit_dirs, |
| 2309 | 2353 | inherit_files, |
| 2310 | 2354 | protocol_args, |
| 2355 | input_dirs, |
| 2356 | man, |
| 2311 | 2357 | has_side_effects, |
| 2312 | 2358 | fuzz_context, |
| 2313 | 2359 | ) catch |e| { |
| ... | ... | @@ -2569,6 +2615,8 @@ fn spawnChildAndCollect( |
| 2569 | 2615 | inherit_dirs: []const Io.Dir, |
| 2570 | 2616 | inherit_files: []const Io.File, |
| 2571 | 2617 | protocol_args: []const u8, |
| 2618 | input_dirs: []const Cache.Path, |
| 2619 | man: ?*Cache.Manifest, |
| 2572 | 2620 | has_side_effects: bool, |
| 2573 | 2621 | fuzz_context: ?FuzzContext, |
| 2574 | 2622 | ) !?EvalGenericResult { |
| ... | ... | @@ -2675,7 +2723,17 @@ fn spawnChildAndCollect( |
| 2675 | 2723 | .zig_test, .protocol => { |
| 2676 | 2724 | try setColorEnvironmentVariables(&conf_run, environ_map, graph.stderr_mode.?); |
| 2677 | 2725 | const started: Io.Clock.Timestamp = .now(io, .awake); |
| 2678 | | const result = evalZigTest(run, run_index, maker, progress_node, spawn_options, protocol_args, fuzz_context) catch |err| switch (err) { |
| 2726 | const result = evalZigTest( |
| 2727 | run, |
| 2728 | run_index, |
| 2729 | maker, |
| 2730 | progress_node, |
| 2731 | spawn_options, |
| 2732 | protocol_args, |
| 2733 | input_dirs, |
| 2734 | man, |
| 2735 | fuzz_context, |
| 2736 | ) catch |err| switch (err) { |
| 2679 | 2737 | error.Canceled => |e| return e, |
| 2680 | 2738 | else => |e| e, |
| 2681 | 2739 | }; |