Compare commits
2 Commits
cbb6116a61
...
4a6f49ac3b
Author | SHA1 | Date | |
---|---|---|---|
4a6f49ac3b | |||
4dacca2d46 |
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user