grace/tpb

Tee your Paste Board

git clone https://git.gae.moe/grace/tpb

Grace Yodermisc: update to zig 0.17c6a3242

main
2.3 KiB70 linesraw
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4    const target = b.standardTargetOptions(.{});
5    const optimize = b.standardOptimizeOption(.{});
6    const sdk = b.option([]const u8, "sdk", "Path to the macOS SDK");
7    const exe = b.addExecutable(.{
8        .name = "tpb",
9        .root_module = b.createModule(.{
10            .root_source_file = b.path("src/main.zig"),
11            .target = target,
12            .optimize = optimize,
13        }),
14    });
15
16    b.installArtifact(exe);
17
18    const tests = b.addTest(.{
19        .name = "tpb",
20        .root_module = b.createModule(.{
21            .root_source_file = b.path("src/main.zig"),
22            .target = target,
23            .optimize = optimize,
24        }),
25    });
26
27    if (target.result.os.tag == .macos) {
28        exe.root_module.link_libc = true;
29        tests.root_module.link_libc = true;
30
31        exe.root_module.addCSourceFiles(.{
32            .files = &.{"src/Clip/NSPBBridge.m"},
33            .language = .objective_c,
34            .flags = &.{"-fobjc-arc"},
35        });
36        tests.root_module.addCSourceFiles(.{
37            .files = &.{"src/Clip/NSPBBridge.m"},
38            .language = .objective_c,
39            .flags = &.{"-fobjc-arc"},
40        });
41
42        if (sdk) |root| {
43            for ([_]*std.Build.Module{ exe.root_module, tests.root_module }) |module| {
44                module.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ root, "System/Library/Frameworks" }) });
45                module.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ root, "usr/include" }) });
46                module.addLibraryPath(.{ .cwd_relative = b.pathJoin(&.{ root, "usr/lib" }) });
47            }
48        }
49
50        exe.root_module.linkFramework("Cocoa", .{});
51        tests.root_module.linkFramework("Cocoa", .{});
52    }
53
54    const test_step = b.step("test", "Run tests");
55    const run_tests = b.addRunArtifact(tests);
56    test_step.dependOn(&run_tests.step);
57
58    const interface_step = b.step("interface", "Check interface (compile tests only)");
59    const check_interface = b.addInstallArtifact(tests, .{});
60    interface_step.dependOn(&check_interface.step);
61
62    const run_step = b.step("run", "Run the app");
63
64    const run_cmd = b.addRunArtifact(exe);
65    run_step.dependOn(&run_cmd.step);
66
67    run_cmd.step.dependOn(b.getInstallStep());
68
69    run_cmd.addPassthruArgs();
70}