authorgravatar for ian@ianjohnson.devIan Johnson <ian@ianjohnson.dev> 2024-03-27 23:25:21-04:00
committergravatar for ian@ianjohnson.devIan Johnson <ian@ianjohnson.dev> 2024-03-28 00:30:42-04:00
log3fb6bb144998de72d03b58e7c1daf134e2438373
tree97ed7faba6053f50b668cd76bbfc5bbe5ebbbc89
parent424dd17b6cc3db868c837f6b7a8fa36dac2166c1

std-docs: include builtin module in sources.tar

Now that `-femit-docs` includes all modules, including the builtin module, in the generated source tarball, it makes sense to apply the same logic to the std-docs server. std-docs constructs its own tarball, so a different approach is needed to achieve the same end result.

1 files changed, 20 insertions(+), 0 deletions(-)

lib/compiler/std-docs.zig+20
......@@ -177,6 +177,26 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void {
177177 try w.writeFile(file);
178178 try w.writeByteNTimes(0, padding);
179179 }
180
181 {
182 // Since this command is JIT compiled, the builtin module available in
183 // this source file corresponds to the user's host system.
184 const builtin_zig = @embedFile("builtin");
185
186 var file_header = std.tar.output.Header.init();
187 file_header.typeflag = .regular;
188 try file_header.setPath("builtin", "builtin.zig");
189 try file_header.setSize(builtin_zig.len);
190 try file_header.updateChecksum();
191 try w.writeAll(std.mem.asBytes(&file_header));
192 try w.writeAll(builtin_zig);
193 const padding = p: {
194 const remainder = builtin_zig.len % 512;
195 break :p if (remainder > 0) 512 - remainder else 0;
196 };
197 try w.writeByteNTimes(0, padding);
198 }
199
180200 // intentionally omitting the pointless trailer
181201 //try w.writeByteNTimes(0, 512 * 2);
182202 try response.end();