1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
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);
// Format/model checks plus the real app driven through its commands with no window shown.
const smoke = b.addRunArtifact(exe);
smoke.setEnvironmentVariable("WRITE_AWAY_SELFTEST", "1");
const test_step = b.step("test", "Run the checks");
for ([_][]const u8{ "src/doc.zig", "src/markdown.zig", "src/lab.zig", "src/lab_ui.zig" }) |path| {
const unit = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path(path), .target = target }) });
test_step.dependOn(&b.addRunArtifact(unit).step);
}
test_step.dependOn(&smoke.step);
}
|