| ... | ... | @@ -3693,6 +3693,9 @@ fn workerDocsCopy(comp: *Compilation, wg: *WaitGroup) void { |
| 3693 | 3693 | } |
| 3694 | 3694 | |
| 3695 | 3695 | fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 3696 | const zcu = comp.module orelse |
| 3697 | return comp.lockAndSetMiscFailure(.docs_copy, "no Zig code to document", .{}); |
| 3698 | |
| 3696 | 3699 | const emit = comp.docs_emit.?; |
| 3697 | 3700 | var out_dir = emit.directory.handle.makeOpenPath(emit.sub_path, .{}) catch |err| { |
| 3698 | 3701 | return comp.lockAndSetMiscFailure( |
| ... | ... | @@ -3723,7 +3726,25 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 3723 | 3726 | }; |
| 3724 | 3727 | defer tar_file.close(); |
| 3725 | 3728 | |
| 3726 | | const root = comp.root_mod.root; |
| 3729 | var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{}; |
| 3730 | defer seen_table.deinit(comp.gpa); |
| 3731 | |
| 3732 | try seen_table.put(comp.gpa, zcu.main_mod, {}); |
| 3733 | try seen_table.put(comp.gpa, zcu.std_mod, {}); |
| 3734 | |
| 3735 | var i: usize = 0; |
| 3736 | while (i < seen_table.count()) : (i += 1) { |
| 3737 | const mod = seen_table.keys()[i]; |
| 3738 | try comp.docsCopyModule(mod, tar_file); |
| 3739 | |
| 3740 | const deps = mod.deps.values(); |
| 3741 | try seen_table.ensureUnusedCapacity(comp.gpa, deps.len); |
| 3742 | for (deps) |dep| seen_table.putAssumeCapacity(dep, {}); |
| 3743 | } |
| 3744 | } |
| 3745 | |
| 3746 | fn docsCopyModule(comp: *Compilation, module: *Package.Module, tar_file: std.fs.File) !void { |
| 3747 | const root = module.root; |
| 3727 | 3748 | const sub_path = if (root.sub_path.len == 0) "." else root.sub_path; |
| 3728 | 3749 | var mod_dir = root.root_dir.handle.openDir(sub_path, .{ .iterate = true }) catch |err| { |
| 3729 | 3750 | return comp.lockAndSetMiscFailure(.docs_copy, "unable to open directory '{}': {s}", .{ |
| ... | ... | @@ -3762,7 +3783,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { |
| 3762 | 3783 | |
| 3763 | 3784 | var file_header = std.tar.output.Header.init(); |
| 3764 | 3785 | file_header.typeflag = .regular; |
| 3765 | | try file_header.setPath(comp.root_name, entry.path); |
| 3786 | try file_header.setPath(module.fully_qualified_name, entry.path); |
| 3766 | 3787 | try file_header.setSize(stat.size); |
| 3767 | 3788 | try file_header.updateChecksum(); |
| 3768 | 3789 | |