grace/tpb

Tee your Paste Board

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

Grace Yoderbuild: updated pipelines to use cargo-zigbuild container to work with apple and be faster1be3e04

0.1.2
2.3 KiB67 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 exe = b.addExecutable(.{
7        .name = "tpb",
8        .root_module = b.createModule(.{
9            .root_source_file = b.path("src/main.zig"),
10            .target = target,
11            .optimize = optimize,
12        }),
13    });
14
15    b.installArtifact(exe);
16
17    const tests = b.addTest(.{
18        .name = "tpb",
19        .root_module = b.createModule(.{
20            .root_source_file = b.path("src/main.zig"),
21            .target = target,
22            .optimize = optimize,
23        }),
24    });
25
26    if (target.result.os.tag == .macos) {
27        exe.root_module.addCSourceFiles(.{
28            .files = &.{"src/Clip/NSPBBridge.m"},
29            .language = .objective_c,
30            .flags = &.{"-fobjc-arc"},
31        });
32        tests.root_module.addCSourceFiles(.{
33            .files = &.{"src/Clip/NSPBBridge.m"},
34            .language = .objective_c,
35            .flags = &.{"-fobjc-arc"},
36        });
37        if (b.sysroot) |sysroot| {
38            const framework_path = b.pathJoin(&.{ sysroot, "System/Library/Frameworks" });
39            const include_path = b.pathJoin(&.{ sysroot, "usr/include" });
40            exe.root_module.addSystemFrameworkPath(.{ .cwd_relative = framework_path });
41            exe.root_module.addSystemIncludePath(.{ .cwd_relative = include_path });
42            tests.root_module.addSystemFrameworkPath(.{ .cwd_relative = framework_path });
43            tests.root_module.addSystemIncludePath(.{ .cwd_relative = include_path });
44        }
45        exe.root_module.linkFramework("Cocoa", .{});
46        tests.root_module.linkFramework("Cocoa", .{});
47    }
48
49    const test_step = b.step("test", "Run tests");
50    const run_tests = b.addRunArtifact(tests);
51    test_step.dependOn(&run_tests.step);
52
53    const interface_step = b.step("interface", "Check interface (compile tests only)");
54    const check_interface = b.addInstallArtifact(tests, .{});
55    interface_step.dependOn(&check_interface.step);
56
57    const run_step = b.step("run", "Run the app");
58
59    const run_cmd = b.addRunArtifact(exe);
60    run_step.dependOn(&run_cmd.step);
61
62    run_cmd.step.dependOn(b.getInstallStep());
63
64    if (b.args) |args| {
65        run_cmd.addArgs(args);
66    }
67}