diff options
author | polwex <polwex@sortug.com> | 2025-10-05 21:56:51 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-10-05 21:56:51 +0700 |
commit | fcedfddf00b3f994e4f4e40332ac7fc192c63244 (patch) | |
tree | 51d38e62c7bdfcc5f9a5e9435fe820c93cfc9a3d /vere/pkg/c3/build.zig |
claude is gud
Diffstat (limited to 'vere/pkg/c3/build.zig')
-rw-r--r-- | vere/pkg/c3/build.zig | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/vere/pkg/c3/build.zig b/vere/pkg/c3/build.zig new file mode 100644 index 0000000..3c5a89c --- /dev/null +++ b/vere/pkg/c3/build.zig @@ -0,0 +1,56 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + const t = target.result; + + const copts: []const []const u8 = + b.option([]const []const u8, "copt", "") orelse &.{}; + + const pkg_c3 = b.addStaticLibrary(.{ + .name = "c3", + .target = target, + .optimize = optimize, + }); + + if (target.result.os.tag.isDarwin() and !target.query.isNative()) { + const macos_sdk = b.lazyDependency("macos_sdk", .{ + .target = target, + .optimize = optimize, + }); + if (macos_sdk != null) { + pkg_c3.addSystemIncludePath(macos_sdk.?.path("usr/include")); + pkg_c3.addLibraryPath(macos_sdk.?.path("usr/lib")); + pkg_c3.addFrameworkPath(macos_sdk.?.path("System/Library/Frameworks")); + } + } + + pkg_c3.linkLibC(); + + pkg_c3.addIncludePath(b.path("")); + + pkg_c3.addCSourceFiles(.{ + .root = b.path(""), + .files = &.{"defs.c"}, + .flags = copts, + }); + + if (t.os.tag == .windows) { + pkg_c3.addIncludePath(b.path("platform/windows")); + pkg_c3.installHeadersDirectory(b.path("platform/windows"), "", .{}); + pkg_c3.addCSourceFiles(.{ + .root = b.path(""), + .files = &.{"platform/windows/compat.c"}, + .flags = copts, + }); + } + + pkg_c3.installHeader(b.path("c3.h"), "c3/c3.h"); + pkg_c3.installHeader(b.path("defs.h"), "c3/defs.h"); + pkg_c3.installHeader(b.path("motes.h"), "c3/motes.h"); + pkg_c3.installHeader(b.path("portable.h"), "c3/portable.h"); + pkg_c3.installHeader(b.path("types.h"), "c3/types.h"); + + b.installArtifact(pkg_c3); +} |