@@ -48,6 +48,30 @@ pub fn build(b: *std.Build) !void {
4848 });
4949}
5050
51+ pub fn activateSdk (b : * std.Build , zwindows : * std.Build.Dependency ) * std.Build.Step {
52+ const step = b .allocator .create (std .Build .Step ) catch unreachable ;
53+ step .* = std .Build .Step .init (.{
54+ .id = .custom ,
55+ .name = "Activate zwindows" ,
56+ .owner = b ,
57+ .makeFn = & struct {
58+ fn make (_ : * std.Build.Step , _ : std.Build.Step.MakeOptions ) anyerror ! void {}
59+ }.make ,
60+ });
61+ switch (builtin .target .os .tag ) {
62+ .windows = > {
63+ const dxc_path = zwindows .path ("bin/x64/dxc.exe" ).getPath (b );
64+ step .dependOn (& b .addSystemCommand (&.{ "takeown" , "/f" , dxc_path }).step );
65+ },
66+ .linux = > {
67+ const dxc_path = zwindows .path ("bin/x64/dxc" ).getPath (b );
68+ step .dependOn (& b .addSystemCommand (&.{ "chmod" , "+x" , dxc_path }).step );
69+ },
70+ else = > @panic ("Unsupported host OS." ),
71+ }
72+ return step ;
73+ }
74+
5175pub fn install_xaudio2 (
5276 step : * std.Build.Step ,
5377 zwindows : * std.Build.Dependency ,
@@ -203,7 +227,7 @@ pub const CompileShaders = struct {
203227 const dxc_path = switch (builtin .target .os .tag ) {
204228 .windows = > self .zwindows .path ("bin/x64/dxc.exe" ).getPath (b ),
205229 .linux = > self .zwindows .path ("bin/x64/dxc" ).getPath (b ),
206- else = > @panic ("Unsupported target " ),
230+ else = > @panic ("Unsupported host OS. " ),
207231 };
208232
209233 const dxc_command = [9 ][]const u8 {
@@ -236,26 +260,8 @@ pub fn addCompileShaders(
236260 zwindows : * std.Build.Dependency ,
237261 options : struct { shader_ver : []const u8 },
238262) CompileShaders {
239- const build_shaders = b .step (name ++ "-dxc" , "Build shaders for '" ++ name ++ "'" );
240-
241- const dxc_path = switch (builtin .target .os .tag ) {
242- .windows = > zwindows .path ("bin/x64/dxc.exe" ).getPath (b ),
243- .linux = > zwindows .path ("bin/x64/dxc" ).getPath (b ),
244- else = > @panic ("Unsupported target" ),
245- };
246- switch (builtin .target .os .tag ) {
247- .windows = > {
248- const takeown = b .addSystemCommand (&.{ "takeown" , "/f" , dxc_path });
249- build_shaders .dependOn (& takeown .step );
250- },
251- else = > {
252- const chmod = b .addSystemCommand (&.{ "chmod" , "+x" , dxc_path });
253- build_shaders .dependOn (& chmod .step );
254- },
255- }
256-
257263 return .{
258- .step = build_shaders ,
264+ .step = b . step ( name ++ "-dxc" , "Build shaders for '" ++ name ++ "'" ) ,
259265 .zwindows = zwindows ,
260266 .shader_ver = options .shader_ver ,
261267 };
0 commit comments