From 267e72051d2b24cef79d077c487cb6beb910a987 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Wed, 30 Jun 2021 09:11:53 -0700 Subject: [PATCH] make services direct imports/pub const in generated service manifest --- codegen/src/main.zig | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/codegen/src/main.zig b/codegen/src/main.zig index 6c5e5ee..358ac1e 100644 --- a/codegen/src/main.zig +++ b/codegen/src/main.zig @@ -12,9 +12,7 @@ pub fn main() anyerror!void { const stdout = std.io.getStdOut().writer(); const manifest_file = try std.fs.cwd().createFile("service_manifest.zig", .{}); defer manifest_file.close(); - errdefer manifest_file.close(); const manifest = manifest_file.writer(); - _ = try manifest.write("pub const services = [_]struct { name: []const u8, file_name: []const u8, export_name: []const u8 }{\n"); var inx: u32 = 0; for (args) |arg| { if (inx == 0) { @@ -27,7 +25,6 @@ pub fn main() anyerror!void { if (args.len == 0) _ = try generateServices(allocator, ";", std.io.getStdIn(), stdout); - _ = try manifest.write("};\n"); } fn processFile(arg: []const u8, stdout: anytype, manifest: anytype) !void { @@ -57,9 +54,7 @@ fn processFile(arg: []const u8, stdout: anytype, manifest: anytype) !void { } file.close(); for (service_names) |name| { - _ = try manifest.write(" .{"); - try manifest.print(" .name = \"{s}\", .file_name = \"{s}\", .export_name = \"{s}\"", .{ name, std.fs.path.basename(filename), name }); - _ = try manifest.write(" },\n"); + try manifest.print("pub const {s} = @import(\"{s}\");\n", .{ name, std.fs.path.basename(filename) }); } }