| ... | ... | @@ -471,32 +471,32 @@ pub const Builder = struct { |
| 471 | 471 | } else if (mem.eql(u8, s, "false")) { |
| 472 | 472 | return false; |
| 473 | 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 | 475 | self.markInvalidUserInput(); |
| 476 | 476 | return null; |
| 477 | 477 | } |
| 478 | 478 | }, |
| 479 | 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 | 481 | self.markInvalidUserInput(); |
| 482 | 482 | return null; |
| 483 | 483 | }, |
| 484 | 484 | }, |
| 485 | 485 | .Int => switch (entry.value.value) { |
| 486 | 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 | 488 | self.markInvalidUserInput(); |
| 489 | 489 | return null; |
| 490 | 490 | }, |
| 491 | 491 | .Scalar => |s| { |
| 492 | 492 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { |
| 493 | 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 | 495 | self.markInvalidUserInput(); |
| 496 | 496 | return null; |
| 497 | 497 | }, |
| 498 | 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 | 500 | self.markInvalidUserInput(); |
| 501 | 501 | return null; |
| 502 | 502 | }, |
| ... | ... | @@ -504,34 +504,34 @@ pub const Builder = struct { |
| 504 | 504 | return n; |
| 505 | 505 | }, |
| 506 | 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 | 508 | self.markInvalidUserInput(); |
| 509 | 509 | return null; |
| 510 | 510 | }, |
| 511 | 511 | }, |
| 512 | 512 | .Float => switch (entry.value.value) { |
| 513 | 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 | 515 | self.markInvalidUserInput(); |
| 516 | 516 | return null; |
| 517 | 517 | }, |
| 518 | 518 | .Scalar => |s| { |
| 519 | 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 | 521 | self.markInvalidUserInput(); |
| 522 | 522 | return null; |
| 523 | 523 | }; |
| 524 | 524 | return n; |
| 525 | 525 | }, |
| 526 | 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 | 528 | self.markInvalidUserInput(); |
| 529 | 529 | return null; |
| 530 | 530 | }, |
| 531 | 531 | }, |
| 532 | 532 | .Enum => switch (entry.value.value) { |
| 533 | 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 | 535 | self.markInvalidUserInput(); |
| 536 | 536 | return null; |
| 537 | 537 | }, |
| ... | ... | @@ -539,25 +539,25 @@ pub const Builder = struct { |
| 539 | 539 | if (std.meta.stringToEnum(T, s)) |enum_lit| { |
| 540 | 540 | return enum_lit; |
| 541 | 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 | 543 | self.markInvalidUserInput(); |
| 544 | 544 | return null; |
| 545 | 545 | } |
| 546 | 546 | }, |
| 547 | 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 | 549 | self.markInvalidUserInput(); |
| 550 | 550 | return null; |
| 551 | 551 | }, |
| 552 | 552 | }, |
| 553 | 553 | .String => switch (entry.value.value) { |
| 554 | 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 | 556 | self.markInvalidUserInput(); |
| 557 | 557 | return null; |
| 558 | 558 | }, |
| 559 | 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 | 561 | self.markInvalidUserInput(); |
| 562 | 562 | return null; |
| 563 | 563 | }, |
| ... | ... | @@ -565,7 +565,7 @@ pub const Builder = struct { |
| 565 | 565 | }, |
| 566 | 566 | .List => switch (entry.value.value) { |
| 567 | 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 | 569 | self.markInvalidUserInput(); |
| 570 | 570 | return null; |
| 571 | 571 | }, |
| ... | ... | @@ -615,7 +615,7 @@ pub const Builder = struct { |
| 615 | 615 | else if (!release_fast and !release_safe and !release_small) |
| 616 | 616 | builtin.Mode.Debug |
| 617 | 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 | 619 | self.markInvalidUserInput(); |
| 620 | 620 | break :x builtin.Mode.Debug; |
| 621 | 621 | }; |
| ... | ... | @@ -646,17 +646,19 @@ pub const Builder = struct { |
| 646 | 646 | .diagnostics = &diags, |
| 647 | 647 | }) catch |err| switch (err) { |
| 648 | 648 | error.UnknownCpuModel => { |
| 649 | | std.debug.warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ |
| 649 | warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ |
| 650 | 650 | diags.cpu_name.?, |
| 651 | 651 | @tagName(diags.arch.?), |
| 652 | 652 | }); |
| 653 | 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 | 660 | error.UnknownCpuFeature => { |
| 659 | | std.debug.warn( |
| 661 | warn( |
| 660 | 662 | \\Unknown CPU feature: '{}' |
| 661 | 663 | \\Available CPU features for architecture '{}': |
| 662 | 664 | \\ |
| ... | ... | @@ -665,24 +667,29 @@ pub const Builder = struct { |
| 665 | 667 | @tagName(diags.arch.?), |
| 666 | 668 | }); |
| 667 | 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 | 676 | error.UnknownOperatingSystem => { |
| 673 | | std.debug.warn( |
| 677 | warn( |
| 674 | 678 | \\Unknown OS: '{}' |
| 675 | 679 | \\Available operating systems: |
| 676 | 680 | \\ |
| 677 | 681 | , .{diags.os_name}); |
| 678 | 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 | 689 | else => |e| { |
| 684 | | std.debug.warn("Unable to parse target '{}': {}\n", .{ triple, @errorName(e) }); |
| 685 | | process.exit(1); |
| 690 | warn("Unable to parse target '{}': {}\n\n", .{ triple, @errorName(e) }); |
| 691 | self.markInvalidUserInput(); |
| 692 | return args.default_target; |
| 686 | 693 | }, |
| 687 | 694 | }; |
| 688 | 695 | |
| ... | ... | @@ -696,16 +703,16 @@ pub const Builder = struct { |
| 696 | 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 | 707 | selected_canonicalized_triple, |
| 701 | 708 | }); |
| 702 | 709 | for (list) |t| { |
| 703 | 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 |
| 707 | | // the build runner that turns process exits into error return traces |
| 708 | | process.exit(1); |
| 713 | warn("\n", .{}); |
| 714 | self.markInvalidUserInput(); |
| 715 | return args.default_target; |
| 709 | 716 | } |
| 710 | 717 | |
| 711 | 718 | return selected_target; |