Compare commits

...

2 Commits

Author SHA1 Message Date
4a6f49ac3b
add verbose flag to diagnose CI/CD
Some checks failed
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Failing after 1m40s
2023-08-15 07:21:56 -07:00
4dacca2d46
introduce verbosity 2023-08-14 22:56:19 -07:00
3 changed files with 13 additions and 8 deletions

View File

@ -23,7 +23,7 @@ jobs:
- run: tar x -C /usr/local -f zig-linux-${ARCH}-${ZIG_VERSION}.tar.xz
- run: ln -s /usr/local/zig-linux-${ARCH}-${ZIG_VERSION}/zig /usr/local/bin/zig
- run: apt update && apt install --no-install-recommends git
- run: zig build test
- run: zig build test --verbose
- run: zig build -Dtarget=arm-linux
- run: zig build -Dtarget=x86_64-windows
- run: zig build -Dtarget=aarch64-linux

View File

@ -82,7 +82,7 @@ pub fn build(b: *Builder) !void {
.root_source_file = .{ .path = "codegen/src/main.zig" },
// We need this generated for the host, not the real target
// .target = target,
.optimize = .ReleaseSafe,
.optimize = if (b.verbose) .Debug else .ReleaseSafe,
});
cg_exe.addModule("smithy", smithy_dep.module("smithy"));
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.addArg("--output");
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
// codegen should store a hash in a comment

View File

@ -3,6 +3,8 @@ const smithy = @import("smithy");
const snake = @import("snake.zig");
const json_zig = @embedFile("json.zig");
var verbose = false;
pub fn main() anyerror!void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
@ -20,7 +22,7 @@ pub fn main() anyerror!void {
if (std.mem.eql(u8, "--help", arg) or
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(" --output specifies an output directory, otherwise the current working directory will be used\n", .{});
std.process.exit(0);
@ -44,6 +46,11 @@ pub fn main() anyerror!void {
skip_next = false;
continue;
}
if (std.mem.eql(u8, "--verbose", arg)) {
verbose = true;
continue;
}
if (std.mem.eql(u8, "--models", arg) or
std.mem.eql(u8, "--output", arg))
{
@ -60,11 +67,7 @@ pub fn main() anyerror!void {
defer cwd.close();
defer cwd.setAsCwd() catch unreachable;
try stdout.print("orig cwd: {any}\n", .{cwd});
try m.dir.setAsCwd();
try stdout.print("cwd: {any}\n", .{m.dir});
// TODO: this is throwing an error?
// _ = cwd;
var mi = m.iterate();
while (try mi.next()) |e| {
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 serializeMap = @import(\"json.zig\").serializeMap;\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| {
std.log.err("Error processing file: {s}", .{file_name});
return err;