diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-04 19:22:04 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 01:23:06 +0300 |
| commit | 41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch) | |
| tree | 3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/spirv-cross | |
| parent | 55c138263e190a1e79d4b997bfb9397306c0ec1f (diff) | |
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/spirv-cross')
| -rw-r--r-- | vendor/libghostty-vt/pkg/spirv-cross/build.zig | 120 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/spirv-cross/build.zig.zon | 16 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/spirv-cross/c.zig | 3 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/spirv-cross/main.zig | 1 |
4 files changed, 140 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/spirv-cross/build.zig b/vendor/libghostty-vt/pkg/spirv-cross/build.zig new file mode 100644 index 00000000..72ce61eb --- /dev/null +++ b/vendor/libghostty-vt/pkg/spirv-cross/build.zig @@ -0,0 +1,120 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) !void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const module = b.addModule("spirv_cross", .{ .root_source_file = b.path("main.zig"), .target = target, .optimize = optimize }); + + // For dynamic linking, we prefer dynamic linking and to search by + // mode first. Mode first will search all paths for a dynamic library + // before falling back to static. + const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{ + .preferred_link_mode = .dynamic, + .search_strategy = .mode_first, + }; + + var test_exe: ?*std.Build.Step.Compile = null; + if (target.query.isNative()) { + test_exe = b.addTest(.{ + .name = "test", + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .target = target, + .optimize = optimize, + }), + }); + const tests_run = b.addRunArtifact(test_exe.?); + const test_step = b.step("test", "Run tests"); + test_step.dependOn(&tests_run.step); + + // Uncomment this if we're debugging tests + // b.installArtifact(test_exe.?); + } + if (b.systemIntegrationOption("spirv-cross", .{})) { + module.linkSystemLibrary("spirv-cross-c-shared", dynamic_link_opts); + if (test_exe) |exe| { + exe.linkSystemLibrary2("spirv-cross-c-shared", dynamic_link_opts); + } + } else { + const lib = try buildSpirvCross(b, module, target, optimize); + b.installArtifact(lib); + if (test_exe) |exe| exe.linkLibrary(lib); + } +} + +fn buildSpirvCross( + b: *std.Build, + module: *std.Build.Module, + target: std.Build.ResolvedTarget, + optimize: std.builtin.OptimizeMode, +) !*std.Build.Step.Compile { + const lib = b.addLibrary(.{ + .name = "spirv_cross", + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), + .linkage = .static, + }); + lib.linkLibC(); + // On MSVC, we must not use linkLibCpp because Zig unconditionally + // passes -nostdinc++ and then adds its bundled libc++/libc++abi + // include paths, which conflict with MSVC's own C++ runtime headers. + // The MSVC SDK include directories (added via linkLibC) contain + // both C and C++ headers, so linkLibCpp is not needed. + if (target.result.abi != .msvc) { + lib.linkLibCpp(); + } + if (target.result.os.tag.isDarwin()) { + const apple_sdk = @import("apple_sdk"); + try apple_sdk.addPaths(b, lib); + } + + var flags: std.ArrayList([]const u8) = .empty; + defer flags.deinit(b.allocator); + try flags.appendSlice(b.allocator, &.{ + "-DSPIRV_CROSS_C_API_GLSL=1", + "-DSPIRV_CROSS_C_API_MSL=1", + + "-fno-sanitize=undefined", + "-fno-sanitize-trap=undefined", + }); + + if (target.result.os.tag == .freebsd or target.result.abi == .musl) { + try flags.append(b.allocator, "-fPIC"); + } + + if (b.lazyDependency("spirv_cross", .{})) |upstream| { + lib.addIncludePath(upstream.path("")); + module.addIncludePath(upstream.path("")); + lib.addCSourceFiles(.{ + .root = upstream.path(""), + .flags = flags.items, + .files = &.{ + // Core + "spirv_cross.cpp", + "spirv_parser.cpp", + "spirv_cross_parsed_ir.cpp", + "spirv_cfg.cpp", + + // C + "spirv_cross_c.cpp", + + // GLSL + "spirv_glsl.cpp", + + // MSL + "spirv_msl.cpp", + }, + }); + + lib.installHeadersDirectory( + upstream.path(""), + "", + .{ .include_extensions = &.{".h"} }, + ); + } + + return lib; +} diff --git a/vendor/libghostty-vt/pkg/spirv-cross/build.zig.zon b/vendor/libghostty-vt/pkg/spirv-cross/build.zig.zon new file mode 100644 index 00000000..30eea950 --- /dev/null +++ b/vendor/libghostty-vt/pkg/spirv-cross/build.zig.zon @@ -0,0 +1,16 @@ +.{ + .name = .spirv_cross, + .version = "13.1.1", + .fingerprint = 0x7ea1d8312b06cca, + .paths = .{""}, + .dependencies = .{ + // KhronosGroup/SPIRV-Cross + .spirv_cross = .{ + .url = "https://deps.files.ghostty.org/spirv_cross-1220fb3b5586e8be67bc3feb34cbe749cf42a60d628d2953632c2f8141302748c8da.tar.gz", + .hash = "N-V-__8AANb6pwD7O1WG6L5nvD_rNMvnSc9Cpg1ijSlTYywv", + .lazy = true, + }, + + .apple_sdk = .{ .path = "../apple-sdk" }, + }, +} diff --git a/vendor/libghostty-vt/pkg/spirv-cross/c.zig b/vendor/libghostty-vt/pkg/spirv-cross/c.zig new file mode 100644 index 00000000..08a999a3 --- /dev/null +++ b/vendor/libghostty-vt/pkg/spirv-cross/c.zig @@ -0,0 +1,3 @@ +pub const c = @cImport({ + @cInclude("spirv_cross_c.h"); +}); diff --git a/vendor/libghostty-vt/pkg/spirv-cross/main.zig b/vendor/libghostty-vt/pkg/spirv-cross/main.zig new file mode 100644 index 00000000..1ef5493b --- /dev/null +++ b/vendor/libghostty-vt/pkg/spirv-cross/main.zig @@ -0,0 +1 @@ +pub const c = @import("c.zig").c; |
