79 lines
2.5 KiB
Zig
79 lines
2.5 KiB
Zig
const std = @import("std");
|
|
const bh = @import("bh");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
const static_build = b.option(bool, "static_build", "builds backlog dependencies for static linking") orelse false;
|
|
|
|
const nfd = bh.MakeModLib(b, .{
|
|
.name = "nfd",
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.static_build = static_build,
|
|
.root = b.path("src/nfd.zig"),
|
|
});
|
|
|
|
nfd.install();
|
|
|
|
// Add include paths to module (for Zig @cImport)
|
|
nfd.addIncludePath("include");
|
|
|
|
// Configure library
|
|
nfd.lib.linkLibC();
|
|
nfd.lib.addCSourceFile(.{
|
|
.file = b.path("src/nfd_common.c"),
|
|
.flags = &.{},
|
|
});
|
|
|
|
if (target.result.os.tag == .macos) {
|
|
nfd.lib.addCSourceFile(.{
|
|
.file = b.path("src/nfd_cocoa.m"),
|
|
.flags = &.{},
|
|
});
|
|
nfd.lib.linkFramework("AppKit");
|
|
} else if (target.result.os.tag == .windows) {
|
|
nfd.lib.addCSourceFile(.{
|
|
.file = b.path("src/nfd_win.cpp"),
|
|
.flags = &.{},
|
|
});
|
|
nfd.lib.linkSystemLibrary("ole32");
|
|
} else if (target.result.os.tag == .linux) {
|
|
// nfd.lib.addCSourceFile(.{
|
|
// .file = b.path("src/nfd_gtk.c"),
|
|
// .flags = &.{},
|
|
// });
|
|
nfd.lib.addCSourceFile(.{
|
|
.file = b.path("src/nfd_null.c"),
|
|
.flags = &.{},
|
|
});
|
|
// nfd.lib.linkSystemLibrary("gdk-3", .{});
|
|
// nfd.lib.linkSystemLibrary("atk-1.0", .{});
|
|
// nfd.lib.linkSystemLibrary("gtk-3", .{});
|
|
// nfd.lib.linkSystemLibrary("glib-2.0", .{});
|
|
// nfd.lib.linkSystemLibrary("gobject-2.0", .{});
|
|
}
|
|
|
|
const p2dep = b.dependency("p2", .{ .target = target, .optimize = optimize, .static_build = static_build });
|
|
|
|
const p2mod = p2dep.module("p2");
|
|
nfd.mod.addImport("p2", p2mod);
|
|
|
|
const test_step = b.step("test", "");
|
|
const tests = b.addTest(.{
|
|
.root_module = b.createModule(.{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.root_source_file = b.path("src/nfd.zig"),
|
|
.link_libc = true,
|
|
}),
|
|
});
|
|
tests.addIncludePath(b.path("./include"));
|
|
|
|
tests.root_module.addImport("nfd", nfd.mod);
|
|
tests.root_module.linkLibrary(nfd.lib);
|
|
tests.root_module.addImport("p2", p2mod);
|
|
const runArtifact = b.addRunArtifact(tests);
|
|
test_step.dependOn(&runArtifact.step);
|
|
}
|