Skip to content

Commit 4668907

Browse files
committed
build.zig fix paths
1 parent 84b0706 commit 4668907

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

build.zig

+26-25
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ pub fn install_xaudio2(
1212
install_dir: std.Build.InstallDir,
1313
) void {
1414
const b = step.owner;
15-
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
1615
step.dependOn(
1716
&b.addInstallFileWithDir(
1817
.{
19-
.cwd_relative = b.pathJoin(
20-
&.{ source_path_prefix, "bin/x64/xaudio2_9redist.dll" },
21-
),
18+
.dependency = .{
19+
.dependency = b.dependency("zwin32", .{}),
20+
.sub_path = "bin/x64/xaudio2_9redist.dll",
21+
},
2222
},
2323
install_dir,
2424
"xaudio2_9redist.dll",
@@ -31,13 +31,14 @@ pub fn install_d3d12(
3131
install_dir: std.Build.InstallDir,
3232
) void {
3333
const b = step.owner;
34-
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
34+
const zwin32 = b.dependency("zwin32", .{});
3535
step.dependOn(
3636
&b.addInstallFileWithDir(
3737
.{
38-
.cwd_relative = b.pathJoin(
39-
&.{ source_path_prefix, "bin/x64/D3D12Core.dll" },
40-
),
38+
.dependency = .{
39+
.dependency = zwin32,
40+
.sub_path = "bin/x64/D3D12Core.dll",
41+
},
4142
},
4243
install_dir,
4344
"d3d12/D3D12Core.dll",
@@ -46,9 +47,10 @@ pub fn install_d3d12(
4647
step.dependOn(
4748
&b.addInstallFileWithDir(
4849
.{
49-
.cwd_relative = b.pathJoin(
50-
&.{ source_path_prefix, "bin/x64/D3D12SDKLayers.dll" },
51-
),
50+
.dependency = .{
51+
.dependency = zwin32,
52+
.sub_path = "bin/x64/D3D12SDKLayers.dll",
53+
},
5254
},
5355
install_dir,
5456
"d3d12/D3D12SDKLayers.dll",
@@ -61,13 +63,13 @@ pub fn install_directml(
6163
install_dir: std.Build.InstallDir,
6264
) void {
6365
const b = step.owner;
64-
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
6566
step.dependOn(
6667
&b.addInstallFileWithDir(
6768
.{
68-
.cwd_relative = b.pathJoin(
69-
&.{ source_path_prefix, "bin/x64/DirectML.dll" },
70-
),
69+
.dependency = .{
70+
.dependency = b.dependency("zwin32", .{}),
71+
.sub_path = "bin/x64/DirectML.dll",
72+
},
7173
},
7274
install_dir,
7375
"DirectML.dll",
@@ -76,9 +78,10 @@ pub fn install_directml(
7678
step.dependOn(
7779
&b.addInstallFileWithDir(
7880
.{
79-
.cwd_relative = b.pathJoin(
80-
&.{ source_path_prefix, "bin/x64/DirectML.Debug.dll" },
81-
),
81+
.dependency = .{
82+
.dependency = b.dependency("zwin32", .{}),
83+
.sub_path = "bin/x64/DirectML.Debug.dll",
84+
},
8285
},
8386
install_dir,
8487
"DirectML.Debug.dll",
@@ -163,10 +166,11 @@ pub const CompileShaders = struct {
163166
) void {
164167
const b = self.step.owner;
165168

166-
const zwin32_path = comptime std.fs.path.dirname(@src().file) orelse ".";
169+
const zwin32 = b.dependency("zwin32", .{});
170+
167171
const dxc_path = switch (builtin.target.os.tag) {
168-
.windows => zwin32_path ++ "/bin/x64/dxc.exe",
169-
.linux => zwin32_path ++ "/bin/x64/dxc",
172+
.windows => zwin32.path("bin/x64/dxc.exe").getPath(b),
173+
.linux => zwin32.path("bin/x64/dxc").getPath(b),
170174
else => @panic("Unsupported target"),
171175
};
172176

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

185189
const cmd_step = b.addSystemCommand(&dxc_command);
186190
if (builtin.target.os.tag == .linux) {
187-
cmd_step.setEnvironmentVariable(
188-
"LD_LIBRARY_PATH",
189-
zwin32_path ++ "/bin/x64",
190-
);
191+
cmd_step.setEnvironmentVariable("LD_LIBRARY_PATH", zwin32.path("bin/x64").getPath(b));
191192
}
192193
self.step.dependOn(&cmd_step.step);
193194
}

0 commit comments

Comments
 (0)