| author | |
| committer | |
| log | df4068cabd9af96d0aca1f435b985d1c103976da |
| tree | e4bb7429476548679a3ed9138bd25aac60681364 |
| parent | f5a327cd366348a739a282f380acd627815183b5 |
e.g. `x86_64-windows.win10...win11_dt-gnu` -> `x86_64-windows-gnu`
When the OS version is the default this is redundant with checking the
default in the standard library.9 files changed, 31 insertions(+), 21 deletions(-)
lib/std/Build.zig+8-1| ... | @@ -1164,7 +1164,14 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run { | ... | @@ -1164,7 +1164,14 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run { |
| 1164 | // It doesn't have to be native. We catch that if you actually try to run it. | 1164 | // It doesn't have to be native. We catch that if you actually try to run it. |
| 1165 | // Consider that this is declarative; the run step may not be run unless a user | 1165 | // Consider that this is declarative; the run step may not be run unless a user |
| 1166 | // option is supplied. | 1166 | // option is supplied. |
| 1167 | const run_step = Step.Run.create(b, b.fmt("run {s}", .{exe.name})); | 1167 | |
| 1168 | // Avoid the common case of the step name looking like "run test test". | ||
| 1169 | const step_name = if (exe.kind.isTest() and mem.eql(u8, exe.name, "test")) | ||
| 1170 | b.fmt("run {s}", .{@tagName(exe.kind)}) | ||
| 1171 | else | ||
| 1172 | b.fmt("run {s} {s}", .{ @tagName(exe.kind), exe.name }); | ||
| 1173 | |||
| 1174 | const run_step = Step.Run.create(b, step_name); | ||
| 1168 | run_step.producer = exe; | 1175 | run_step.producer = exe; |
| 1169 | if (exe.kind == .@"test") { | 1176 | if (exe.kind == .@"test") { |
| 1170 | if (exe.exec_cmd_args) |exec_cmd_args| { | 1177 | if (exe.exec_cmd_args) |exec_cmd_args| { |
lib/std/Build/Step/Compile.zig+13-9| ... | @@ -292,6 +292,13 @@ pub const Kind = enum { | ... | @@ -292,6 +292,13 @@ pub const Kind = enum { |
| 292 | obj, | 292 | obj, |
| 293 | @"test", | 293 | @"test", |
| 294 | test_obj, | 294 | test_obj, |
| 295 | |||
| 296 | pub fn isTest(kind: Kind) bool { | ||
| 297 | return switch (kind) { | ||
| 298 | .exe, .lib, .obj => false, | ||
| 299 | .@"test", .test_obj => true, | ||
| 300 | }; | ||
| 301 | } | ||
| 295 | }; | 302 | }; |
| 296 | 303 | ||
| 297 | pub const HeaderInstallation = union(enum) { | 304 | pub const HeaderInstallation = union(enum) { |
| ... | @@ -368,19 +375,16 @@ pub fn create(owner: *std.Build, options: Options) *Compile { | ... | @@ -368,19 +375,16 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 368 | panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name}); | 375 | panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name}); |
| 369 | } | 376 | } |
| 370 | 377 | ||
| 371 | // Avoid the common case of the step name looking like "zig test test". | ||
| 372 | const name_adjusted = if ((options.kind == .@"test" or options.kind == .test_obj) and mem.eql(u8, name, "test")) | ||
| 373 | "" | ||
| 374 | else | ||
| 375 | owner.fmt("{s} ", .{name}); | ||
| 376 | |||
| 377 | const resolved_target = options.root_module.resolved_target orelse | 378 | const resolved_target = options.root_module.resolved_target orelse |
| 378 | @panic("the root Module of a Compile step must be created with a known 'target' field"); | 379 | @panic("the root Module of a Compile step must be created with a known 'target' field"); |
| 379 | const target = resolved_target.result; | 380 | const target = resolved_target.result; |
| 380 | 381 | ||
| 381 | const step_name = owner.fmt("compile {s} {s}{s} {s}", .{ | 382 | const step_name = owner.fmt("compile {s} {s} {s}", .{ |
| 382 | @tagName(options.kind), | 383 | // Avoid the common case of the step name looking like "compile test test". |
| 383 | name_adjusted, | 384 | if (options.kind.isTest() and mem.eql(u8, name, "test")) |
| 385 | @tagName(options.kind) | ||
| 386 | else | ||
| 387 | owner.fmt("{s} {s}", .{ @tagName(options.kind), name }), | ||
| 384 | @tagName(options.root_module.optimize orelse .Debug), | 388 | @tagName(options.root_module.optimize orelse .Debug), |
| 385 | resolved_target.query.zigTriple(owner.allocator) catch @panic("OOM"), | 389 | resolved_target.query.zigTriple(owner.allocator) catch @panic("OOM"), |
| 386 | }); | 390 | }); |
test/behavior/x86_64/build.zig+3-4| ... | @@ -115,6 +115,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -115,6 +115,7 @@ pub fn build(b: *std.Build) void { |
| 115 | }, | 115 | }, |
| 116 | }) |query| { | 116 | }) |query| { |
| 117 | const target = b.resolveTargetQuery(query); | 117 | const target = b.resolveTargetQuery(query); |
| 118 | const triple = query.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 118 | const cpu = query.serializeCpuAlloc(b.allocator) catch @panic("OOM"); | 119 | const cpu = query.serializeCpuAlloc(b.allocator) catch @panic("OOM"); |
| 119 | for ([_][]const u8{ | 120 | for ([_][]const u8{ |
| 120 | "access.zig", | 121 | "access.zig", |
| ... | @@ -133,16 +134,14 @@ pub fn build(b: *std.Build) void { | ... | @@ -133,16 +134,14 @@ pub fn build(b: *std.Build) void { |
| 133 | .use_lld = false, | 134 | .use_lld = false, |
| 134 | .root_module = test_mod, | 135 | .root_module = test_mod, |
| 135 | }); | 136 | }); |
| 137 | test_exe.step.name = b.fmt("{s} {s}", .{ test_exe.step.name, cpu }); | ||
| 136 | if (!target.result.cpu.has(.x86, .sse2)) { | 138 | if (!target.result.cpu.has(.x86, .sse2)) { |
| 137 | test_exe.bundle_compiler_rt = false; | 139 | test_exe.bundle_compiler_rt = false; |
| 138 | test_mod.linkLibrary(compiler_rt_lib); | 140 | test_mod.linkLibrary(compiler_rt_lib); |
| 139 | } | 141 | } |
| 140 | const test_run = b.addRunArtifact(test_exe); | 142 | const test_run = b.addRunArtifact(test_exe); |
| 143 | test_run.step.name = b.fmt("{s} {s} {s}", .{ test_run.step.name, triple, cpu }); | ||
| 141 | b.default_step.dependOn(&test_run.step); | 144 | b.default_step.dependOn(&test_run.step); |
| 142 | for ([_]*std.Build.Step{ | ||
| 143 | &test_exe.step, | ||
| 144 | &test_run.step, | ||
| 145 | }) |step| step.name = b.fmt("{s} {s}", .{ step.name, cpu }); | ||
| 146 | } | 145 | } |
| 147 | } | 146 | } |
| 148 | } | 147 | } |
test/link/link.zig+1-1| ... | @@ -13,7 +13,7 @@ pub const Options = struct { | ... | @@ -13,7 +13,7 @@ pub const Options = struct { |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | pub fn addTestStep(b: *Build, prefix: []const u8, opts: Options) *Step { | 15 | pub fn addTestStep(b: *Build, prefix: []const u8, opts: Options) *Step { |
| 16 | const target = opts.target.result.zigTriple(b.allocator) catch @panic("OOM"); | 16 | const target = opts.target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 17 | const optimize = @tagName(opts.optimize); | 17 | const optimize = @tagName(opts.optimize); |
| 18 | const use_llvm = if (opts.use_llvm) "llvm" else "no-llvm"; | 18 | const use_llvm = if (opts.use_llvm) "llvm" else "no-llvm"; |
| 19 | const use_lld = if (opts.use_lld) "lld" else "no-lld"; | 19 | const use_lld = if (opts.use_lld) "lld" else "no-lld"; |
test/src/Cases.zig+1-1| ... | @@ -610,7 +610,7 @@ pub fn lowerToBuildSteps( | ... | @@ -610,7 +610,7 @@ pub fn lowerToBuildSteps( |
| 610 | if (std.mem.indexOf(u8, case.name, test_filter)) |_| break; | 610 | if (std.mem.indexOf(u8, case.name, test_filter)) |_| break; |
| 611 | } else if (test_filters.len > 0) continue; | 611 | } else if (test_filters.len > 0) continue; |
| 612 | 612 | ||
| 613 | const triple_txt = case.target.result.zigTriple(b.allocator) catch @panic("OOM"); | 613 | const triple_txt = case.target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 614 | 614 | ||
| 615 | if (test_target_filters.len > 0) { | 615 | if (test_target_filters.len > 0) { |
| 616 | for (test_target_filters) |filter| { | 616 | for (test_target_filters) |filter| { |
test/src/Debugger.zig+1-1| ... | @@ -2447,7 +2447,7 @@ fn addTest( | ... | @@ -2447,7 +2447,7 @@ fn addTest( |
| 2447 | } else return; | 2447 | } else return; |
| 2448 | } | 2448 | } |
| 2449 | if (db.options.test_target_filters.len > 0) { | 2449 | if (db.options.test_target_filters.len > 0) { |
| 2450 | const triple_txt = target.resolved.result.zigTriple(db.b.allocator) catch @panic("OOM"); | 2450 | const triple_txt = target.resolved.query.zigTriple(db.b.allocator) catch @panic("OOM"); |
| 2451 | for (db.options.test_target_filters) |filter| { | 2451 | for (db.options.test_target_filters) |filter| { |
| 2452 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; | 2452 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; |
| 2453 | } else return; | 2453 | } else return; |
test/src/LlvmIr.zig+1-1| ... | @@ -75,7 +75,7 @@ pub fn addExact( | ... | @@ -75,7 +75,7 @@ pub fn addExact( |
| 75 | pub fn addCase(self: *LlvmIr, case: TestCase) void { | 75 | pub fn addCase(self: *LlvmIr, case: TestCase) void { |
| 76 | const target = self.b.resolveTargetQuery(case.params.target); | 76 | const target = self.b.resolveTargetQuery(case.params.target); |
| 77 | if (self.options.test_target_filters.len > 0) { | 77 | if (self.options.test_target_filters.len > 0) { |
| 78 | const triple_txt = target.result.zigTriple(self.b.allocator) catch @panic("OOM"); | 78 | const triple_txt = target.query.zigTriple(self.b.allocator) catch @panic("OOM"); |
| 79 | for (self.options.test_target_filters) |filter| { | 79 | for (self.options.test_target_filters) |filter| { |
| 80 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; | 80 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; |
| 81 | } else return; | 81 | } else return; |
test/src/TranslateC.zig+1-1| ... | @@ -96,7 +96,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void { | ... | @@ -96,7 +96,7 @@ pub fn addCase(self: *TranslateCContext, case: *const TestCase) void { |
| 96 | const target = b.resolveTargetQuery(case.target); | 96 | const target = b.resolveTargetQuery(case.target); |
| 97 | 97 | ||
| 98 | if (self.test_target_filters.len > 0) { | 98 | if (self.test_target_filters.len > 0) { |
| 99 | const triple_txt = target.result.zigTriple(b.allocator) catch @panic("OOM"); | 99 | const triple_txt = target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| 100 | 100 | ||
| 101 | for (self.test_target_filters) |filter| { | 101 | for (self.test_target_filters) |filter| { |
| 102 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; | 102 | if (std.mem.indexOf(u8, triple_txt, filter) != null) break; |
test/tests.zig+2-2| ... | @@ -2310,8 +2310,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -2310,8 +2310,8 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 2310 | if (options.skip_llvm and would_use_llvm) continue; | 2310 | if (options.skip_llvm and would_use_llvm) continue; |
| 2311 | 2311 | ||
| 2312 | const resolved_target = b.resolveTargetQuery(test_target.target); | 2312 | const resolved_target = b.resolveTargetQuery(test_target.target); |
| 2313 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 2313 | const target = resolved_target.result; | 2314 | const target = resolved_target.result; |
| 2314 | const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 2315 | 2315 | ||
| 2316 | if (options.test_target_filters.len > 0) { | 2316 | if (options.test_target_filters.len > 0) { |
| 2317 | for (options.test_target_filters) |filter| { | 2317 | for (options.test_target_filters) |filter| { |
| ... | @@ -2556,8 +2556,8 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { | ... | @@ -2556,8 +2556,8 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step { |
| 2556 | if (options.skip_llvm and would_use_llvm) continue; | 2556 | if (options.skip_llvm and would_use_llvm) continue; |
| 2557 | 2557 | ||
| 2558 | const resolved_target = b.resolveTargetQuery(c_abi_target.target); | 2558 | const resolved_target = b.resolveTargetQuery(c_abi_target.target); |
| 2559 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 2559 | const target = resolved_target.result; | 2560 | const target = resolved_target.result; |
| 2560 | const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM"); | ||
| 2561 | 2561 | ||
| 2562 | if (options.test_target_filters.len > 0) { | 2562 | if (options.test_target_filters.len > 0) { |
| 2563 | for (options.test_target_filters) |filter| { | 2563 | for (options.test_target_filters) |filter| { |