diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..2fe0069 --- /dev/null +++ b/build.zig @@ -0,0 +1,41 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const mod = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + .link_libc = true, + }); + mod.linkFramework("AppKit", .{}); + mod.addImport("panto", b.dependency("libpantograph", .{ .target = target, .optimize = optimize }).module("panto")); + const exe = b.addExecutable(.{ .name = "write_away", .root_module = mod }); + + // Installed as an app bundle: zig-out/Write_Away.app + const bundle = "Write_Away.app/Contents"; + const bin = b.addInstallArtifact(exe, .{ .dest_dir = .{ .override = .{ .custom = bundle ++ "/MacOS" } } }); + b.getInstallStep().dependOn(&bin.step); + b.getInstallStep().dependOn(&b.addInstallFile(b.path("Info.plist"), bundle ++ "/Info.plist").step); + b.getInstallStep().dependOn(&b.addInstallFile(b.path("assets/Write_Away.icns"), bundle ++ "/Resources/Write_Away.icns").step); + + const run = b.addRunArtifact(exe); + if (b.args) |args| run.addArgs(args); + b.step("run", "Run the editor (zig build run -- file.md)").dependOn(&run.step); + + // The checks: the document model on its own, then the real app driven through its + // commands with no window shown. + const unit = b.addTest(.{ .root_module = b.createModule(.{ + .root_source_file = b.path("src/doc.zig"), + .target = target, + }) }); + const smoke = b.addRunArtifact(exe); + smoke.setEnvironmentVariable("WRITE_AWAY_SELFTEST", "1"); + const test_step = b.step("test", "Run the checks"); + const lab_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/lab.zig"), .target = target }) }); + test_step.dependOn(&b.addRunArtifact(lab_tests).step); + test_step.dependOn(&b.addRunArtifact(unit).step); + test_step.dependOn(&smoke.step); +} |
