Skip to content

Commit b9b9718

Browse files
committed
fix build asset install & upgrade to writergate
only took 6h45m to upgrade to writergate :^) also build assets now install correctly
1 parent 237ef14 commit b9b9718

37 files changed

Lines changed: 703 additions & 601 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ jobs:
2828
fetch-depth: 0 # Change if you need git info
2929

3030
- name: Setup Zig
31-
uses: mlugg/setup-zig@v1
32-
with:
33-
version: 0.14.0
31+
uses: mlugg/setup-zig@v2
3432

3533
- name: Build
3634
run: zig build test

build.zig

Lines changed: 64 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ pub fn build(b: *std.Build) !void {
176176

177177
const options = blk: {
178178
const options = b.addOptions();
179-
const out = options.contents.writer();
180-
try out.print(
179+
try options.contents.print(b.allocator,
181180
\\// module = zine
182181
\\const std = @import("std");
183182
\\pub const tsan = {};
@@ -187,10 +186,10 @@ pub fn build(b: *std.Build) !void {
187186
\\
188187
, .{ tsan, highlight, version.string() });
189188

190-
for (scopes) |l| try out.print(
191-
\\.{{.scope = .{s}, .level = .debug}},
192-
, std.zig.fmtId(l));
193-
try out.writeAll("};");
189+
for (scopes) |l| try options.contents.print(b.allocator,
190+
\\.{{.scope = .{f}, .level = .debug}},
191+
, .{std.zig.fmtId(l)});
192+
try options.contents.print(b.allocator, "}};", .{});
194193
break :blk options.createModule();
195194
};
196195

@@ -242,9 +241,11 @@ pub fn build(b: *std.Build) !void {
242241

243242
const shtml_docgen = b.addExecutable(.{
244243
.name = "shtml_docgen",
245-
.root_source_file = b.path("src/docgen.zig"),
246-
.target = target,
247-
.optimize = .Debug,
244+
.root_module = b.createModule(.{
245+
.root_source_file = b.path("src/docgen.zig"),
246+
.target = target,
247+
.optimize = .Debug,
248+
}),
248249
});
249250
shtml_docgen.root_module.addImport("zeit", zeit);
250251
shtml_docgen.root_module.addImport("ziggy", ziggy);
@@ -270,24 +271,34 @@ pub fn build(b: *std.Build) !void {
270271
// setup the Zine standalone executable
271272
const zine_exe = b.addExecutable(.{
272273
.name = "zine",
273-
.root_source_file = b.path("src/main.zig"),
274-
.target = target,
275-
.optimize = optimize,
276-
.single_threaded = b.option(
277-
bool,
278-
"single-threaded",
279-
"build Zine in single-threaded mode",
280-
) orelse false,
281-
282-
.sanitize_thread = tsan,
274+
.root_module = b.createModule(.{
275+
.root_source_file = b.path("src/main.zig"),
276+
.target = target,
277+
.optimize = optimize,
278+
.single_threaded = b.option(
279+
bool,
280+
"single-threaded",
281+
"build Zine in single-threaded mode",
282+
) orelse false,
283+
284+
.sanitize_thread = tsan,
285+
}),
283286
});
284287

285-
if (target.result.os.tag == .macos) {
286-
const frameworks = b.lazyDependency("frameworks", .{}) orelse return;
287-
zine_exe.addIncludePath(frameworks.path("include"));
288-
zine_exe.addFrameworkPath(frameworks.path("Frameworks"));
289-
zine_exe.addLibraryPath(frameworks.path("lib"));
290-
zine_exe.linkFramework("CoreServices");
288+
switch (target.result.os.tag) {
289+
else => @panic("target must be added to build.zig"),
290+
.linux => {},
291+
292+
.windows => {
293+
zine_exe.linkSystemLibrary("ws2_32");
294+
},
295+
.macos => {
296+
const frameworks = b.lazyDependency("frameworks", .{}) orelse return;
297+
zine_exe.addIncludePath(frameworks.path("include"));
298+
zine_exe.addFrameworkPath(frameworks.path("Frameworks"));
299+
zine_exe.addLibraryPath(frameworks.path("lib"));
300+
zine_exe.linkFramework("CoreServices");
301+
},
291302
}
292303

293304
// zine_exe.root_module.addImport("zine", zine);
@@ -325,9 +336,11 @@ fn setupSnapshotTesting(
325336

326337
const camera = b.addExecutable(.{
327338
.name = "camera",
328-
.root_source_file = b.path("build/camera.zig"),
329-
.target = target,
330-
.optimize = .ReleaseFast,
339+
.root_module = b.createModule(.{
340+
.root_source_file = b.path("build/camera.zig"),
341+
.target = target,
342+
.optimize = .ReleaseFast,
343+
}),
331344
});
332345

333346
const diff = b.addSystemCommand(&.{
@@ -555,8 +568,7 @@ fn setupReleaseStep(
555568

556569
const options = blk: {
557570
const options = b.addOptions();
558-
const out = options.contents.writer();
559-
out.print(
571+
options.contents.print(b.allocator,
560572
\\// module = zine
561573
\\const std = @import("std");
562574
\\pub const tsan = false;
@@ -570,9 +582,11 @@ fn setupReleaseStep(
570582

571583
const zine_exe_release = b.addExecutable(.{
572584
.name = "zine",
573-
.root_source_file = b.path("src/main.zig"),
574-
.target = target,
575-
.optimize = .ReleaseFast,
585+
.root_module = b.createModule(.{
586+
.root_source_file = b.path("src/main.zig"),
587+
.target = target,
588+
.optimize = .ReleaseFast,
589+
}),
576590
});
577591

578592
zine_exe_release.root_module.addImport("options", options);
@@ -587,16 +601,23 @@ fn setupReleaseStep(
587601
zine_exe_release.root_module.addImport("mime", mime.module("mime"));
588602
zine_exe_release.root_module.addImport("wuffs", wuffs.module("wuffs"));
589603

590-
if (target.result.os.tag == .macos) {
591-
if (b.lazyDependency("frameworks", .{
592-
.target = target,
593-
.optimize = optimize,
594-
})) |frameworks| {
595-
zine_exe_release.addIncludePath(frameworks.path("include"));
596-
zine_exe_release.addFrameworkPath(frameworks.path("Frameworks"));
597-
zine_exe_release.addLibraryPath(frameworks.path("lib"));
598-
zine_exe_release.linkFramework("CoreServices");
599-
}
604+
switch (target.result.os.tag) {
605+
else => @panic("target must be added to build.zig"),
606+
.linux => {},
607+
.windows => {
608+
zine_exe_release.linkSystemLibrary("ws2_32");
609+
},
610+
.macos => {
611+
if (b.lazyDependency("frameworks", .{
612+
.target = target,
613+
.optimize = optimize,
614+
})) |frameworks| {
615+
zine_exe_release.addIncludePath(frameworks.path("include"));
616+
zine_exe_release.addFrameworkPath(frameworks.path("Frameworks"));
617+
zine_exe_release.addLibraryPath(frameworks.path("lib"));
618+
zine_exe_release.linkFramework("CoreServices");
619+
}
620+
},
600621
}
601622

602623
switch (t.os_tag.?) {

build.zig.zon

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,57 @@
22
.name = .zine,
33
.version = "0.10.3",
44
.fingerprint = 0xa466bcb520a7eea2,
5-
.minimum_zig_version = "0.14.1",
5+
.minimum_zig_version = "0.15.0-dev.1048+f43f89a70",
66
.dependencies = .{
7-
.ziggy = .{
8-
.url = "git+https://github.com/kristoff-it/ziggy#eeb21acc0a369dca503167fe963f4f5a7eda2659",
9-
.hash = "ziggy-0.1.0-kTg8vwBEBgA21d_qL5UmAoCr3bvnjkTRbF41tZzo2zuL",
10-
},
117
.afl_kit = .{
12-
.url = "git+https://github.com/kristoff-it/zig-afl-kit#39c33d45dbe3605a9ef7cab863620d1ca78a3623",
13-
.hash = "zig_afl_kit-0.1.0-3k74fQAdAABrirJM84Lo-lnl9mnUMwtJCSPPyIJ0OzAr",
8+
.url = "git+https://github.com/kristoff-it/zig-afl-kit#8ef04d1db48650345dca68da1e1b8f2615125c40",
9+
.hash = "afl_kit-0.1.0-NdJ3cvscAACLEvjZTB017IAks_Uq5ux1qpA-klDe384Y",
1410
.lazy = true,
1511
},
1612
.lsp_kit = .{
17-
.url = "git+https://github.com/kristoff-it/zig-lsp-kit#46e2b958c02dc4ed2d4784f8841ba7d2076da783",
18-
.hash = "lsp_kit-0.1.0-hAAxO8G9AACr9SwC5FsYac37Bn7yi968x2UMq4wxKlgr",
13+
.url = "git+https://github.com/zigtools/lsp-kit#e58d398b4058eea09d984d5d039eddd243e535ad",
14+
.hash = "lsp_kit-0.1.0-bi_PL5IyCgCh6ZNq1VaDklFqV0u23xNSXONjfDpYceJr",
1915
},
2016
.scripty = .{
21-
.url = "git+https://github.com/kristoff-it/scripty#131704ebf9b3557c9480248787bd7b640a6ac98d",
22-
.hash = "scripty-0.1.0-LKK5O83DAACoGpVDkm8JxzgevTE76bkf0n3mHyTej9nb",
17+
.url = "git+https://github.com/kristoff-it/scripty#3d56bb62a1aec0b07b634aea42ec46e72e017e33",
18+
.hash = "scripty-0.1.0-LKK5O2zEAADkO2rJa_QbMWwC_YmFnUKC384wwMeBGOQv",
2319
},
2420
.tracy = .{
2521
.url = "git+https://github.com/kristoff-it/tracy#67d2d89e351048c76fc6d161e0ac09d8a831dc60",
2622
.hash = "tracy-0.0.0-4Xw-1pwwAABTfMgoDP1unCbZDZhJEfict7XCBGF6IdIn",
2723
},
2824
.mime = .{
29-
.url = "git+https://github.com/andrewrk/mime.git#0b676643886b1e2f19cf11b4e15b028768708342",
30-
.hash = "mime-2.0.1-AAAAAIQgAACQg7DEPQ9oompIp7Jq2fk7IsnP9xDHjd_r",
31-
},
32-
.zeit = .{
33-
.url = "git+https://github.com/rockorager/zeit#52b100caa223d5cb1ff0d34f1b677f26e0ce8b84",
34-
.hash = "zeit-0.0.0-AAAAALZOAgDpc1fMOfT58FPHY_PsFiPgx_OZnxhXRvK9",
35-
},
36-
.flow_syntax = .{
37-
.url = "git+https://github.com/neurocyte/flow-syntax#d231728c92cb3c5a7139cb0d75a321a119b8e777",
38-
.hash = "flow_syntax-0.1.0-X8jOoUX-AADI9WdOuVSYK9yjyBOTFj4UicSapF7QQssd",
25+
.url = "git+https://github.com/kristoff-it/mime#a2ed0cba3b1463217168034ffed8c1604e72598d",
26+
.hash = "mime-3.0.0-zwmL--0gAAByELrj57sRm2EFBRzjKLFrMgHQcs7sFZev",
3927
},
4028
.wuffs = .{
41-
.url = "git+https://github.com/allyourcodebase/wuffs#3646d8efae3f042ccbf552263ac6b2af738bdaa7",
42-
.hash = "wuffs-0.4.0-alpha.9+3837.20240914-3CHJgWsPAADpG9AWvKJ8ZxQ-t2IcnPEYVi_FD_o-qxjD",
29+
.url = "git+https://github.com/allyourcodebase/wuffs#5822dc06c75b30d53082debf68c90193cb2b2608",
30+
.hash = "wuffs-0.4.0-alpha.9+3837.20240914-3CHJgcMFAACyPvxsC7b48pJv9dPkPa4pSrB2VFbCXTfK",
4331
},
4432
.frameworks = .{
4533
.url = "git+https://github.com/hexops/xcode-frameworks.git#8a1cfb373587ea4c9bb1468b7c986462d8d4e10e",
4634
.hash = "N-V-__8AALShqgXkvqYU6f__FrA22SMWmi2TXCJjNTO1m8XJ",
4735
.lazy = true,
4836
},
4937
.superhtml = .{
50-
.url = "git+https://github.com/kristoff-it/superhtml#0b9bd0e8fd6284c0cfca85f7997535fe7f051046",
51-
.hash = "superhtml-0.4.0-Y7MdPIOYDQAur5AdrA9FL0NNzR1yq-sWZ5bUD7yn6Wm4",
38+
.url = "git+https://github.com/kristoff-it/superhtml#a67317fb81afe76cc04e6d92124cfc20a903cee7",
39+
.hash = "superhtml-0.4.0-Y7MdPFOGDQDNOWo-h4o8yNvX8Iys3JqU-uYBka837Ls5",
40+
},
41+
.ziggy = .{
42+
.url = "git+https://github.com/kristoff-it/ziggy#f3dcc37beab34478a67aa9680f581edb0bc4d482",
43+
.hash = "ziggy-0.1.0-kTg8v9g9BgB0Tdid89m2yC7a-LtZB8sD3v4pWzHCp7MO",
5244
},
5345
.supermd = .{
54-
.url = "git+https://github.com/kristoff-it/supermd#e153cca96a9defea46872f9a7e980008ef6c8cdb",
55-
.hash = "supermd-0.1.0-3Mco3MySWAA6fMdE3cTui2uQeCwTSJ-DU3lLiDriioah",
46+
.url = "git+https://github.com/kristoff-it/supermd#fa0110e2b2dcc2baa8e46672561d0064ee252276",
47+
.hash = "supermd-0.1.0-3Mco3D-SWABXmj0ocbgWRwbWTmRpK8OdhRsj9NUHyDag",
48+
},
49+
.zeit = .{
50+
.url = "git+https://github.com/kristoff-it/zeit?ref=writergate#06ec40445cc477fea5a8369f1ba3881e2a3c00eb",
51+
.hash = "zeit-0.6.0-5I6bkyJ8AgAS1_0NDvfxmFsBDTOxkZXtLUHrmPjcmt-K",
52+
},
53+
.flow_syntax = .{
54+
.url = "git+https://github.com/kristoff-it/flow-syntax?ref=writergate#727dfa247d6cfe99939c98e5bcb440dfeefc261d",
55+
.hash = "flow_syntax-0.1.0-X8jOoSUNAQD_lAmm4kWMCsqYGQNUBP6qGldpxR_6D7GC",
5656
},
5757
},
5858
.paths = .{"."},

src/AnsiRenderer.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const AnsiRenderer = @This();
2+
23
const std = @import("std");
4+
const Reader = std.Io.Reader;
5+
const Writer = std.Io.Writer;
36

47
state: State = .normal,
58
current_style: Style = .{},
@@ -28,7 +31,7 @@ const Style = struct {
2831
white,
2932
};
3033

31-
fn print(style: Style, out: anytype, open: bool) !void {
34+
fn print(style: Style, out: *Writer, open: bool) !void {
3235
comptime var fields: [std.meta.fields(Style).len]std.builtin.Type.StructField = undefined;
3336
@memcpy(&fields, std.meta.fields(Style));
3437
comptime std.mem.reverse(std.builtin.Type.StructField, &fields);
@@ -57,11 +60,11 @@ const Style = struct {
5760
}
5861
}
5962

60-
fn printOpen(style: Style, out: anytype) !void {
63+
fn printOpen(style: Style, out: *Writer) !void {
6164
try style.print(out, true);
6265
}
6366

64-
fn printClose(style: Style, out: anytype) !void {
67+
fn printClose(style: Style, out: *Writer) !void {
6568
try style.print(out, false);
6669
}
6770
};
@@ -83,7 +86,7 @@ pub fn renderSlice(allocator: std.mem.Allocator, src: []const u8) ![]const u8 {
8386
return try out.toOwnedSlice();
8487
}
8588

86-
fn render(renderer: *AnsiRenderer, reader: anytype, writer: anytype) !void {
89+
fn render(renderer: *AnsiRenderer, reader: *Reader, writer: *Writer) !void {
8790
try renderer.current_style.printOpen(writer);
8891

8992
while (true) {

src/Build.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ pub fn scanTemplates(b: *Build, gpa: Allocator, arena: Allocator) !void {
309309
else => continue,
310310
.file, .sym_link => {
311311
if (std.mem.endsWith(u8, entry.name, ".html")) {
312-
std.debug.print("WARNING: found plain HTML file {/}, did you mean to give it a shtml extension?\n", .{
313-
root.fmtJoin(&.{
312+
std.debug.print("WARNING: found plain HTML file {f}, did you mean to give it a shtml extension?\n", .{
313+
root.fmtJoin('/', &.{
314314
layouts_dir_path,
315315
dir_entry.path,
316316
entry.name,

src/Git.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const Git = @This();
22

33
const std = @import("std");
4+
const Writer = std.Io.Writer;
45
const builtin = @import("builtin");
56
const ziggy = @import("ziggy");
67
const zeit = @import("zeit");
@@ -27,7 +28,7 @@ const CommitDate = struct {
2728
opts: ziggy.serializer.StringifyOptions,
2829
indent_level: usize,
2930
depth: usize,
30-
writer: anytype,
31+
w: *Writer,
3132
) !void {
3233
_ = opts;
3334
_ = indent_level;
@@ -37,9 +38,9 @@ const CommitDate = struct {
3738
.source = .{ .unix_timestamp = value.unix },
3839
}) catch unreachable;
3940

40-
try writer.print("@date(\"", .{});
41-
date.time().gofmt(writer, "2006-01-02T15:04:05") catch unreachable;
42-
try writer.print("\")", .{});
41+
try w.print("@date(\"", .{});
42+
date.time().gofmt(w, "2006-01-02T15:04:05") catch unreachable;
43+
try w.print("\")", .{});
4344
}
4445
};
4546
};

0 commit comments

Comments
 (0)