Skip to content

Commit

Permalink
build.zig fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hazeycode committed Aug 10, 2024
1 parent 84b0706 commit 4668907
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ pub fn install_xaudio2(
install_dir: std.Build.InstallDir,
) void {
const b = step.owner;
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
step.dependOn(
&b.addInstallFileWithDir(
.{
.cwd_relative = b.pathJoin(
&.{ source_path_prefix, "bin/x64/xaudio2_9redist.dll" },
),
.dependency = .{
.dependency = b.dependency("zwin32", .{}),
.sub_path = "bin/x64/xaudio2_9redist.dll",
},
},
install_dir,
"xaudio2_9redist.dll",
Expand All @@ -31,13 +31,14 @@ pub fn install_d3d12(
install_dir: std.Build.InstallDir,
) void {
const b = step.owner;
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
const zwin32 = b.dependency("zwin32", .{});
step.dependOn(
&b.addInstallFileWithDir(
.{
.cwd_relative = b.pathJoin(
&.{ source_path_prefix, "bin/x64/D3D12Core.dll" },
),
.dependency = .{
.dependency = zwin32,
.sub_path = "bin/x64/D3D12Core.dll",
},
},
install_dir,
"d3d12/D3D12Core.dll",
Expand All @@ -46,9 +47,10 @@ pub fn install_d3d12(
step.dependOn(
&b.addInstallFileWithDir(
.{
.cwd_relative = b.pathJoin(
&.{ source_path_prefix, "bin/x64/D3D12SDKLayers.dll" },
),
.dependency = .{
.dependency = zwin32,
.sub_path = "bin/x64/D3D12SDKLayers.dll",
},
},
install_dir,
"d3d12/D3D12SDKLayers.dll",
Expand All @@ -61,13 +63,13 @@ pub fn install_directml(
install_dir: std.Build.InstallDir,
) void {
const b = step.owner;
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
step.dependOn(
&b.addInstallFileWithDir(
.{
.cwd_relative = b.pathJoin(
&.{ source_path_prefix, "bin/x64/DirectML.dll" },
),
.dependency = .{
.dependency = b.dependency("zwin32", .{}),
.sub_path = "bin/x64/DirectML.dll",
},
},
install_dir,
"DirectML.dll",
Expand All @@ -76,9 +78,10 @@ pub fn install_directml(
step.dependOn(
&b.addInstallFileWithDir(
.{
.cwd_relative = b.pathJoin(
&.{ source_path_prefix, "bin/x64/DirectML.Debug.dll" },
),
.dependency = .{
.dependency = b.dependency("zwin32", .{}),
.sub_path = "bin/x64/DirectML.Debug.dll",
},
},
install_dir,
"DirectML.Debug.dll",
Expand Down Expand Up @@ -163,10 +166,11 @@ pub const CompileShaders = struct {
) void {
const b = self.step.owner;

const zwin32_path = comptime std.fs.path.dirname(@src().file) orelse ".";
const zwin32 = b.dependency("zwin32", .{});

const dxc_path = switch (builtin.target.os.tag) {
.windows => zwin32_path ++ "/bin/x64/dxc.exe",
.linux => zwin32_path ++ "/bin/x64/dxc",
.windows => zwin32.path("bin/x64/dxc.exe").getPath(b),
.linux => zwin32.path("bin/x64/dxc").getPath(b),
else => @panic("Unsupported target"),
};

Expand All @@ -184,10 +188,7 @@ pub const CompileShaders = struct {

const cmd_step = b.addSystemCommand(&dxc_command);
if (builtin.target.os.tag == .linux) {
cmd_step.setEnvironmentVariable(
"LD_LIBRARY_PATH",
zwin32_path ++ "/bin/x64",
);
cmd_step.setEnvironmentVariable("LD_LIBRARY_PATH", zwin32.path("bin/x64").getPath(b));
}
self.step.dependOn(&cmd_step.step);
}
Expand Down

0 comments on commit 4668907

Please sign in to comment.