| ... | @@ -471,32 +471,32 @@ pub const Builder = struct { | ... | @@ -471,32 +471,32 @@ pub const Builder = struct { |
| 471 | } else if (mem.eql(u8, s, "false")) { | 471 | } else if (mem.eql(u8, s, "false")) { |
| 472 | return false; | 472 | return false; |
| 473 | } else { | 473 | } else { |
| 474 | warn("Expected -D{} to be a boolean, but received '{}'\n", .{ name, s }); | 474 | warn("Expected -D{} to be a boolean, but received '{}'\n\n", .{ name, s }); |
| 475 | self.markInvalidUserInput(); | 475 | self.markInvalidUserInput(); |
| 476 | return null; | 476 | return null; |
| 477 | } | 477 | } |
| 478 | }, | 478 | }, |
| 479 | .List => { | 479 | .List => { |
| 480 | warn("Expected -D{} to be a boolean, but received a list.\n", .{name}); | 480 | warn("Expected -D{} to be a boolean, but received a list.\n\n", .{name}); |
| 481 | self.markInvalidUserInput(); | 481 | self.markInvalidUserInput(); |
| 482 | return null; | 482 | return null; |
| 483 | }, | 483 | }, |
| 484 | }, | 484 | }, |
| 485 | .Int => switch (entry.value.value) { | 485 | .Int => switch (entry.value.value) { |
| 486 | .Flag => { | 486 | .Flag => { |
| 487 | warn("Expected -D{} to be an integer, but received a boolean.\n", .{name}); | 487 | warn("Expected -D{} to be an integer, but received a boolean.\n\n", .{name}); |
| 488 | self.markInvalidUserInput(); | 488 | self.markInvalidUserInput(); |
| 489 | return null; | 489 | return null; |
| 490 | }, | 490 | }, |
| 491 | .Scalar => |s| { | 491 | .Scalar => |s| { |
| 492 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { | 492 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { |
| 493 | error.Overflow => { | 493 | error.Overflow => { |
| 494 | warn("-D{} value {} cannot fit into type {}.\n", .{ name, s, @typeName(T) }); | 494 | warn("-D{} value {} cannot fit into type {}.\n\n", .{ name, s, @typeName(T) }); |
| 495 | self.markInvalidUserInput(); | 495 | self.markInvalidUserInput(); |
| 496 | return null; | 496 | return null; |
| 497 | }, | 497 | }, |
| 498 | else => { | 498 | else => { |
| 499 | warn("Expected -D{} to be an integer of type {}.\n", .{ name, @typeName(T) }); | 499 | warn("Expected -D{} to be an integer of type {}.\n\n", .{ name, @typeName(T) }); |
| 500 | self.markInvalidUserInput(); | 500 | self.markInvalidUserInput(); |
| 501 | return null; | 501 | return null; |
| 502 | }, | 502 | }, |
| ... | @@ -504,34 +504,34 @@ pub const Builder = struct { | ... | @@ -504,34 +504,34 @@ pub const Builder = struct { |
| 504 | return n; | 504 | return n; |
| 505 | }, | 505 | }, |
| 506 | .List => { | 506 | .List => { |
| 507 | warn("Expected -D{} to be an integer, but received a list.\n", .{name}); | 507 | warn("Expected -D{} to be an integer, but received a list.\n\n", .{name}); |
| 508 | self.markInvalidUserInput(); | 508 | self.markInvalidUserInput(); |
| 509 | return null; | 509 | return null; |
| 510 | }, | 510 | }, |
| 511 | }, | 511 | }, |
| 512 | .Float => switch (entry.value.value) { | 512 | .Float => switch (entry.value.value) { |
| 513 | .Flag => { | 513 | .Flag => { |
| 514 | warn("Expected -D{} to be a float, but received a boolean.\n", .{name}); | 514 | warn("Expected -D{} to be a float, but received a boolean.\n\n", .{name}); |
| 515 | self.markInvalidUserInput(); | 515 | self.markInvalidUserInput(); |
| 516 | return null; | 516 | return null; |
| 517 | }, | 517 | }, |
| 518 | .Scalar => |s| { | 518 | .Scalar => |s| { |
| 519 | const n = std.fmt.parseFloat(T, s) catch |err| { | 519 | const n = std.fmt.parseFloat(T, s) catch |err| { |
| 520 | warn("Expected -D{} to be a float of type {}.\n", .{ name, @typeName(T) }); | 520 | warn("Expected -D{} to be a float of type {}.\n\n", .{ name, @typeName(T) }); |
| 521 | self.markInvalidUserInput(); | 521 | self.markInvalidUserInput(); |
| 522 | return null; | 522 | return null; |
| 523 | }; | 523 | }; |
| 524 | return n; | 524 | return n; |
| 525 | }, | 525 | }, |
| 526 | .List => { | 526 | .List => { |
| 527 | warn("Expected -D{} to be a float, but received a list.\n", .{name}); | 527 | warn("Expected -D{} to be a float, but received a list.\n\n", .{name}); |
| 528 | self.markInvalidUserInput(); | 528 | self.markInvalidUserInput(); |
| 529 | return null; | 529 | return null; |
| 530 | }, | 530 | }, |
| 531 | }, | 531 | }, |
| 532 | .Enum => switch (entry.value.value) { | 532 | .Enum => switch (entry.value.value) { |
| 533 | .Flag => { | 533 | .Flag => { |
| 534 | warn("Expected -D{} to be a string, but received a boolean.\n", .{name}); | 534 | warn("Expected -D{} to be a string, but received a boolean.\n\n", .{name}); |
| 535 | self.markInvalidUserInput(); | 535 | self.markInvalidUserInput(); |
| 536 | return null; | 536 | return null; |
| 537 | }, | 537 | }, |
| ... | @@ -539,25 +539,25 @@ pub const Builder = struct { | ... | @@ -539,25 +539,25 @@ pub const Builder = struct { |
| 539 | if (std.meta.stringToEnum(T, s)) |enum_lit| { | 539 | if (std.meta.stringToEnum(T, s)) |enum_lit| { |
| 540 | return enum_lit; | 540 | return enum_lit; |
| 541 | } else { | 541 | } else { |
| 542 | warn("Expected -D{} to be of type {}.\n", .{ name, @typeName(T) }); | 542 | warn("Expected -D{} to be of type {}.\n\n", .{ name, @typeName(T) }); |
| 543 | self.markInvalidUserInput(); | 543 | self.markInvalidUserInput(); |
| 544 | return null; | 544 | return null; |
| 545 | } | 545 | } |
| 546 | }, | 546 | }, |
| 547 | .List => { | 547 | .List => { |
| 548 | warn("Expected -D{} to be a string, but received a list.\n", .{name}); | 548 | warn("Expected -D{} to be a string, but received a list.\n\n", .{name}); |
| 549 | self.markInvalidUserInput(); | 549 | self.markInvalidUserInput(); |
| 550 | return null; | 550 | return null; |
| 551 | }, | 551 | }, |
| 552 | }, | 552 | }, |
| 553 | .String => switch (entry.value.value) { | 553 | .String => switch (entry.value.value) { |
| 554 | .Flag => { | 554 | .Flag => { |
| 555 | warn("Expected -D{} to be a string, but received a boolean.\n", .{name}); | 555 | warn("Expected -D{} to be a string, but received a boolean.\n\n", .{name}); |
| 556 | self.markInvalidUserInput(); | 556 | self.markInvalidUserInput(); |
| 557 | return null; | 557 | return null; |
| 558 | }, | 558 | }, |
| 559 | .List => { | 559 | .List => { |
| 560 | warn("Expected -D{} to be a string, but received a list.\n", .{name}); | 560 | warn("Expected -D{} to be a string, but received a list.\n\n", .{name}); |
| 561 | self.markInvalidUserInput(); | 561 | self.markInvalidUserInput(); |
| 562 | return null; | 562 | return null; |
| 563 | }, | 563 | }, |
| ... | @@ -565,7 +565,7 @@ pub const Builder = struct { | ... | @@ -565,7 +565,7 @@ pub const Builder = struct { |
| 565 | }, | 565 | }, |
| 566 | .List => switch (entry.value.value) { | 566 | .List => switch (entry.value.value) { |
| 567 | .Flag => { | 567 | .Flag => { |
| 568 | warn("Expected -D{} to be a list, but received a boolean.\n", .{name}); | 568 | warn("Expected -D{} to be a list, but received a boolean.\n\n", .{name}); |
| 569 | self.markInvalidUserInput(); | 569 | self.markInvalidUserInput(); |
| 570 | return null; | 570 | return null; |
| 571 | }, | 571 | }, |
| ... | @@ -615,7 +615,7 @@ pub const Builder = struct { | ... | @@ -615,7 +615,7 @@ pub const Builder = struct { |
| 615 | else if (!release_fast and !release_safe and !release_small) | 615 | else if (!release_fast and !release_safe and !release_small) |
| 616 | builtin.Mode.Debug | 616 | builtin.Mode.Debug |
| 617 | else x: { | 617 | else x: { |
| 618 | warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)", .{}); | 618 | warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)\n\n", .{}); |
| 619 | self.markInvalidUserInput(); | 619 | self.markInvalidUserInput(); |
| 620 | break :x builtin.Mode.Debug; | 620 | break :x builtin.Mode.Debug; |
| 621 | }; | 621 | }; |
| ... | @@ -646,17 +646,19 @@ pub const Builder = struct { | ... | @@ -646,17 +646,19 @@ pub const Builder = struct { |
| 646 | .diagnostics = &diags, | 646 | .diagnostics = &diags, |
| 647 | }) catch |err| switch (err) { | 647 | }) catch |err| switch (err) { |
| 648 | error.UnknownCpuModel => { | 648 | error.UnknownCpuModel => { |
| 649 | std.debug.warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ | 649 | warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ |
| 650 | diags.cpu_name.?, | 650 | diags.cpu_name.?, |
| 651 | @tagName(diags.arch.?), | 651 | @tagName(diags.arch.?), |
| 652 | }); | 652 | }); |
| 653 | for (diags.arch.?.allCpuModels()) |cpu| { | 653 | for (diags.arch.?.allCpuModels()) |cpu| { |
| 654 | std.debug.warn(" {}\n", .{cpu.name}); | 654 | warn(" {}\n", .{cpu.name}); |
| 655 | } | 655 | } |
| 656 | process.exit(1); | 656 | warn("\n", .{}); |
| | 657 | self.markInvalidUserInput(); |
| | 658 | return args.default_target; |
| 657 | }, | 659 | }, |
| 658 | error.UnknownCpuFeature => { | 660 | error.UnknownCpuFeature => { |
| 659 | std.debug.warn( | 661 | warn( |
| 660 | \\Unknown CPU feature: '{}' | 662 | \\Unknown CPU feature: '{}' |
| 661 | \\Available CPU features for architecture '{}': | 663 | \\Available CPU features for architecture '{}': |
| 662 | \\ | 664 | \\ |
| ... | @@ -665,24 +667,29 @@ pub const Builder = struct { | ... | @@ -665,24 +667,29 @@ pub const Builder = struct { |
| 665 | @tagName(diags.arch.?), | 667 | @tagName(diags.arch.?), |
| 666 | }); | 668 | }); |
| 667 | for (diags.arch.?.allFeaturesList()) |feature| { | 669 | for (diags.arch.?.allFeaturesList()) |feature| { |
| 668 | std.debug.warn(" {}: {}\n", .{ feature.name, feature.description }); | 670 | warn(" {}: {}\n", .{ feature.name, feature.description }); |
| 669 | } | 671 | } |
| 670 | process.exit(1); | 672 | warn("\n", .{}); |
| | 673 | self.markInvalidUserInput(); |
| | 674 | return args.default_target; |
| 671 | }, | 675 | }, |
| 672 | error.UnknownOperatingSystem => { | 676 | error.UnknownOperatingSystem => { |
| 673 | std.debug.warn( | 677 | warn( |
| 674 | \\Unknown OS: '{}' | 678 | \\Unknown OS: '{}' |
| 675 | \\Available operating systems: | 679 | \\Available operating systems: |
| 676 | \\ | 680 | \\ |
| 677 | , .{diags.os_name}); | 681 | , .{diags.os_name}); |
| 678 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { | 682 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { |
| 679 | std.debug.warn(" {}\n", .{field.name}); | 683 | warn(" {}\n", .{field.name}); |
| 680 | } | 684 | } |
| 681 | process.exit(1); | 685 | warn("\n", .{}); |
| | 686 | self.markInvalidUserInput(); |
| | 687 | return args.default_target; |
| 682 | }, | 688 | }, |
| 683 | else => |e| { | 689 | else => |e| { |
| 684 | std.debug.warn("Unable to parse target '{}': {}\n", .{ triple, @errorName(e) }); | 690 | warn("Unable to parse target '{}': {}\n\n", .{ triple, @errorName(e) }); |
| 685 | process.exit(1); | 691 | self.markInvalidUserInput(); |
| | 692 | return args.default_target; |
| 686 | }, | 693 | }, |
| 687 | }; | 694 | }; |
| 688 | | 695 | |
| ... | @@ -696,16 +703,16 @@ pub const Builder = struct { | ... | @@ -696,16 +703,16 @@ pub const Builder = struct { |
| 696 | break :whitelist_check; | 703 | break :whitelist_check; |
| 697 | } | 704 | } |
| 698 | } | 705 | } |
| 699 | std.debug.warn("Chosen target '{}' does not match one of the supported targets:\n", .{ | 706 | warn("Chosen target '{}' does not match one of the supported targets:\n", .{ |
| 700 | selected_canonicalized_triple, | 707 | selected_canonicalized_triple, |
| 701 | }); | 708 | }); |
| 702 | for (list) |t| { | 709 | for (list) |t| { |
| 703 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 710 | const t_triple = t.zigTriple(self.allocator) catch unreachable; |
| 704 | std.debug.warn(" {}\n", .{t_triple}); | 711 | warn(" {}\n", .{t_triple}); |
| 705 | } | 712 | } |
| 706 | // TODO instead of process exit, return error and have a zig build flag implemented by | 713 | warn("\n", .{}); |
| 707 | // the build runner that turns process exits into error return traces | 714 | self.markInvalidUserInput(); |
| 708 | process.exit(1); | 715 | return args.default_target; |
| 709 | } | 716 | } |
| 710 | | 717 | |
| 711 | return selected_target; | 718 | return selected_target; |