const std = @import("std"); const bh = @import("bh"); pub fn build(b: *std.Build) void { const opts = bh.declareOptions(b); const mod = b.addModule("nfd", .{ .target = opts.target, .optimize = opts.optimize, .root_source_file = b.path("src/nfd.zig"), .link_libc = true, }); mod.addCSourceFile(.{ .file = b.path("src/nfd_common.c"), .flags = &.{}, }); mod.addIncludePath(b.path("include")); if (opts.target.result.os.tag == .macos) { mod.addCSourceFile(.{ .file = b.path("src/nfd_cocoa.m"), .flags = &.{}, }); mod.linkFramework("AppKit", .{}); } else if (opts.target.result.os.tag == .windows) { mod.addCSourceFile(.{ .file = b.path("src/nfd_win.cpp"), .flags = &.{}, }); mod.linkSystemLibrary("ole32", .{}); } else if (opts.target.result.os.tag == .linux) { // mod.addCSourceFile(.{ // .file = b.path("src/nfd_gtk.c"), // .flags = &.{}, // }); mod.addCSourceFile(.{ .file = b.path("src/nfd_null.c"), .flags = &.{}, }); // mod.linkSystemLibrary("gdk-3", .{}); // mod.linkSystemLibrary("atk-1.0", .{}); // mod.linkSystemLibrary("gtk-3", .{}); // mod.linkSystemLibrary("glib-2.0", .{}); // mod.linkSystemLibrary("gobject-2.0", .{}); } const p2dep = b.dependency("p2", .{ .target = opts.target, .optimize = opts.optimize, .static_build = opts.static_build }); const p2mod = p2dep.module("p2"); mod.addImport("p2", p2mod); const test_step = b.step("test", ""); const tests = b.addTest(.{ .root_module = b.createModule(.{ .target = opts.target, .optimize = opts.optimize, .root_source_file = b.path("src/nfd.zig"), .link_libc = true, }), }); tests.addIncludePath(b.path("./include")); tests.root_module.addImport("nfd", mod); tests.root_module.addImport("p2", p2mod); const runArtifact = b.addRunArtifact(tests); test_step.dependOn(&runArtifact.step); }