mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
pkg/spirv-cross
This commit is contained in:
85
pkg/spirv-cross/build.zig
Normal file
85
pkg/spirv-cross/build.zig
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) !void {
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
_ = b.addModule("spirv-cross", .{ .source_file = .{ .path = "main.zig" } });
|
||||||
|
|
||||||
|
const upstream = b.dependency("spirv_cross", .{});
|
||||||
|
const lib = try buildSpirvCross(b, upstream, target, optimize);
|
||||||
|
b.installArtifact(lib);
|
||||||
|
|
||||||
|
{
|
||||||
|
const test_exe = b.addTest(.{
|
||||||
|
.name = "test",
|
||||||
|
.root_source_file = .{ .path = "main.zig" },
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
test_exe.linkLibrary(lib);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn buildSpirvCross(
|
||||||
|
b: *std.Build,
|
||||||
|
upstream: *std.Build.Dependency,
|
||||||
|
target: std.zig.CrossTarget,
|
||||||
|
optimize: std.builtin.OptimizeMode,
|
||||||
|
) !*std.Build.Step.Compile {
|
||||||
|
const lib = b.addStaticLibrary(.{
|
||||||
|
.name = "spirv-cross",
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
lib.linkLibC();
|
||||||
|
lib.linkLibCpp();
|
||||||
|
//lib.addIncludePath(upstream.path(""));
|
||||||
|
//lib.addIncludePath(.{ .path = "override" });
|
||||||
|
|
||||||
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
|
defer flags.deinit();
|
||||||
|
try flags.appendSlice(&.{
|
||||||
|
"-DSPIRV_CROSS_C_API_GLSL=1",
|
||||||
|
"-DSPIRV_CROSS_C_API_MSL=1",
|
||||||
|
|
||||||
|
"-fno-sanitize=undefined",
|
||||||
|
"-fno-sanitize-trap=undefined",
|
||||||
|
});
|
||||||
|
|
||||||
|
lib.addCSourceFiles(.{
|
||||||
|
.dependency = upstream,
|
||||||
|
.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.installHeadersDirectoryOptions(.{
|
||||||
|
.source_dir = upstream.path("include"),
|
||||||
|
.install_dir = .header,
|
||||||
|
.install_subdir = "",
|
||||||
|
.include_extensions = &.{".h"},
|
||||||
|
});
|
||||||
|
|
||||||
|
return lib;
|
||||||
|
}
|
11
pkg/spirv-cross/build.zig.zon
Normal file
11
pkg/spirv-cross/build.zig.zon
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.{
|
||||||
|
.name = "spirv-cross",
|
||||||
|
.version = "13.1.1",
|
||||||
|
.paths = .{""},
|
||||||
|
.dependencies = .{
|
||||||
|
.spirv_cross = .{
|
||||||
|
.url = "https://github.com/KhronosGroup/SPIRV-Cross/archive/4818f7e7ef7b7078a3a7a5a52c4a338e0dda22f4.tar.gz",
|
||||||
|
.hash = "1220b2d8a6cff1926ef28a29e312a0a503b555ebc2f082230b882410f49e672ac9c6",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
3
pkg/spirv-cross/c.zig
Normal file
3
pkg/spirv-cross/c.zig
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub usingnamespace @cImport({
|
||||||
|
@cInclude("spriv_cross/external_interface.h");
|
||||||
|
});
|
1
pkg/spirv-cross/main.zig
Normal file
1
pkg/spirv-cross/main.zig
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub const c = @import("c.zig");
|
Reference in New Issue
Block a user