| ... | ... | @@ -397,9 +397,25 @@ pub const Step = extern struct { |
| 397 | 397 | owner: Package.Index, |
| 398 | 398 | deps: Deps, |
| 399 | 399 | max_rss: MaxRss, |
| 400 | | /// Points into `extra` for step-specific data. First element has flags |
| 401 | | /// with `Tag`. |
| 402 | | extra_index: u32, |
| 400 | extended: Storage.ExtendedIndex(Flags, union(Tag) { |
| 401 | check_file: CheckFile, |
| 402 | check_object: CheckObject, |
| 403 | compile: Compile, |
| 404 | config_header: ConfigHeader, |
| 405 | fail: Fail, |
| 406 | fmt: Fmt, |
| 407 | install_artifact: InstallArtifact, |
| 408 | install_dir: InstallDir, |
| 409 | install_file: InstallFile, |
| 410 | objcopy: Objcopy, |
| 411 | options: Options, |
| 412 | remove_dir: RemoveDir, |
| 413 | run: Run, |
| 414 | top_level: TopLevel, |
| 415 | translate_c: TranslateC, |
| 416 | update_source_files: UpdateSourceFiles, |
| 417 | write_file: WriteFile, |
| 418 | }), |
| 403 | 419 | |
| 404 | 420 | /// Points into `steps`. |
| 405 | 421 | pub const Index = enum(u32) { |
| ... | ... | @@ -449,17 +465,17 @@ pub const Step = extern struct { |
| 449 | 465 | pub const InstallArtifact = struct { |
| 450 | 466 | flags: @This().Flags, |
| 451 | 467 | |
| 452 | | dest_dir: InstallDir, |
| 468 | dest_dir: InstallDestDir, |
| 453 | 469 | dest_sub_path: String, |
| 454 | 470 | emitted_bin: OptionalLazyPath, |
| 455 | 471 | |
| 456 | | implib_dir: InstallDir, |
| 472 | implib_dir: InstallDestDir, |
| 457 | 473 | emitted_implib: OptionalLazyPath, |
| 458 | 474 | |
| 459 | | pdb_dir: InstallDir, |
| 475 | pdb_dir: InstallDestDir, |
| 460 | 476 | emitted_pdb: OptionalLazyPath, |
| 461 | 477 | |
| 462 | | h_dir: InstallDir, |
| 478 | h_dir: InstallDestDir, |
| 463 | 479 | emitted_h: OptionalLazyPath, |
| 464 | 480 | |
| 465 | 481 | /// Always a compile step. |
| ... | ... | @@ -789,8 +805,125 @@ pub const Step = extern struct { |
| 789 | 805 | }; |
| 790 | 806 | }; |
| 791 | 807 | |
| 808 | pub const CheckFile = struct { |
| 809 | flags: @This().Flags, |
| 810 | |
| 811 | pub const Flags = packed struct(u32) { |
| 812 | tag: Tag = .check_file, |
| 813 | _: u27 = 0, |
| 814 | }; |
| 815 | }; |
| 816 | |
| 817 | pub const CheckObject = struct { |
| 818 | flags: @This().Flags, |
| 819 | |
| 820 | pub const Flags = packed struct(u32) { |
| 821 | tag: Tag = .check_object, |
| 822 | _: u27 = 0, |
| 823 | }; |
| 824 | }; |
| 825 | |
| 826 | pub const ConfigHeader = struct { |
| 827 | flags: @This().Flags, |
| 828 | |
| 829 | pub const Flags = packed struct(u32) { |
| 830 | tag: Tag = .config_header, |
| 831 | _: u27 = 0, |
| 832 | }; |
| 833 | }; |
| 834 | |
| 835 | pub const Fail = struct { |
| 836 | flags: @This().Flags, |
| 837 | |
| 838 | pub const Flags = packed struct(u32) { |
| 839 | tag: Tag = .fail, |
| 840 | _: u27 = 0, |
| 841 | }; |
| 842 | }; |
| 843 | |
| 844 | pub const Fmt = struct { |
| 845 | flags: @This().Flags, |
| 846 | |
| 847 | pub const Flags = packed struct(u32) { |
| 848 | tag: Tag = .fmt, |
| 849 | _: u27 = 0, |
| 850 | }; |
| 851 | }; |
| 852 | |
| 853 | pub const InstallDir = struct { |
| 854 | flags: @This().Flags, |
| 855 | |
| 856 | pub const Flags = packed struct(u32) { |
| 857 | tag: Tag = .install_dir, |
| 858 | _: u27 = 0, |
| 859 | }; |
| 860 | }; |
| 861 | |
| 862 | pub const InstallFile = struct { |
| 863 | flags: @This().Flags, |
| 864 | |
| 865 | pub const Flags = packed struct(u32) { |
| 866 | tag: Tag = .install_file, |
| 867 | _: u27 = 0, |
| 868 | }; |
| 869 | }; |
| 870 | |
| 871 | pub const Objcopy = struct { |
| 872 | flags: @This().Flags, |
| 873 | |
| 874 | pub const Flags = packed struct(u32) { |
| 875 | tag: Tag = .objcopy, |
| 876 | _: u27 = 0, |
| 877 | }; |
| 878 | }; |
| 879 | |
| 880 | pub const Options = struct { |
| 881 | flags: @This().Flags, |
| 882 | |
| 883 | pub const Flags = packed struct(u32) { |
| 884 | tag: Tag = .options, |
| 885 | _: u27 = 0, |
| 886 | }; |
| 887 | }; |
| 888 | |
| 889 | pub const RemoveDir = struct { |
| 890 | flags: @This().Flags, |
| 891 | |
| 892 | pub const Flags = packed struct(u32) { |
| 893 | tag: Tag = .remove_dir, |
| 894 | _: u27 = 0, |
| 895 | }; |
| 896 | }; |
| 897 | |
| 898 | pub const TranslateC = struct { |
| 899 | flags: @This().Flags, |
| 900 | |
| 901 | pub const Flags = packed struct(u32) { |
| 902 | tag: Tag = .translate_c, |
| 903 | _: u27 = 0, |
| 904 | }; |
| 905 | }; |
| 906 | |
| 907 | pub const UpdateSourceFiles = struct { |
| 908 | flags: @This().Flags, |
| 909 | |
| 910 | pub const Flags = packed struct(u32) { |
| 911 | tag: Tag = .update_source_files, |
| 912 | _: u27 = 0, |
| 913 | }; |
| 914 | }; |
| 915 | |
| 916 | pub const WriteFile = struct { |
| 917 | flags: @This().Flags, |
| 918 | |
| 919 | pub const Flags = packed struct(u32) { |
| 920 | tag: Tag = .write_file, |
| 921 | _: u27 = 0, |
| 922 | }; |
| 923 | }; |
| 924 | |
| 792 | 925 | pub fn flags(s: *const Step, c: *const Configuration) Flags { |
| 793 | | return @bitCast(c.extra[s.extra_index]); |
| 926 | return @bitCast(c.extra[@intFromEnum(s.extended)]); |
| 794 | 927 | } |
| 795 | 928 | }; |
| 796 | 929 | |
| ... | ... | @@ -1081,7 +1214,7 @@ pub const Path = extern struct { |
| 1081 | 1214 | } |
| 1082 | 1215 | }; |
| 1083 | 1216 | |
| 1084 | | pub const InstallDir = enum(u32) { |
| 1217 | pub const InstallDestDir = enum(u32) { |
| 1085 | 1218 | none = maxInt(u32) - 4, |
| 1086 | 1219 | prefix = maxInt(u32) - 3, |
| 1087 | 1220 | lib = maxInt(u32) - 2, |
| ... | ... | @@ -1090,8 +1223,8 @@ pub const InstallDir = enum(u32) { |
| 1090 | 1223 | /// A `String` path relative to the prefix. |
| 1091 | 1224 | _, |
| 1092 | 1225 | |
| 1093 | | pub fn initCustom(sub_path: String) InstallDir { |
| 1094 | | assert(@intFromEnum(sub_path) < @intFromEnum(InstallDir.none)); |
| 1226 | pub fn initCustom(sub_path: String) InstallDestDir { |
| 1227 | assert(@intFromEnum(sub_path) < @intFromEnum(InstallDestDir.none)); |
| 1095 | 1228 | return @enumFromInt(@intFromEnum(sub_path)); |
| 1096 | 1229 | } |
| 1097 | 1230 | }; |
| ... | ... | @@ -1496,7 +1629,10 @@ pub const TargetQuery = struct { |
| 1496 | 1629 | |
| 1497 | 1630 | pub const Storage = enum { |
| 1498 | 1631 | flag_optional, |
| 1632 | extended, |
| 1499 | 1633 | |
| 1634 | /// The presence of the field is determined by a boolean within a packed |
| 1635 | /// struct. |
| 1500 | 1636 | pub fn FlagOptional( |
| 1501 | 1637 | comptime flags_arg: @EnumLiteral(), |
| 1502 | 1638 | comptime flag_arg: @EnumLiteral(), |
| ... | ... | @@ -1512,6 +1648,31 @@ pub const Storage = enum { |
| 1512 | 1648 | }; |
| 1513 | 1649 | } |
| 1514 | 1650 | |
| 1651 | /// The field indexes into an auxilary buffer, with the first element being |
| 1652 | /// a packed struct that contains the tag. |
| 1653 | pub fn Extended(comptime U: type) type { |
| 1654 | return struct { |
| 1655 | value: U, |
| 1656 | |
| 1657 | pub const storage: Storage = .extended; |
| 1658 | }; |
| 1659 | } |
| 1660 | |
| 1661 | /// Equivalent to `Extended` but works in an `extern struct`. |
| 1662 | pub fn ExtendedIndex(comptime BaseFlags: type, comptime U: type) type { |
| 1663 | return enum(u32) { |
| 1664 | _, |
| 1665 | |
| 1666 | pub fn get(this: @This(), buffer: []const u32) U { |
| 1667 | var i: usize = @intFromEnum(this); |
| 1668 | const base_flags: BaseFlags = @bitCast(buffer[i]); |
| 1669 | return switch (base_flags.tag) { |
| 1670 | inline else => |tag| @unionInit(U, @tagName(tag), data(buffer, &i, @FieldType(U, @tagName(tag)))), |
| 1671 | }; |
| 1672 | } |
| 1673 | }; |
| 1674 | } |
| 1675 | |
| 1515 | 1676 | pub fn dataLength(buffer: []const u32, i: usize, comptime S: type) usize { |
| 1516 | 1677 | var end = i; |
| 1517 | 1678 | _ = data(buffer, &end, S); |
| ... | ... | @@ -1536,7 +1697,7 @@ pub const Storage = enum { |
| 1536 | 1697 | }, |
| 1537 | 1698 | 64 => { |
| 1538 | 1699 | defer i.* += 2; |
| 1539 | | return buffer[i.*..][0..2].*; |
| 1700 | return @bitCast(buffer[i.*..][0..2].*); |
| 1540 | 1701 | }, |
| 1541 | 1702 | else => comptime unreachable, |
| 1542 | 1703 | }, |
| ... | ... | @@ -1573,6 +1734,7 @@ pub const Storage = enum { |
| 1573 | 1734 | .value = if (flag) dataField(buffer, i, container, Field.Value) else null, |
| 1574 | 1735 | }; |
| 1575 | 1736 | }, |
| 1737 | .extended => @compileError("TODO"), |
| 1576 | 1738 | }, |
| 1577 | 1739 | }, |
| 1578 | 1740 | .@"extern" => comptime unreachable, |
| ... | ... | @@ -1639,6 +1801,7 @@ pub const Storage = enum { |
| 1639 | 1801 | .flag_optional => { |
| 1640 | 1802 | return if (value.value) |v| setExtraField(buffer, i, Field.Value, v) else 0; |
| 1641 | 1803 | }, |
| 1804 | .extended => @compileError("TODO"), |
| 1642 | 1805 | }, |
| 1643 | 1806 | }, |
| 1644 | 1807 | .@"extern" => comptime unreachable, |
| ... | ... | @@ -1662,7 +1825,7 @@ pub const Storage = enum { |
| 1662 | 1825 | else => comptime unreachable, |
| 1663 | 1826 | }, |
| 1664 | 1827 | .auto => switch (Field.storage) { |
| 1665 | | .flag_optional => 1, |
| 1828 | .flag_optional, .extended => 1, |
| 1666 | 1829 | }, |
| 1667 | 1830 | .@"extern" => comptime unreachable, |
| 1668 | 1831 | }, |