2525using static Nuke . Common . Tools . Git . GitTasks ;
2626using static Nuke . Common . Tools . GitHub . GitHubTasks ;
2727
28- partial class Build {
28+ partial class Build
29+ {
2930 AbsolutePath SPIRVCrossPath => RootDirectory / "build" / "submodules" / "SPIRV-Cross" ;
3031
3132 //This is the build script for the SPIRV-Reflect shared library
@@ -34,62 +35,64 @@ partial class Build {
3435
3536pub fn build(b: *std.Build) void {
3637 const target = b.standardTargetOptions(.{});
37- const mode = b.standardOptimizeOption(.{});
38+ const optimize = b.standardOptimizeOption(.{});
3839
39- const shared_lib_options: std.Build.SharedLibraryOptions = .{
40- .name = ""spirv-cross"",
40+ const lib_mod = b.createModule(.{
4141 .target = target,
42- .optimize = mode,
43- };
42+ .optimize = optimize,
43+ .link_libc = true,
44+ .link_libcpp = true,
45+ });
4446
45- const lib: *std.Build.Step.Compile = b.addSharedLibrary(shared_lib_options);
46- lib.linkLibC();
47- lib.linkLibCpp();
47+ const lib = b.addLibrary(.{
48+ .name = ""spirv-cross"",
49+ .root_module = lib_mod,
50+ .use_llvm = true,
51+ .linkage = .dynamic,
52+ });
4853
4954 const flags = &.{ ""-std=c++11"", ""-fPIC"" };
5055
5156 //Enable the GLSL, HLSL, MSL, CPP, and Reflect C APIs
52- lib.defineCMacro (""SPIRV_CROSS_C_API_GLSL"", ""1"");
53- lib.defineCMacro (""SPIRV_CROSS_C_API_HLSL"", ""1"");
54- lib.defineCMacro (""SPIRV_CROSS_C_API_MSL"", ""1"");
55- lib.defineCMacro (""SPIRV_CROSS_C_API_CPP"", ""1"");
56- lib.defineCMacro (""SPIRV_CROSS_C_API_REFLECT"", ""1"");
57+ lib_mod.addCMacro (""SPIRV_CROSS_C_API_GLSL"", ""1"");
58+ lib_mod.addCMacro (""SPIRV_CROSS_C_API_HLSL"", ""1"");
59+ lib_mod.addCMacro (""SPIRV_CROSS_C_API_MSL"", ""1"");
60+ lib_mod.addCMacro (""SPIRV_CROSS_C_API_CPP"", ""1"");
61+ lib_mod.addCMacro (""SPIRV_CROSS_C_API_REFLECT"", ""1"");
5762
5863 //Export the C API symbols
59- lib.defineCMacro (""SPVC_EXPORT_SYMBOLS"", ""1"");
64+ lib_mod.addCMacro (""SPVC_EXPORT_SYMBOLS"", ""1"");
6065
6166 //On windows, we need to specify `__declspec(dllexport)` ourselves
6267 //else SPIRV-Cross thinks this is a GNU toolchain and uses the wrong attribute in this case
6368 if (target.result.os.tag == .windows) {
64- lib.defineCMacro (""SPVC_PUBLIC_API"", ""__declspec(dllexport)"");
69+ lib_mod.addCMacro (""SPVC_PUBLIC_API"", ""__declspec(dllexport)"");
6570 }
6671
6772 //If we arent in debug, defined NDEBUG and strip symbols
68- if (mode != .Debug) {
69- lib.defineCMacro (""NDEBUG"", ""1"");
73+ if (optimize != .Debug) {
74+ lib_mod.addCMacro (""NDEBUG"", ""1"");
7075
71- lib.root_module .strip = true;
76+ lib_mod .strip = true;
7277 }
7378
74- lib.addCSourceFiles(.{
75- .files = &.{
76- ""spirv_cross.cpp"",
77- ""spirv_cfg.cpp"",
78- ""spirv_cpp.cpp"",
79- ""spirv_cross_c.cpp"",
80- ""spirv_cross_parsed_ir.cpp"",
81- ""spirv_cross_util.cpp"",
82- ""spirv_glsl.cpp"",
83- ""spirv_hlsl.cpp"",
84- ""spirv_msl.cpp"",
85- ""spirv_parser.cpp"",
86- ""spirv_reflect.cpp"",
87- },
88- .flags = flags
89- });
79+ lib_mod.addCSourceFiles(.{ .files = &.{
80+ ""spirv_cross.cpp"",
81+ ""spirv_cfg.cpp"",
82+ ""spirv_cpp.cpp"",
83+ ""spirv_cross_c.cpp"",
84+ ""spirv_cross_parsed_ir.cpp"",
85+ ""spirv_cross_util.cpp"",
86+ ""spirv_glsl.cpp"",
87+ ""spirv_hlsl.cpp"",
88+ ""spirv_msl.cpp"",
89+ ""spirv_parser.cpp"",
90+ ""spirv_reflect.cpp"",
91+ }, .flags = flags });
9092
9193 b.installArtifact(lib);
92- }" ;
94+ }
95+ " ;
9396
9497 Target SPIRVCross => CommonTarget
9598 (
0 commit comments