introduce verbosity
This commit is contained in:
parent
cbb6116a61
commit
4dacca2d46
|
@ -82,7 +82,7 @@ pub fn build(b: *Builder) !void {
|
||||||
.root_source_file = .{ .path = "codegen/src/main.zig" },
|
.root_source_file = .{ .path = "codegen/src/main.zig" },
|
||||||
// We need this generated for the host, not the real target
|
// We need this generated for the host, not the real target
|
||||||
// .target = target,
|
// .target = target,
|
||||||
.optimize = .ReleaseSafe,
|
.optimize = if (b.verbose) .Debug else .ReleaseSafe,
|
||||||
});
|
});
|
||||||
cg_exe.addModule("smithy", smithy_dep.module("smithy"));
|
cg_exe.addModule("smithy", smithy_dep.module("smithy"));
|
||||||
var cg_cmd = b.addRunArtifact(cg_exe);
|
var cg_cmd = b.addRunArtifact(cg_exe);
|
||||||
|
@ -90,6 +90,8 @@ pub fn build(b: *Builder) !void {
|
||||||
cg_cmd.addDirectoryArg(std.Build.FileSource.relative("codegen/models"));
|
cg_cmd.addDirectoryArg(std.Build.FileSource.relative("codegen/models"));
|
||||||
cg_cmd.addArg("--output");
|
cg_cmd.addArg("--output");
|
||||||
cg_cmd.addDirectoryArg(std.Build.FileSource.relative("src/models"));
|
cg_cmd.addDirectoryArg(std.Build.FileSource.relative("src/models"));
|
||||||
|
if (b.verbose)
|
||||||
|
cg_cmd.addArg("--verbose");
|
||||||
|
|
||||||
// TODO: this should use zig_exe from std.Build
|
// TODO: this should use zig_exe from std.Build
|
||||||
// codegen should store a hash in a comment
|
// codegen should store a hash in a comment
|
||||||
|
|
|
@ -3,6 +3,8 @@ const smithy = @import("smithy");
|
||||||
const snake = @import("snake.zig");
|
const snake = @import("snake.zig");
|
||||||
const json_zig = @embedFile("json.zig");
|
const json_zig = @embedFile("json.zig");
|
||||||
|
|
||||||
|
var verbose = false;
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
|
@ -20,7 +22,7 @@ pub fn main() anyerror!void {
|
||||||
if (std.mem.eql(u8, "--help", arg) or
|
if (std.mem.eql(u8, "--help", arg) or
|
||||||
std.mem.eql(u8, "-h", arg))
|
std.mem.eql(u8, "-h", arg))
|
||||||
{
|
{
|
||||||
try stdout.print("usage: {s} [--models dir] [--output dir] [file...]\n\n", .{args[0]});
|
try stdout.print("usage: {s} [--verbose] [--models dir] [--output dir] [file...]\n\n", .{args[0]});
|
||||||
try stdout.print(" --models specifies a directory with all model files (do not specify files if --models is used)\n", .{});
|
try stdout.print(" --models specifies a directory with all model files (do not specify files if --models is used)\n", .{});
|
||||||
try stdout.print(" --output specifies an output directory, otherwise the current working directory will be used\n", .{});
|
try stdout.print(" --output specifies an output directory, otherwise the current working directory will be used\n", .{});
|
||||||
std.process.exit(0);
|
std.process.exit(0);
|
||||||
|
@ -44,6 +46,11 @@ pub fn main() anyerror!void {
|
||||||
skip_next = false;
|
skip_next = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (std.mem.eql(u8, "--verbose", arg)) {
|
||||||
|
verbose = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (std.mem.eql(u8, "--models", arg) or
|
if (std.mem.eql(u8, "--models", arg) or
|
||||||
std.mem.eql(u8, "--output", arg))
|
std.mem.eql(u8, "--output", arg))
|
||||||
{
|
{
|
||||||
|
@ -60,11 +67,7 @@ pub fn main() anyerror!void {
|
||||||
defer cwd.close();
|
defer cwd.close();
|
||||||
defer cwd.setAsCwd() catch unreachable;
|
defer cwd.setAsCwd() catch unreachable;
|
||||||
|
|
||||||
try stdout.print("orig cwd: {any}\n", .{cwd});
|
|
||||||
try m.dir.setAsCwd();
|
try m.dir.setAsCwd();
|
||||||
try stdout.print("cwd: {any}\n", .{m.dir});
|
|
||||||
// TODO: this is throwing an error?
|
|
||||||
// _ = cwd;
|
|
||||||
var mi = m.iterate();
|
var mi = m.iterate();
|
||||||
while (try mi.next()) |e| {
|
while (try mi.next()) |e| {
|
||||||
if ((e.kind == .file or e.kind == .sym_link) and
|
if ((e.kind == .file or e.kind == .sym_link) and
|
||||||
|
@ -96,7 +99,7 @@ fn processFile(file_name: []const u8, stdout: anytype, output_dir: std.fs.Dir, m
|
||||||
_ = try writer.write("const std = @import(\"std\");\n");
|
_ = try writer.write("const std = @import(\"std\");\n");
|
||||||
_ = try writer.write("const serializeMap = @import(\"json.zig\").serializeMap;\n");
|
_ = try writer.write("const serializeMap = @import(\"json.zig\").serializeMap;\n");
|
||||||
_ = try writer.write("const smithy = @import(\"smithy\");\n\n");
|
_ = try writer.write("const smithy = @import(\"smithy\");\n\n");
|
||||||
std.log.info("Processing file: {s}", .{file_name});
|
if (verbose) std.log.info("Processing file: {s}", .{file_name});
|
||||||
const service_names = generateServicesForFilePath(allocator, ";", file_name, writer) catch |err| {
|
const service_names = generateServicesForFilePath(allocator, ";", file_name, writer) catch |err| {
|
||||||
std.log.err("Error processing file: {s}", .{file_name});
|
std.log.err("Error processing file: {s}", .{file_name});
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user