Skip to content

Commit 8fefd0f

Browse files
committed
updates from monorepo 4d7d629a42af5bbe9f84cb69cae61662c064c51d
1 parent d816442 commit 8fefd0f

File tree

4 files changed

+43
-42
lines changed

4 files changed

+43
-42
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ pub fn build(b: *std.Build) !void {
4949
5050
// Install vendored binaries
5151
const zwindows = @import("zwindows");
52-
try zwindows.install_xaudio2(&exe.step, .bin);
53-
try zwindows.install_d3d12(&exe.step, .bin);
54-
try zwindows.install_directml(&exe.step, .bin);
52+
try zwindows.install_xaudio2(&exe.step, zwindows_dependency, .bin);
53+
try zwindows.install_d3d12(&exe.step, zwindows_dependency, .bin);
54+
try zwindows.install_directml(&exe.step, zwindows_dependency, .bin);
5555
}
5656
```
5757

build.zig

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,16 @@ pub fn build(b: *std.Build) !void {
5050

5151
pub fn install_xaudio2(
5252
step: *std.Build.Step,
53+
zwindows: *std.Build.Dependency,
5354
install_dir: std.Build.InstallDir,
5455
) void {
5556
const b = step.owner;
56-
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
5757
step.dependOn(
5858
&b.addInstallFileWithDir(
59-
.{
60-
.cwd_relative = b.pathJoin(
61-
&.{ source_path_prefix, "bin/x64/xaudio2_9redist.dll" },
62-
),
63-
},
59+
.{ .dependency = .{
60+
.dependency = zwindows,
61+
.sub_path = "bin/x64/xaudio2_9redist.dll",
62+
} },
6463
install_dir,
6564
"xaudio2_9redist.dll",
6665
).step,
@@ -69,28 +68,26 @@ pub fn install_xaudio2(
6968

7069
pub fn install_d3d12(
7170
step: *std.Build.Step,
71+
zwindows: *std.Build.Dependency,
7272
install_dir: std.Build.InstallDir,
7373
) void {
7474
const b = step.owner;
75-
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
7675
step.dependOn(
7776
&b.addInstallFileWithDir(
78-
.{
79-
.cwd_relative = b.pathJoin(
80-
&.{ source_path_prefix, "bin/x64/D3D12Core.dll" },
81-
),
82-
},
77+
.{ .dependency = .{
78+
.dependency = zwindows,
79+
.sub_path = "bin/x64/D3D12Core.dll",
80+
} },
8381
install_dir,
8482
"d3d12/D3D12Core.dll",
8583
).step,
8684
);
8785
step.dependOn(
8886
&b.addInstallFileWithDir(
89-
.{
90-
.cwd_relative = b.pathJoin(
91-
&.{ source_path_prefix, "bin/x64/D3D12SDKLayers.dll" },
92-
),
93-
},
87+
.{ .dependency = .{
88+
.dependency = zwindows,
89+
.sub_path = "bin/x64/D3D12SDKLayers.dll",
90+
} },
9491
install_dir,
9592
"d3d12/D3D12SDKLayers.dll",
9693
).step,
@@ -99,28 +96,26 @@ pub fn install_d3d12(
9996

10097
pub fn install_directml(
10198
step: *std.Build.Step,
99+
zwindows: *std.Build.Dependency,
102100
install_dir: std.Build.InstallDir,
103101
) void {
104102
const b = step.owner;
105-
const source_path_prefix = comptime std.fs.path.dirname(@src().file) orelse ".";
106103
step.dependOn(
107104
&b.addInstallFileWithDir(
108-
.{
109-
.cwd_relative = b.pathJoin(
110-
&.{ source_path_prefix, "bin/x64/DirectML.dll" },
111-
),
112-
},
105+
.{ .dependency = .{
106+
.dependency = zwindows,
107+
.sub_path = "bin/x64/DirectML.dll",
108+
} },
113109
install_dir,
114110
"DirectML.dll",
115111
).step,
116112
);
117113
step.dependOn(
118114
&b.addInstallFileWithDir(
119-
.{
120-
.cwd_relative = b.pathJoin(
121-
&.{ source_path_prefix, "bin/x64/DirectML.Debug.dll" },
122-
),
123-
},
115+
.{ .dependency = .{
116+
.dependency = zwindows,
117+
.sub_path = "bin/x64/DirectML.Debug.dll",
118+
} },
124119
install_dir,
125120
"DirectML.Debug.dll",
126121
).step,
@@ -129,6 +124,7 @@ pub fn install_directml(
129124

130125
pub const CompileShaders = struct {
131126
step: *std.Build.Step,
127+
zwindows: *std.Build.Dependency,
132128
shader_ver: []const u8,
133129

134130
pub fn addVsShader(
@@ -204,10 +200,9 @@ pub const CompileShaders = struct {
204200
) void {
205201
const b = self.step.owner;
206202

207-
const zwindows_path = comptime std.fs.path.dirname(@src().file) orelse ".";
208203
const dxc_path = switch (builtin.target.os.tag) {
209-
.windows => zwindows_path ++ "/bin/x64/dxc.exe",
210-
.linux => zwindows_path ++ "/bin/x64/dxc",
204+
.windows => self.zwindows.path("bin/x64/dxc.exe").getPath(b),
205+
.linux => self.zwindows.path("bin/x64/dxc").getPath(b),
211206
else => @panic("Unsupported target"),
212207
};
213208

@@ -227,16 +222,22 @@ pub const CompileShaders = struct {
227222
if (builtin.target.os.tag == .linux) {
228223
cmd_step.setEnvironmentVariable(
229224
"LD_LIBRARY_PATH",
230-
zwindows_path ++ "/bin/x64",
225+
self.zwindows.path("bin/x64").getPath(b),
231226
);
232227
}
233228
self.step.dependOn(&cmd_step.step);
234229
}
235230
};
236231

237-
pub fn addCompileShaders(b: *std.Build, comptime name: []const u8, options: struct { shader_ver: []const u8 }) CompileShaders {
232+
pub fn addCompileShaders(
233+
b: *std.Build,
234+
comptime name: []const u8,
235+
zwindows: *std.Build.Dependency,
236+
options: struct { shader_ver: []const u8 },
237+
) CompileShaders {
238238
return .{
239239
.step = b.step(name ++ "-dxc", "Build shaders for '" ++ name ++ "'"),
240+
.zwindows = zwindows,
240241
.shader_ver = options.shader_ver,
241242
};
242243
}

src/zd3d12.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub const VerticesHandle = struct {
6666

6767
fn init(comptime T: type, gctx: *GraphicsContext, vertices_length: usize) !VerticesHandle {
6868
switch (@typeInfo(T)) {
69-
.Struct => |s| {
69+
.@"struct" => |s| {
7070
if (s.layout != .@"extern") {
7171
@compileError(@typeName(T) ++ " must be extern");
7272
}
@@ -981,7 +981,7 @@ pub const GraphicsContext = struct {
981981
comptime T: type,
982982
) HResultError!ConstantBufferHandle(T) {
983983
switch (@typeInfo(T)) {
984-
.Struct => |s| {
984+
.@"struct" => |s| {
985985
if (s.layout != .@"extern") {
986986
@compileError(@typeName(T) ++ " must be extern");
987987
}
@@ -1072,7 +1072,7 @@ pub const GraphicsContext = struct {
10721072
vertices_length: usize,
10731073
) HResultError!VerticesHandle {
10741074
switch (@typeInfo(T)) {
1075-
.Struct => |s| {
1075+
.@"struct" => |s| {
10761076
if (s.layout != .@"extern") {
10771077
@compileError(@typeName(T) ++ " must be extern");
10781078
}
@@ -1663,7 +1663,7 @@ pub const GraphicsContext = struct {
16631663
) HResultError!ResourceHandle {
16641664
assert(gctx.is_cmdlist_opened);
16651665

1666-
var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
1666+
var buffer: [std.fs.max_path_bytes]u8 = undefined;
16671667
var fba = std.heap.FixedBufferAllocator.init(buffer[0..]);
16681668
const allocator = fba.allocator();
16691669

@@ -1802,7 +1802,7 @@ pub const GraphicsContext = struct {
18021802
) !ResourceHandle {
18031803
assert(gctx.is_cmdlist_opened);
18041804

1805-
var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
1805+
var buffer: [std.fs.max_path_bytes]u8 = undefined;
18061806
var fba = std.heap.FixedBufferAllocator.init(buffer[0..]);
18071807
const allocator = fba.allocator();
18081808

src/zxaudio2.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub const AudioContext = struct {
192192
}
193193

194194
pub fn loadSound(actx: *AudioContext, relpath: []const u8) SoundHandle {
195-
var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
195+
var buffer: [std.fs.max_path_bytes]u8 = undefined;
196196
var fba = std.heap.FixedBufferAllocator.init(buffer[0..]);
197197
const allocator = fba.allocator();
198198

0 commit comments

Comments
 (0)