| ... | @@ -6,7 +6,7 @@ const mem = std.mem; | ... | @@ -6,7 +6,7 @@ const mem = std.mem; |
| 6 | const debug = std.debug; | 6 | const debug = std.debug; |
| 7 | const panic = std.debug.panic; | 7 | const panic = std.debug.panic; |
| 8 | const assert = debug.assert; | 8 | const assert = debug.assert; |
| 9 | const warn = std.debug.print; // TODO use the log system instead of this | 9 | const log = std.log; |
| 10 | const ArrayList = std.ArrayList; | 10 | const ArrayList = std.ArrayList; |
| 11 | const StringHashMap = std.StringHashMap; | 11 | const StringHashMap = std.StringHashMap; |
| 12 | const Allocator = mem.Allocator; | 12 | const Allocator = mem.Allocator; |
| ... | @@ -478,7 +478,7 @@ pub const Builder = struct { | ... | @@ -478,7 +478,7 @@ pub const Builder = struct { |
| 478 | for (self.installed_files.items) |installed_file| { | 478 | for (self.installed_files.items) |installed_file| { |
| 479 | const full_path = self.getInstallPath(installed_file.dir, installed_file.path); | 479 | const full_path = self.getInstallPath(installed_file.dir, installed_file.path); |
| 480 | if (self.verbose) { | 480 | if (self.verbose) { |
| 481 | warn("rm {s}\n", .{full_path}); | 481 | log.info("rm {s}", .{full_path}); |
| 482 | } | 482 | } |
| 483 | fs.cwd().deleteTree(full_path) catch {}; | 483 | fs.cwd().deleteTree(full_path) catch {}; |
| 484 | } | 484 | } |
| ... | @@ -488,7 +488,7 @@ pub const Builder = struct { | ... | @@ -488,7 +488,7 @@ pub const Builder = struct { |
| 488 | | 488 | |
| 489 | fn makeOneStep(self: *Builder, s: *Step) anyerror!void { | 489 | fn makeOneStep(self: *Builder, s: *Step) anyerror!void { |
| 490 | if (s.loop_flag) { | 490 | if (s.loop_flag) { |
| 491 | warn("Dependency loop detected:\n {s}\n", .{s.name}); | 491 | log.err("Dependency loop detected:\n {s}", .{s.name}); |
| 492 | return error.DependencyLoopDetected; | 492 | return error.DependencyLoopDetected; |
| 493 | } | 493 | } |
| 494 | s.loop_flag = true; | 494 | s.loop_flag = true; |
| ... | @@ -496,7 +496,7 @@ pub const Builder = struct { | ... | @@ -496,7 +496,7 @@ pub const Builder = struct { |
| 496 | for (s.dependencies.items) |dep| { | 496 | for (s.dependencies.items) |dep| { |
| 497 | self.makeOneStep(dep) catch |err| { | 497 | self.makeOneStep(dep) catch |err| { |
| 498 | if (err == error.DependencyLoopDetected) { | 498 | if (err == error.DependencyLoopDetected) { |
| 499 | warn(" {s}\n", .{s.name}); | 499 | log.err(" {s}", .{s.name}); |
| 500 | } | 500 | } |
| 501 | return err; | 501 | return err; |
| 502 | }; | 502 | }; |
| ... | @@ -513,7 +513,7 @@ pub const Builder = struct { | ... | @@ -513,7 +513,7 @@ pub const Builder = struct { |
| 513 | return &top_level_step.step; | 513 | return &top_level_step.step; |
| 514 | } | 514 | } |
| 515 | } | 515 | } |
| 516 | warn("Cannot run step '{s}' because it does not exist\n", .{name}); | 516 | log.err("Cannot run step '{s}' because it does not exist", .{name}); |
| 517 | return error.InvalidStepName; | 517 | return error.InvalidStepName; |
| 518 | } | 518 | } |
| 519 | | 519 | |
| ... | @@ -553,32 +553,32 @@ pub const Builder = struct { | ... | @@ -553,32 +553,32 @@ pub const Builder = struct { |
| 553 | } else if (mem.eql(u8, s, "false")) { | 553 | } else if (mem.eql(u8, s, "false")) { |
| 554 | return false; | 554 | return false; |
| 555 | } else { | 555 | } else { |
| 556 | warn("Expected -D{s} to be a boolean, but received '{s}'\n\n", .{ name, s }); | 556 | log.err("Expected -D{s} to be a boolean, but received '{s}'\n", .{ name, s }); |
| 557 | self.markInvalidUserInput(); | 557 | self.markInvalidUserInput(); |
| 558 | return null; | 558 | return null; |
| 559 | } | 559 | } |
| 560 | }, | 560 | }, |
| 561 | .list => { | 561 | .list => { |
| 562 | warn("Expected -D{s} to be a boolean, but received a list.\n\n", .{name}); | 562 | log.err("Expected -D{s} to be a boolean, but received a list.\n", .{name}); |
| 563 | self.markInvalidUserInput(); | 563 | self.markInvalidUserInput(); |
| 564 | return null; | 564 | return null; |
| 565 | }, | 565 | }, |
| 566 | }, | 566 | }, |
| 567 | .int => switch (option_ptr.value) { | 567 | .int => switch (option_ptr.value) { |
| 568 | .flag => { | 568 | .flag => { |
| 569 | warn("Expected -D{s} to be an integer, but received a boolean.\n\n", .{name}); | 569 | log.err("Expected -D{s} to be an integer, but received a boolean.\n", .{name}); |
| 570 | self.markInvalidUserInput(); | 570 | self.markInvalidUserInput(); |
| 571 | return null; | 571 | return null; |
| 572 | }, | 572 | }, |
| 573 | .scalar => |s| { | 573 | .scalar => |s| { |
| 574 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { | 574 | const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { |
| 575 | error.Overflow => { | 575 | error.Overflow => { |
| 576 | warn("-D{s} value {s} cannot fit into type {s}.\n\n", .{ name, s, @typeName(T) }); | 576 | log.err("-D{s} value {s} cannot fit into type {s}.\n", .{ name, s, @typeName(T) }); |
| 577 | self.markInvalidUserInput(); | 577 | self.markInvalidUserInput(); |
| 578 | return null; | 578 | return null; |
| 579 | }, | 579 | }, |
| 580 | else => { | 580 | else => { |
| 581 | warn("Expected -D{s} to be an integer of type {s}.\n\n", .{ name, @typeName(T) }); | 581 | log.err("Expected -D{s} to be an integer of type {s}.\n", .{ name, @typeName(T) }); |
| 582 | self.markInvalidUserInput(); | 582 | self.markInvalidUserInput(); |
| 583 | return null; | 583 | return null; |
| 584 | }, | 584 | }, |
| ... | @@ -586,34 +586,34 @@ pub const Builder = struct { | ... | @@ -586,34 +586,34 @@ pub const Builder = struct { |
| 586 | return n; | 586 | return n; |
| 587 | }, | 587 | }, |
| 588 | .list => { | 588 | .list => { |
| 589 | warn("Expected -D{s} to be an integer, but received a list.\n\n", .{name}); | 589 | log.err("Expected -D{s} to be an integer, but received a list.\n", .{name}); |
| 590 | self.markInvalidUserInput(); | 590 | self.markInvalidUserInput(); |
| 591 | return null; | 591 | return null; |
| 592 | }, | 592 | }, |
| 593 | }, | 593 | }, |
| 594 | .float => switch (option_ptr.value) { | 594 | .float => switch (option_ptr.value) { |
| 595 | .flag => { | 595 | .flag => { |
| 596 | warn("Expected -D{s} to be a float, but received a boolean.\n\n", .{name}); | 596 | log.err("Expected -D{s} to be a float, but received a boolean.\n", .{name}); |
| 597 | self.markInvalidUserInput(); | 597 | self.markInvalidUserInput(); |
| 598 | return null; | 598 | return null; |
| 599 | }, | 599 | }, |
| 600 | .scalar => |s| { | 600 | .scalar => |s| { |
| 601 | const n = std.fmt.parseFloat(T, s) catch { | 601 | const n = std.fmt.parseFloat(T, s) catch { |
| 602 | warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) }); | 602 | log.err("Expected -D{s} to be a float of type {s}.\n", .{ name, @typeName(T) }); |
| 603 | self.markInvalidUserInput(); | 603 | self.markInvalidUserInput(); |
| 604 | return null; | 604 | return null; |
| 605 | }; | 605 | }; |
| 606 | return n; | 606 | return n; |
| 607 | }, | 607 | }, |
| 608 | .list => { | 608 | .list => { |
| 609 | warn("Expected -D{s} to be a float, but received a list.\n\n", .{name}); | 609 | log.err("Expected -D{s} to be a float, but received a list.\n", .{name}); |
| 610 | self.markInvalidUserInput(); | 610 | self.markInvalidUserInput(); |
| 611 | return null; | 611 | return null; |
| 612 | }, | 612 | }, |
| 613 | }, | 613 | }, |
| 614 | .@"enum" => switch (option_ptr.value) { | 614 | .@"enum" => switch (option_ptr.value) { |
| 615 | .flag => { | 615 | .flag => { |
| 616 | warn("Expected -D{s} to be a string, but received a boolean.\n\n", .{name}); | 616 | log.err("Expected -D{s} to be a string, but received a boolean.\n", .{name}); |
| 617 | self.markInvalidUserInput(); | 617 | self.markInvalidUserInput(); |
| 618 | return null; | 618 | return null; |
| 619 | }, | 619 | }, |
| ... | @@ -621,25 +621,25 @@ pub const Builder = struct { | ... | @@ -621,25 +621,25 @@ pub const Builder = struct { |
| 621 | if (std.meta.stringToEnum(T, s)) |enum_lit| { | 621 | if (std.meta.stringToEnum(T, s)) |enum_lit| { |
| 622 | return enum_lit; | 622 | return enum_lit; |
| 623 | } else { | 623 | } else { |
| 624 | warn("Expected -D{s} to be of type {s}.\n\n", .{ name, @typeName(T) }); | 624 | log.err("Expected -D{s} to be of type {s}.\n", .{ name, @typeName(T) }); |
| 625 | self.markInvalidUserInput(); | 625 | self.markInvalidUserInput(); |
| 626 | return null; | 626 | return null; |
| 627 | } | 627 | } |
| 628 | }, | 628 | }, |
| 629 | .list => { | 629 | .list => { |
| 630 | warn("Expected -D{s} to be a string, but received a list.\n\n", .{name}); | 630 | log.err("Expected -D{s} to be a string, but received a list.\n", .{name}); |
| 631 | self.markInvalidUserInput(); | 631 | self.markInvalidUserInput(); |
| 632 | return null; | 632 | return null; |
| 633 | }, | 633 | }, |
| 634 | }, | 634 | }, |
| 635 | .string => switch (option_ptr.value) { | 635 | .string => switch (option_ptr.value) { |
| 636 | .flag => { | 636 | .flag => { |
| 637 | warn("Expected -D{s} to be a string, but received a boolean.\n\n", .{name}); | 637 | log.err("Expected -D{s} to be a string, but received a boolean.\n", .{name}); |
| 638 | self.markInvalidUserInput(); | 638 | self.markInvalidUserInput(); |
| 639 | return null; | 639 | return null; |
| 640 | }, | 640 | }, |
| 641 | .list => { | 641 | .list => { |
| 642 | warn("Expected -D{s} to be a string, but received a list.\n\n", .{name}); | 642 | log.err("Expected -D{s} to be a string, but received a list.\n", .{name}); |
| 643 | self.markInvalidUserInput(); | 643 | self.markInvalidUserInput(); |
| 644 | return null; | 644 | return null; |
| 645 | }, | 645 | }, |
| ... | @@ -647,7 +647,7 @@ pub const Builder = struct { | ... | @@ -647,7 +647,7 @@ pub const Builder = struct { |
| 647 | }, | 647 | }, |
| 648 | .list => switch (option_ptr.value) { | 648 | .list => switch (option_ptr.value) { |
| 649 | .flag => { | 649 | .flag => { |
| 650 | warn("Expected -D{s} to be a list, but received a boolean.\n\n", .{name}); | 650 | log.err("Expected -D{s} to be a list, but received a boolean.\n", .{name}); |
| 651 | self.markInvalidUserInput(); | 651 | self.markInvalidUserInput(); |
| 652 | return null; | 652 | return null; |
| 653 | }, | 653 | }, |
| ... | @@ -697,7 +697,7 @@ pub const Builder = struct { | ... | @@ -697,7 +697,7 @@ pub const Builder = struct { |
| 697 | else if (!release_fast and !release_safe and !release_small) | 697 | else if (!release_fast and !release_safe and !release_small) |
| 698 | std.builtin.Mode.Debug | 698 | std.builtin.Mode.Debug |
| 699 | else x: { | 699 | else x: { |
| 700 | warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)\n\n", .{}); | 700 | log.err("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)\n", .{}); |
| 701 | self.markInvalidUserInput(); | 701 | self.markInvalidUserInput(); |
| 702 | break :x std.builtin.Mode.Debug; | 702 | break :x std.builtin.Mode.Debug; |
| 703 | }; | 703 | }; |
| ... | @@ -734,19 +734,18 @@ pub const Builder = struct { | ... | @@ -734,19 +734,18 @@ pub const Builder = struct { |
| 734 | .diagnostics = &diags, | 734 | .diagnostics = &diags, |
| 735 | }) catch |err| switch (err) { | 735 | }) catch |err| switch (err) { |
| 736 | error.UnknownCpuModel => { | 736 | error.UnknownCpuModel => { |
| 737 | warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{ | 737 | log.err("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':", .{ |
| 738 | diags.cpu_name.?, | 738 | diags.cpu_name.?, |
| 739 | @tagName(diags.arch.?), | 739 | @tagName(diags.arch.?), |
| 740 | }); | 740 | }); |
| 741 | for (diags.arch.?.allCpuModels()) |cpu| { | 741 | for (diags.arch.?.allCpuModels()) |cpu| { |
| 742 | warn(" {s}\n", .{cpu.name}); | 742 | log.err(" {s}", .{cpu.name}); |
| 743 | } | 743 | } |
| 744 | warn("\n", .{}); | | |
| 745 | self.markInvalidUserInput(); | 744 | self.markInvalidUserInput(); |
| 746 | return args.default_target; | 745 | return args.default_target; |
| 747 | }, | 746 | }, |
| 748 | error.UnknownCpuFeature => { | 747 | error.UnknownCpuFeature => { |
| 749 | warn( | 748 | log.err( |
| 750 | \\Unknown CPU feature: '{s}' | 749 | \\Unknown CPU feature: '{s}' |
| 751 | \\Available CPU features for architecture '{s}': | 750 | \\Available CPU features for architecture '{s}': |
| 752 | \\ | 751 | \\ |
| ... | @@ -755,27 +754,25 @@ pub const Builder = struct { | ... | @@ -755,27 +754,25 @@ pub const Builder = struct { |
| 755 | @tagName(diags.arch.?), | 754 | @tagName(diags.arch.?), |
| 756 | }); | 755 | }); |
| 757 | for (diags.arch.?.allFeaturesList()) |feature| { | 756 | for (diags.arch.?.allFeaturesList()) |feature| { |
| 758 | warn(" {s}: {s}\n", .{ feature.name, feature.description }); | 757 | log.err(" {s}: {s}", .{ feature.name, feature.description }); |
| 759 | } | 758 | } |
| 760 | warn("\n", .{}); | | |
| 761 | self.markInvalidUserInput(); | 759 | self.markInvalidUserInput(); |
| 762 | return args.default_target; | 760 | return args.default_target; |
| 763 | }, | 761 | }, |
| 764 | error.UnknownOperatingSystem => { | 762 | error.UnknownOperatingSystem => { |
| 765 | warn( | 763 | log.err( |
| 766 | \\Unknown OS: '{s}' | 764 | \\Unknown OS: '{s}' |
| 767 | \\Available operating systems: | 765 | \\Available operating systems: |
| 768 | \\ | 766 | \\ |
| 769 | , .{diags.os_name}); | 767 | , .{diags.os_name}); |
| 770 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { | 768 | inline for (std.meta.fields(std.Target.Os.Tag)) |field| { |
| 771 | warn(" {s}\n", .{field.name}); | 769 | log.err(" {s}", .{field.name}); |
| 772 | } | 770 | } |
| 773 | warn("\n", .{}); | | |
| 774 | self.markInvalidUserInput(); | 771 | self.markInvalidUserInput(); |
| 775 | return args.default_target; | 772 | return args.default_target; |
| 776 | }, | 773 | }, |
| 777 | else => |e| { | 774 | else => |e| { |
| 778 | warn("Unable to parse target '{s}': {s}\n\n", .{ triple, @errorName(e) }); | 775 | log.err("Unable to parse target '{s}': {s}\n", .{ triple, @errorName(e) }); |
| 779 | self.markInvalidUserInput(); | 776 | self.markInvalidUserInput(); |
| 780 | return args.default_target; | 777 | return args.default_target; |
| 781 | }, | 778 | }, |
| ... | @@ -805,22 +802,21 @@ pub const Builder = struct { | ... | @@ -805,22 +802,21 @@ pub const Builder = struct { |
| 805 | } | 802 | } |
| 806 | } | 803 | } |
| 807 | if (mismatch_triple) { | 804 | if (mismatch_triple) { |
| 808 | warn("Chosen target '{s}' does not match one of the supported targets:\n", .{ | 805 | log.err("Chosen target '{s}' does not match one of the supported targets:", .{ |
| 809 | selected_canonicalized_triple, | 806 | selected_canonicalized_triple, |
| 810 | }); | 807 | }); |
| 811 | for (list) |t| { | 808 | for (list) |t| { |
| 812 | const t_triple = t.zigTriple(self.allocator) catch unreachable; | 809 | const t_triple = t.zigTriple(self.allocator) catch unreachable; |
| 813 | warn(" {s}\n", .{t_triple}); | 810 | log.err(" {s}", .{t_triple}); |
| 814 | } | 811 | } |
| 815 | warn("\n", .{}); | | |
| 816 | } else { | 812 | } else { |
| 817 | assert(mismatch_cpu_features); | 813 | assert(mismatch_cpu_features); |
| 818 | const whitelist_cpu = whitelist_item.getCpu(); | 814 | const whitelist_cpu = whitelist_item.getCpu(); |
| 819 | const selected_cpu = selected_target.getCpu(); | 815 | const selected_cpu = selected_target.getCpu(); |
| 820 | warn("Chosen CPU model '{s}' does not match one of the supported targets:\n", .{ | 816 | log.err("Chosen CPU model '{s}' does not match one of the supported targets:", .{ |
| 821 | selected_cpu.model.name, | 817 | selected_cpu.model.name, |
| 822 | }); | 818 | }); |
| 823 | warn(" Supported feature Set: ", .{}); | 819 | log.err(" Supported feature Set: ", .{}); |
| 824 | const all_features = whitelist_cpu.arch.allFeaturesList(); | 820 | const all_features = whitelist_cpu.arch.allFeaturesList(); |
| 825 | var populated_cpu_features = whitelist_cpu.model.features; | 821 | var populated_cpu_features = whitelist_cpu.model.features; |
| 826 | populated_cpu_features.populateDependencies(all_features); | 822 | populated_cpu_features.populateDependencies(all_features); |
| ... | @@ -828,20 +824,18 @@ pub const Builder = struct { | ... | @@ -828,20 +824,18 @@ pub const Builder = struct { |
| 828 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); | 824 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); |
| 829 | const in_cpu_set = populated_cpu_features.isEnabled(i); | 825 | const in_cpu_set = populated_cpu_features.isEnabled(i); |
| 830 | if (in_cpu_set) { | 826 | if (in_cpu_set) { |
| 831 | warn("{s} ", .{feature.name}); | 827 | log.err("{s} ", .{feature.name}); |
| 832 | } | 828 | } |
| 833 | } | 829 | } |
| 834 | warn("\n", .{}); | 830 | log.err(" Remove: ", .{}); |
| 835 | warn(" Remove: ", .{}); | | |
| 836 | for (all_features) |feature, i_usize| { | 831 | for (all_features) |feature, i_usize| { |
| 837 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); | 832 | const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); |
| 838 | const in_cpu_set = populated_cpu_features.isEnabled(i); | 833 | const in_cpu_set = populated_cpu_features.isEnabled(i); |
| 839 | const in_actual_set = selected_cpu.features.isEnabled(i); | 834 | const in_actual_set = selected_cpu.features.isEnabled(i); |
| 840 | if (in_actual_set and !in_cpu_set) { | 835 | if (in_actual_set and !in_cpu_set) { |
| 841 | warn("{s} ", .{feature.name}); | 836 | log.err("{s} ", .{feature.name}); |
| 842 | } | 837 | } |
| 843 | } | 838 | } |
| 844 | warn("\n", .{}); | | |
| 845 | } | 839 | } |
| 846 | self.markInvalidUserInput(); | 840 | self.markInvalidUserInput(); |
| 847 | return args.default_target; | 841 | return args.default_target; |
| ... | @@ -886,7 +880,7 @@ pub const Builder = struct { | ... | @@ -886,7 +880,7 @@ pub const Builder = struct { |
| 886 | }) catch unreachable; | 880 | }) catch unreachable; |
| 887 | }, | 881 | }, |
| 888 | .flag => { | 882 | .flag => { |
| 889 | warn("Option '-D{s}={s}' conflicts with flag '-D{s}'.\n", .{ name, value, name }); | 883 | log.warn("Option '-D{s}={s}' conflicts with flag '-D{s}'.", .{ name, value, name }); |
| 890 | return true; | 884 | return true; |
| 891 | }, | 885 | }, |
| 892 | } | 886 | } |
| ... | @@ -908,11 +902,11 @@ pub const Builder = struct { | ... | @@ -908,11 +902,11 @@ pub const Builder = struct { |
| 908 | // option already exists | 902 | // option already exists |
| 909 | switch (gop.value_ptr.value) { | 903 | switch (gop.value_ptr.value) { |
| 910 | .scalar => |s| { | 904 | .scalar => |s| { |
| 911 | warn("Flag '-D{s}' conflicts with option '-D{s}={s}'.\n", .{ name, name, s }); | 905 | log.err("Flag '-D{s}' conflicts with option '-D{s}={s}'.", .{ name, name, s }); |
| 912 | return true; | 906 | return true; |
| 913 | }, | 907 | }, |
| 914 | .list => { | 908 | .list => { |
| 915 | warn("Flag '-D{s}' conflicts with multiple options of the same name.\n", .{name}); | 909 | log.err("Flag '-D{s}' conflicts with multiple options of the same name.", .{name}); |
| 916 | return true; | 910 | return true; |
| 917 | }, | 911 | }, |
| 918 | .flag => {}, | 912 | .flag => {}, |
| ... | @@ -943,7 +937,7 @@ pub const Builder = struct { | ... | @@ -943,7 +937,7 @@ pub const Builder = struct { |
| 943 | var it = self.user_input_options.iterator(); | 937 | var it = self.user_input_options.iterator(); |
| 944 | while (it.next()) |entry| { | 938 | while (it.next()) |entry| { |
| 945 | if (!entry.value_ptr.used) { | 939 | if (!entry.value_ptr.used) { |
| 946 | warn("Invalid option: -D{s}\n\n", .{entry.key_ptr.*}); | 940 | log.err("Invalid option: -D{s}\n", .{entry.key_ptr.*}); |
| 947 | self.markInvalidUserInput(); | 941 | self.markInvalidUserInput(); |
| 948 | } | 942 | } |
| 949 | } | 943 | } |
| ... | @@ -956,11 +950,11 @@ pub const Builder = struct { | ... | @@ -956,11 +950,11 @@ pub const Builder = struct { |
| 956 | } | 950 | } |
| 957 | | 951 | |
| 958 | fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { | 952 | fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { |
| 959 | if (cwd) |yes_cwd| warn("cd {s} && ", .{yes_cwd}); | 953 | if (cwd) |yes_cwd| std.debug.print("cd {s} && ", .{yes_cwd}); |
| 960 | for (argv) |arg| { | 954 | for (argv) |arg| { |
| 961 | warn("{s} ", .{arg}); | 955 | std.debug.print("{s} ", .{arg}); |
| 962 | } | 956 | } |
| 963 | warn("\n", .{}); | 957 | std.debug.print("\n", .{}); |
| 964 | } | 958 | } |
| 965 | | 959 | |
| 966 | pub fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const EnvMap, argv: []const []const u8) !void { | 960 | pub fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const EnvMap, argv: []const []const u8) !void { |
| ... | @@ -976,20 +970,20 @@ pub const Builder = struct { | ... | @@ -976,20 +970,20 @@ pub const Builder = struct { |
| 976 | child.env_map = env_map; | 970 | child.env_map = env_map; |
| 977 | | 971 | |
| 978 | const term = child.spawnAndWait() catch |err| { | 972 | const term = child.spawnAndWait() catch |err| { |
| 979 | warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) }); | 973 | log.err("Unable to spawn {s}: {s}", .{ argv[0], @errorName(err) }); |
| 980 | return err; | 974 | return err; |
| 981 | }; | 975 | }; |
| 982 | | 976 | |
| 983 | switch (term) { | 977 | switch (term) { |
| 984 | .Exited => |code| { | 978 | .Exited => |code| { |
| 985 | if (code != 0) { | 979 | if (code != 0) { |
| 986 | warn("The following command exited with error code {}:\n", .{code}); | 980 | log.err("The following command exited with error code {}:", .{code}); |
| 987 | printCmd(cwd, argv); | 981 | printCmd(cwd, argv); |
| 988 | return error.UncleanExit; | 982 | return error.UncleanExit; |
| 989 | } | 983 | } |
| 990 | }, | 984 | }, |
| 991 | else => { | 985 | else => { |
| 992 | warn("The following command terminated unexpectedly:\n", .{}); | 986 | log.err("The following command terminated unexpectedly:", .{}); |
| 993 | printCmd(cwd, argv); | 987 | printCmd(cwd, argv); |
| 994 | | 988 | |
| 995 | return error.UncleanExit; | 989 | return error.UncleanExit; |
| ... | @@ -999,7 +993,7 @@ pub const Builder = struct { | ... | @@ -999,7 +993,7 @@ pub const Builder = struct { |
| 999 | | 993 | |
| 1000 | pub fn makePath(self: *Builder, path: []const u8) !void { | 994 | pub fn makePath(self: *Builder, path: []const u8) !void { |
| 1001 | fs.cwd().makePath(self.pathFromRoot(path)) catch |err| { | 995 | fs.cwd().makePath(self.pathFromRoot(path)) catch |err| { |
| 1002 | warn("Unable to create path {s}: {s}\n", .{ path, @errorName(err) }); | 996 | log.err("Unable to create path {s}: {s}", .{ path, @errorName(err) }); |
| 1003 | return err; | 997 | return err; |
| 1004 | }; | 998 | }; |
| 1005 | } | 999 | } |
| ... | @@ -1087,19 +1081,19 @@ pub const Builder = struct { | ... | @@ -1087,19 +1081,19 @@ pub const Builder = struct { |
| 1087 | | 1081 | |
| 1088 | pub fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void { | 1082 | pub fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void { |
| 1089 | if (self.verbose) { | 1083 | if (self.verbose) { |
| 1090 | warn("cp {s} {s} ", .{ source_path, dest_path }); | 1084 | log.info("cp {s} {s} ", .{ source_path, dest_path }); |
| 1091 | } | 1085 | } |
| 1092 | const cwd = fs.cwd(); | 1086 | const cwd = fs.cwd(); |
| 1093 | const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{}); | 1087 | const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{}); |
| 1094 | if (self.verbose) switch (prev_status) { | 1088 | if (self.verbose) switch (prev_status) { |
| 1095 | .stale => warn("# installed\n", .{}), | 1089 | .stale => log.info("# installed", .{}), |
| 1096 | .fresh => warn("# up-to-date\n", .{}), | 1090 | .fresh => log.info("# up-to-date", .{}), |
| 1097 | }; | 1091 | }; |
| 1098 | } | 1092 | } |
| 1099 | | 1093 | |
| 1100 | pub fn truncateFile(self: *Builder, dest_path: []const u8) !void { | 1094 | pub fn truncateFile(self: *Builder, dest_path: []const u8) !void { |
| 1101 | if (self.verbose) { | 1095 | if (self.verbose) { |
| 1102 | warn("truncate {s}\n", .{dest_path}); | 1096 | log.info("truncate {s}", .{dest_path}); |
| 1103 | } | 1097 | } |
| 1104 | const cwd = fs.cwd(); | 1098 | const cwd = fs.cwd(); |
| 1105 | var src_file = cwd.createFile(dest_path, .{}) catch |err| switch (err) { | 1099 | var src_file = cwd.createFile(dest_path, .{}) catch |err| switch (err) { |
| ... | @@ -1222,8 +1216,8 @@ pub const Builder = struct { | ... | @@ -1222,8 +1216,8 @@ pub const Builder = struct { |
| 1222 | } | 1216 | } |
| 1223 | | 1217 | |
| 1224 | if (!std.process.can_spawn) { | 1218 | if (!std.process.can_spawn) { |
| 1225 | if (src_step) |s| warn("{s}...", .{s.name}); | 1219 | if (src_step) |s| log.err("{s}...", .{s.name}); |
| 1226 | warn("Unable to spawn the following command: cannot spawn child process\n", .{}); | 1220 | log.err("Unable to spawn the following command: cannot spawn child process", .{}); |
| 1227 | printCmd(null, argv); | 1221 | printCmd(null, argv); |
| 1228 | std.os.abort(); | 1222 | std.os.abort(); |
| 1229 | } | 1223 | } |
| ... | @@ -1231,31 +1225,31 @@ pub const Builder = struct { | ... | @@ -1231,31 +1225,31 @@ pub const Builder = struct { |
| 1231 | var code: u8 = undefined; | 1225 | var code: u8 = undefined; |
| 1232 | return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) { | 1226 | return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) { |
| 1233 | error.ExecNotSupported => { | 1227 | error.ExecNotSupported => { |
| 1234 | if (src_step) |s| warn("{s}...", .{s.name}); | 1228 | if (src_step) |s| log.err("{s}...", .{s.name}); |
| 1235 | warn("Unable to spawn the following command: cannot spawn child process\n", .{}); | 1229 | log.err("Unable to spawn the following command: cannot spawn child process", .{}); |
| 1236 | printCmd(null, argv); | 1230 | printCmd(null, argv); |
| 1237 | std.os.abort(); | 1231 | std.os.abort(); |
| 1238 | }, | 1232 | }, |
| 1239 | error.FileNotFound => { | 1233 | error.FileNotFound => { |
| 1240 | if (src_step) |s| warn("{s}...", .{s.name}); | 1234 | if (src_step) |s| log.err("{s}...", .{s.name}); |
| 1241 | warn("Unable to spawn the following command: file not found\n", .{}); | 1235 | log.err("Unable to spawn the following command: file not found", .{}); |
| 1242 | printCmd(null, argv); | 1236 | printCmd(null, argv); |
| 1243 | std.os.exit(@truncate(u8, code)); | 1237 | std.os.exit(@truncate(u8, code)); |
| 1244 | }, | 1238 | }, |
| 1245 | error.ExitCodeFailure => { | 1239 | error.ExitCodeFailure => { |
| 1246 | if (src_step) |s| warn("{s}...", .{s.name}); | 1240 | if (src_step) |s| log.err("{s}...", .{s.name}); |
| 1247 | if (self.prominent_compile_errors) { | 1241 | if (self.prominent_compile_errors) { |
| 1248 | warn("The step exited with error code {d}\n", .{code}); | 1242 | log.err("The step exited with error code {d}", .{code}); |
| 1249 | } else { | 1243 | } else { |
| 1250 | warn("The following command exited with error code {d}:\n", .{code}); | 1244 | log.err("The following command exited with error code {d}:", .{code}); |
| 1251 | printCmd(null, argv); | 1245 | printCmd(null, argv); |
| 1252 | } | 1246 | } |
| 1253 | | 1247 | |
| 1254 | std.os.exit(@truncate(u8, code)); | 1248 | std.os.exit(@truncate(u8, code)); |
| 1255 | }, | 1249 | }, |
| 1256 | error.ProcessTerminated => { | 1250 | error.ProcessTerminated => { |
| 1257 | if (src_step) |s| warn("{s}...", .{s.name}); | 1251 | if (src_step) |s| log.err("{s}...", .{s.name}); |
| 1258 | warn("The following command terminated unexpectedly:\n", .{}); | 1252 | log.err("The following command terminated unexpectedly:", .{}); |
| 1259 | printCmd(null, argv); | 1253 | printCmd(null, argv); |
| 1260 | std.os.exit(@truncate(u8, code)); | 1254 | std.os.exit(@truncate(u8, code)); |
| 1261 | }, | 1255 | }, |
| ... | @@ -2140,7 +2134,7 @@ pub const LibExeObjStep = struct { | ... | @@ -2140,7 +2134,7 @@ pub const LibExeObjStep = struct { |
| 2140 | } else if (mem.startsWith(u8, tok, "-D")) { | 2134 | } else if (mem.startsWith(u8, tok, "-D")) { |
| 2141 | try zig_args.append(tok); | 2135 | try zig_args.append(tok); |
| 2142 | } else if (self.builder.verbose) { | 2136 | } else if (self.builder.verbose) { |
| 2143 | warn("Ignoring pkg-config flag '{s}'\n", .{tok}); | 2137 | log.warn("Ignoring pkg-config flag '{s}'", .{tok}); |
| 2144 | } | 2138 | } |
| 2145 | } | 2139 | } |
| 2146 | | 2140 | |
| ... | @@ -2435,7 +2429,7 @@ pub const LibExeObjStep = struct { | ... | @@ -2435,7 +2429,7 @@ pub const LibExeObjStep = struct { |
| 2435 | const builder = self.builder; | 2429 | const builder = self.builder; |
| 2436 | | 2430 | |
| 2437 | if (self.root_src == null and self.link_objects.items.len == 0) { | 2431 | if (self.root_src == null and self.link_objects.items.len == 0) { |
| 2438 | warn("{s}: linker needs 1 or more objects to link\n", .{self.step.name}); | 2432 | log.err("{s}: linker needs 1 or more objects to link", .{self.step.name}); |
| 2439 | return error.NeedAnObject; | 2433 | return error.NeedAnObject; |
| 2440 | } | 2434 | } |
| 2441 | | 2435 | |
| ... | @@ -2558,7 +2552,7 @@ pub const LibExeObjStep = struct { | ... | @@ -2558,7 +2552,7 @@ pub const LibExeObjStep = struct { |
| 2558 | if (system_lib.needed) break :prefix "-needed-l"; | 2552 | if (system_lib.needed) break :prefix "-needed-l"; |
| 2559 | if (system_lib.weak) { | 2553 | if (system_lib.weak) { |
| 2560 | if (self.target.isDarwin()) break :prefix "-weak-l"; | 2554 | if (self.target.isDarwin()) break :prefix "-weak-l"; |
| 2561 | warn("Weak library import used for a non-darwin target, this will be converted to normally library import `-lname`\n", .{}); | 2555 | log.warn("Weak library import used for a non-darwin target, this will be converted to normally library import `-lname`", .{}); |
| 2562 | } | 2556 | } |
| 2563 | break :prefix "-l"; | 2557 | break :prefix "-l"; |
| 2564 | }; | 2558 | }; |
| ... | @@ -3078,11 +3072,11 @@ pub const LibExeObjStep = struct { | ... | @@ -3078,11 +3072,11 @@ pub const LibExeObjStep = struct { |
| 3078 | } | 3072 | } |
| 3079 | } else { | 3073 | } else { |
| 3080 | if (self.framework_dirs.items.len > 0) { | 3074 | if (self.framework_dirs.items.len > 0) { |
| 3081 | warn("Framework directories have been added for a non-darwin target, this will have no affect on the build\n", .{}); | 3075 | log.info("Framework directories have been added for a non-darwin target, this will have no affect on the build", .{}); |
| 3082 | } | 3076 | } |
| 3083 | | 3077 | |
| 3084 | if (self.frameworks.count() > 0) { | 3078 | if (self.frameworks.count() > 0) { |
| 3085 | warn("Frameworks have been added for a non-darwin target, this will have no affect on the build\n", .{}); | 3079 | log.info("Frameworks have been added for a non-darwin target, this will have no affect on the build", .{}); |
| 3086 | } | 3080 | } |
| 3087 | } | 3081 | } |
| 3088 | | 3082 | |
| ... | @@ -3530,7 +3524,7 @@ pub const LogStep = struct { | ... | @@ -3530,7 +3524,7 @@ pub const LogStep = struct { |
| 3530 | | 3524 | |
| 3531 | fn make(step: *Step) anyerror!void { | 3525 | fn make(step: *Step) anyerror!void { |
| 3532 | const self = @fieldParentPtr(LogStep, "step", step); | 3526 | const self = @fieldParentPtr(LogStep, "step", step); |
| 3533 | warn("{s}", .{self.data}); | 3527 | log.info("{s}", .{self.data}); |
| 3534 | } | 3528 | } |
| 3535 | }; | 3529 | }; |
| 3536 | | 3530 | |
| ... | @@ -3554,7 +3548,7 @@ pub const RemoveDirStep = struct { | ... | @@ -3554,7 +3548,7 @@ pub const RemoveDirStep = struct { |
| 3554 | | 3548 | |
| 3555 | const full_path = self.builder.pathFromRoot(self.dir_path); | 3549 | const full_path = self.builder.pathFromRoot(self.dir_path); |
| 3556 | fs.cwd().deleteTree(full_path) catch |err| { | 3550 | fs.cwd().deleteTree(full_path) catch |err| { |
| 3557 | warn("Unable to remove {s}: {s}\n", .{ full_path, @errorName(err) }); | 3551 | log.err("Unable to remove {s}: {s}", .{ full_path, @errorName(err) }); |
| 3558 | return err; | 3552 | return err; |
| 3559 | }; | 3553 | }; |
| 3560 | } | 3554 | } |
| ... | @@ -3639,7 +3633,7 @@ fn doAtomicSymLinks(allocator: Allocator, output_path: []const u8, filename_majo | ... | @@ -3639,7 +3633,7 @@ fn doAtomicSymLinks(allocator: Allocator, output_path: []const u8, filename_majo |
| 3639 | &[_][]const u8{ out_dir, filename_major_only }, | 3633 | &[_][]const u8{ out_dir, filename_major_only }, |
| 3640 | ) catch unreachable; | 3634 | ) catch unreachable; |
| 3641 | fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { | 3635 | fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { |
| 3642 | warn("Unable to symlink {s} -> {s}\n", .{ major_only_path, out_basename }); | 3636 | log.err("Unable to symlink {s} -> {s}", .{ major_only_path, out_basename }); |
| 3643 | return err; | 3637 | return err; |
| 3644 | }; | 3638 | }; |
| 3645 | // sym link for libfoo.so to libfoo.so.1 | 3639 | // sym link for libfoo.so to libfoo.so.1 |
| ... | @@ -3648,7 +3642,7 @@ fn doAtomicSymLinks(allocator: Allocator, output_path: []const u8, filename_majo | ... | @@ -3648,7 +3642,7 @@ fn doAtomicSymLinks(allocator: Allocator, output_path: []const u8, filename_majo |
| 3648 | &[_][]const u8{ out_dir, filename_name_only }, | 3642 | &[_][]const u8{ out_dir, filename_name_only }, |
| 3649 | ) catch unreachable; | 3643 | ) catch unreachable; |
| 3650 | fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { | 3644 | fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { |
| 3651 | warn("Unable to symlink {s} -> {s}\n", .{ name_only_path, filename_major_only }); | 3645 | log.err("Unable to symlink {s} -> {s}", .{ name_only_path, filename_major_only }); |
| 3652 | return err; | 3646 | return err; |
| 3653 | }; | 3647 | }; |
| 3654 | } | 3648 | } |