Skip to content

Commit ebb4686

Browse files
committed
Fix scaffold error handling and shim template syntax
1 parent 5c86c1a commit ebb4686

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎src/codegen/mod.rs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ pub fn generate_repo_only(manifest: &Manifest, output_dir: &str) -> Result<Scaff
9393
);
9494
}
9595
_ => {
96-
if let Some(msg) = result.error_message() {
97-
eprintln!("error: {}", msg);
98-
}
96+
anyhow::bail!(
97+
"{}",
98+
result.error_message().unwrap_or("unknown error")
99+
);
99100
}
100101
}
101102

@@ -131,9 +132,10 @@ pub fn generate_cartridge(
131132
);
132133
}
133134
_ => {
134-
if let Some(msg) = result.error_message() {
135-
eprintln!("error: {}", msg);
136-
}
135+
anyhow::bail!(
136+
"{}",
137+
result.error_message().unwrap_or("unknown error")
138+
);
137139
}
138140
}
139141

‎src/codegen/templates/cartridge_shim.zig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// Cartridges import this file by relative path (no build-graph change
1313
// needed). Example:
1414
//
15-
// const shim = @import("../../../ffi/zig/src/cartridge_shim.zig");
15+
// const shim = @import("ffi/cartridge_shim.zig");
1616
//
1717
// export fn boj_cartridge_invoke(
1818
// tool_name: [*c]const u8,
@@ -114,7 +114,7 @@ var shared_io_state: std.atomic.Value(u8) = .init(0); // 0=uninit 1=initing 2=re
114114
pub fn io() std.Io {
115115
if (shared_io_state.load(.acquire) != 2) {
116116
if (shared_io_state.cmpxchgStrong(0, 1, .acq_rel, .acquire) == null) {
117-
shared_threaded = std.Io.Threaded.init(std.heap.smp_allocator, .{});
117+
shared_threaded = std.Io.Threaded.init(std.heap.smp_allocator);
118118
shared_io_state.store(2, .release);
119119
} else {
120120
while (shared_io_state.load(.acquire) != 2) std.Thread.yield() catch {};
@@ -145,7 +145,7 @@ pub const Mutex = struct {
145145
/// Nanoseconds since the POSIX epoch (drop-in for the removed
146146
/// `std.time.nanoTimestamp`).
147147
pub fn nanoTimestamp() i128 {
148-
const ts = std.Io.Clock.Timestamp.now(io(), .real);
148+
const ts = std.Io.Clock.Timestamp.now(io(), .real) catch return 0;
149149
return @intCast(ts.raw.nanoseconds);
150150
}
151151

0 commit comments

Comments
 (0)