| author | |
| committer | |
| log | c3cdf484072d84f32e19c9286071a913269c90e9 |
| tree | a0be35e5e6b163f80eb94d4e8131d6de1754d1a6 |
| parent | 2c18bccf4428a6e23ed5c5572243337a560af9b5 |
steps are many; unlazy dependencies are few4 files changed, 57 insertions(+), 24 deletions(-)
lib/compiler/Maker.zig+16-8| ... | ... | @@ -1608,16 +1608,24 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1608 | 1608 | |
| 1609 | 1609 | if (configuration.unlazy_deps.len != 0) { |
| 1610 | 1610 | var any_errors = false; |
| 1611 | for (configuration.unlazy_deps) |hash_string| { | |
| 1612 | const hash = hash_string.slice(&configuration); | |
| 1613 | assert(hash.len != 0); | |
| 1614 | if (hash.len > Package.Hash.max_len) { | |
| 1615 | log.err("invalid digest (length {d} exceeds maximum): {q}", .{ hash.len, hash }); | |
| 1611 | for (configuration.unlazy_deps) |unlazy_dep| { | |
| 1612 | if (unlazy_dep.step.unwrap()) |step_index| { | |
| 1613 | log.err("TODO implement step-associated lazy dependencies in maker", .{}); | |
| 1616 | 1614 | any_errors = true; |
| 1617 | continue; | |
| 1615 | _ = step_index; | |
| 1616 | } else { | |
| 1617 | for (unlazy_dep.list.slice(&configuration)) |hash_string| { | |
| 1618 | const hash = hash_string.slice(&configuration); | |
| 1619 | assert(hash.len != 0); | |
| 1620 | if (hash.len > Package.Hash.max_len) { | |
| 1621 | log.err("invalid digest (length {d} exceeds maximum): {q}", .{ hash.len, hash }); | |
| 1622 | any_errors = true; | |
| 1623 | continue; | |
| 1624 | } | |
| 1625 | log.info("fetching lazy dependency {s}", .{hash}); | |
| 1626 | try unlazy_set.put(arena, .fromSlice(hash), {}); | |
| 1627 | } | |
| 1618 | 1628 | } |
| 1619 | log.info("fetching lazy dependency {s}", .{hash}); | |
| 1620 | try unlazy_set.put(arena, .fromSlice(hash), {}); | |
| 1621 | 1629 | } |
| 1622 | 1630 | if (any_errors) return error.FailedButCacheIntact; |
| 1623 | 1631 | if (options.system_pkg_dir_path) |p| { |
lib/compiler/Maker/ScannedConfig.zig+3-1| ... | ... | @@ -55,7 +55,9 @@ pub fn print(sc: *const ScannedConfig, w: *Writer) Writer.Error!void { |
| 55 | 55 | { |
| 56 | 56 | var tf = try s.beginTupleField("unlazy_deps", .{}); |
| 57 | 57 | for (c.unlazy_deps) |dep| { |
| 58 | try tf.field(dep.slice(c), .{}); | |
| 58 | var field = try tf.beginStructField(.{}); | |
| 59 | try printStruct(sc, &field, Configuration.UnlazyDep, dep); | |
| 60 | try field.end(); | |
| 59 | 61 | } |
| 60 | 62 | try tf.end(); |
| 61 | 63 | } |
lib/std/Build/Configuration.zig+26-4| ... | ... | @@ -11,7 +11,7 @@ const native_endian = builtin.target.cpu.arch.endian(); |
| 11 | 11 | string_bytes: []u8, |
| 12 | 12 | steps: []Step, |
| 13 | 13 | path_deps: []PathDep, |
| 14 | unlazy_deps: []String, | |
| 14 | unlazy_deps: []UnlazyDep, | |
| 15 | 15 | system_integrations: []SystemIntegration, |
| 16 | 16 | available_options: []AvailableOption, |
| 17 | 17 | search_prefixes: []String, |
| ... | ... | @@ -52,7 +52,7 @@ pub const Wip = struct { |
| 52 | 52 | targets_table: TargetsTable = .empty, |
| 53 | 53 | |
| 54 | 54 | string_bytes: std.ArrayList(u8) = .empty, |
| 55 | unlazy_deps: std.ArrayList(String) = .empty, | |
| 55 | unlazy_deps: std.ArrayList(UnlazyDep) = .empty, | |
| 56 | 56 | system_integrations: std.ArrayList(SystemIntegration) = .empty, |
| 57 | 57 | available_options: std.ArrayList(AvailableOption) = .empty, |
| 58 | 58 | steps: std.ArrayList(Step) = .empty, |
| ... | ... | @@ -495,12 +495,17 @@ pub const AvailableOption = extern struct { |
| 495 | 495 | }; |
| 496 | 496 | }; |
| 497 | 497 | |
| 498 | pub const UnlazyDep = extern struct { | |
| 499 | /// none indicates not associated with any particular step. | |
| 500 | step: Step.OptionalIndex, | |
| 501 | list: StringList, | |
| 502 | }; | |
| 503 | ||
| 498 | 504 | pub const Step = extern struct { |
| 499 | 505 | name: String, |
| 500 | 506 | owner: Package.Index, |
| 501 | 507 | deps: Deps.Index, |
| 502 | 508 | max_rss: MaxRss, |
| 503 | unlazy_deps: OptionalStringList, | |
| 504 | 509 | extended: Storage.Extended(Flags, union(Tag) { |
| 505 | 510 | check_file: CheckFile, |
| 506 | 511 | compile: Compile, |
| ... | ... | @@ -529,6 +534,23 @@ pub const Step = extern struct { |
| 529 | 534 | } |
| 530 | 535 | }; |
| 531 | 536 | |
| 537 | pub const OptionalIndex = enum(u32) { | |
| 538 | none = max_u32, | |
| 539 | _, | |
| 540 | ||
| 541 | pub fn unwrap(this: @This()) ?Index { | |
| 542 | return switch (this) { | |
| 543 | .none => null, | |
| 544 | else => @fromBackingInt(@intCast(@backingInt(this))), | |
| 545 | }; | |
| 546 | } | |
| 547 | ||
| 548 | pub fn ptr(i: @This(), c: *const Configuration) ?*const Step { | |
| 549 | if (i == .none) return null; | |
| 550 | return &c.steps[@backingInt(i)]; | |
| 551 | } | |
| 552 | }; | |
| 553 | ||
| 532 | 554 | /// Shared by all steps. |
| 533 | 555 | pub const Flags = packed struct(u32) { |
| 534 | 556 | tag: Tag, |
| ... | ... | @@ -3156,7 +3178,7 @@ pub fn load(arena: Allocator, reader: *Io.Reader) LoadError!Configuration { |
| 3156 | 3178 | .string_bytes = try arena.alloc(u8, header.string_bytes_len), |
| 3157 | 3179 | .steps = try arena.alloc(Step, header.steps_len), |
| 3158 | 3180 | .path_deps = try arena.alloc(PathDep, header.path_deps_len), |
| 3159 | .unlazy_deps = try arena.alloc(String, header.unlazy_deps_len), | |
| 3181 | .unlazy_deps = try arena.alloc(UnlazyDep, header.unlazy_deps_len), | |
| 3160 | 3182 | .system_integrations = try arena.alloc(SystemIntegration, header.system_integrations_len), |
| 3161 | 3183 | .available_options = try arena.alloc(AvailableOption, header.available_options_len), |
| 3162 | 3184 | .search_prefixes = try arena.alloc(String, header.search_prefixes_len), |
lib/std/Build/Serialize.zig+12-11| ... | ... | @@ -681,22 +681,23 @@ pub fn write(b: *std.Build, wc: *Configuration.Wip, writer: *std.Io.Writer) !voi |
| 681 | 681 | .owner = try s.builderToPackage(step.owner), |
| 682 | 682 | .deps = deps, |
| 683 | 683 | .max_rss = .fromBytes(step.max_rss), |
| 684 | .unlazy_deps = if (step.unlazy_deps.count() != 0) | |
| 685 | .init(try wc.addStringListInterned(step.unlazy_deps.keys())) | |
| 686 | else | |
| 687 | .none, | |
| 688 | 684 | .extended = @fromBackingInt(extended), |
| 689 | 685 | }); |
| 686 | ||
| 687 | if (step.unlazy_deps.count() != 0) { | |
| 688 | try wc.unlazy_deps.append(gpa, .{ | |
| 689 | .step = @fromBackingInt(@intCast(wc.steps.items.len - 1)), | |
| 690 | .list = try wc.addStringListInterned(step.unlazy_deps.keys()), | |
| 691 | }); | |
| 692 | } | |
| 690 | 693 | } |
| 691 | 694 | } |
| 692 | 695 | |
| 693 | { | |
| 694 | // TODO exchange graph.unlazy_deps.keys with the wc.unlazy_deps array list without copying | |
| 695 | // MultiArrayList should support this when there is only 1 non zero sized struct field | |
| 696 | const unlazy_deps = graph.unlazy_deps.keys(); | |
| 697 | try wc.unlazy_deps.ensureTotalCapacityPrecise(gpa, unlazy_deps.len); | |
| 698 | assert(wc.unlazy_deps.items.len == 0); | |
| 699 | wc.unlazy_deps.appendSliceAssumeCapacity(unlazy_deps); | |
| 696 | if (graph.unlazy_deps.count() != 0) { | |
| 697 | try wc.unlazy_deps.append(gpa, .{ | |
| 698 | .step = .none, | |
| 699 | .list = try wc.addStringListInterned(graph.unlazy_deps.keys()), | |
| 700 | }); | |
| 700 | 701 | } |
| 701 | 702 | |
| 702 | 703 | try wc.write(writer, .{ |