zig-objc/build.zig

32 lines
1 KiB
Zig
Raw Normal View History

2023-01-02 14:48:21 -08:00
const std = @import("std");
2023-02-14 18:03:43 -08:00
pub fn build(b: *std.Build) void {
2023-02-14 18:03:43 -08:00
const optimize = b.standardOptimizeOption(.{});
2023-01-02 14:48:21 -08:00
const target = b.standardTargetOptions(.{});
const add_paths = b.option(bool, "add-paths", "add macos SDK paths from dependency") orelse false;
2023-01-02 14:48:21 -08:00
const objc = b.addModule("objc", .{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
if (add_paths) @import("macos_sdk").addPathsModule(objc);
objc.linkSystemLibrary("objc", .{});
objc.linkFramework("Foundation", .{});
2023-08-03 16:53:26 -07:00
2023-02-14 18:03:43 -08:00
const tests = b.addTest(.{
.name = "objc-test",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
2023-01-02 14:48:21 -08:00
tests.linkSystemLibrary("objc");
2023-10-20 15:36:55 -07:00
tests.linkFramework("Foundation");
@import("macos_sdk").addPaths(tests);
2023-06-30 09:49:12 -07:00
b.installArtifact(tests);
2023-01-02 14:48:21 -08:00
const test_step = b.step("test", "Run tests");
2023-06-30 09:49:12 -07:00
const tests_run = b.addRunArtifact(tests);
2023-01-02 14:48:21 -08:00
test_step.dependOn(&tests_run.step);
}