| ... | ... | @@ -119,7 +119,6 @@ fn serveDocsFile( |
| 119 | 119 | const file_contents = try context.lib_dir.readFileAlloc(gpa, name, 10 * 1024 * 1024); |
| 120 | 120 | defer gpa.free(file_contents); |
| 121 | 121 | try request.respond(file_contents, .{ |
| 122 | | .status = .ok, |
| 123 | 122 | .extra_headers = &.{ |
| 124 | 123 | .{ .name = "content-type", .value = content_type }, |
| 125 | 124 | cache_control_header, |
| ... | ... | @@ -128,9 +127,46 @@ fn serveDocsFile( |
| 128 | 127 | } |
| 129 | 128 | |
| 130 | 129 | fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void { |
| 131 | | _ = request; |
| 132 | | _ = context; |
| 133 | | @panic("TODO"); |
| 130 | const gpa = context.gpa; |
| 131 | |
| 132 | var send_buffer: [0x4000]u8 = undefined; |
| 133 | var response = request.respondStreaming(.{ |
| 134 | .send_buffer = &send_buffer, |
| 135 | .respond_options = .{ |
| 136 | .extra_headers = &.{ |
| 137 | .{ .name = "content-type", .value = "application/x-tar" }, |
| 138 | cache_control_header, |
| 139 | }, |
| 140 | }, |
| 141 | }); |
| 142 | const w = response.writer(); |
| 143 | try w.writeAll("tar header"); |
| 144 | |
| 145 | var std_dir = try context.lib_dir.openDir("std", .{ .iterate = true }); |
| 146 | defer std_dir.close(); |
| 147 | |
| 148 | var walker = try std_dir.walk(gpa); |
| 149 | defer walker.deinit(); |
| 150 | |
| 151 | while (try walker.next()) |entry| { |
| 152 | switch (entry.kind) { |
| 153 | .file => { |
| 154 | if (!std.mem.endsWith(u8, entry.basename, ".zig")) |
| 155 | continue; |
| 156 | if (std.mem.endsWith(u8, entry.basename, "test.zig")) |
| 157 | continue; |
| 158 | }, |
| 159 | else => continue, |
| 160 | } |
| 161 | |
| 162 | try w.writeAll(entry.path); |
| 163 | |
| 164 | var file = try std_dir.openFile(entry.path, .{}); |
| 165 | defer file.close(); |
| 166 | |
| 167 | try w.writeFile(file); |
| 168 | } |
| 169 | try response.end(); |
| 134 | 170 | } |
| 135 | 171 | |
| 136 | 172 | fn serveWasm( |
| ... | ... | @@ -151,7 +187,6 @@ fn serveWasm( |
| 151 | 187 | const file_contents = try std.fs.cwd().readFileAlloc(gpa, wasm_binary_path, 10 * 1024 * 1024); |
| 152 | 188 | defer gpa.free(file_contents); |
| 153 | 189 | try request.respond(file_contents, .{ |
| 154 | | .status = .ok, |
| 155 | 190 | .extra_headers = &.{ |
| 156 | 191 | .{ .name = "content-type", .value = "application/wasm" }, |
| 157 | 192 | cache_control_header, |
| ... | ... | @@ -250,7 +285,7 @@ fn buildWasmBinary( |
| 250 | 285 | const EbpHdr = std.zig.Server.Message.EmitBinPath; |
| 251 | 286 | const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); |
| 252 | 287 | if (!ebp_hdr.flags.cache_hit) { |
| 253 | | std.log.info("source changes detected; rebuilding wasm component", .{}); |
| 288 | std.log.info("source changes detected; rebuilt wasm component", .{}); |
| 254 | 289 | } |
| 255 | 290 | result = try arena.dupe(u8, body[@sizeOf(EbpHdr)..]); |
| 256 | 291 | }, |