Skip to content

Commit f382963

Browse files
committed
Upgrade to zig 0.15.1
1 parent d5e2d46 commit f382963

File tree

16 files changed

+155
-134
lines changed

16 files changed

+155
-134
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ on:
1616
- "tools/**"
1717
- "build.zig"
1818
- "build.zig.zon"
19-
- ".zigversion"
2019

2120
push:
2221
branches:
@@ -29,7 +28,6 @@ on:
2928
- "tools/**"
3029
- "build.zig"
3130
- "build.zig.zon"
32-
- ".zigversion"
3331

3432
concurrency:
3533
# Cancels pending runs when a PR gets updated.
@@ -47,16 +45,8 @@ jobs:
4745
with:
4846
submodules: true
4947

50-
- name: Read .zig-version
51-
id: zigversion
52-
uses: juliangruber/read-file-action@v1
53-
with:
54-
path: ./.zigversion
5548
- name: Install Zig
5649
uses: mlugg/setup-zig@v2
57-
with:
58-
version: ${{ steps.zigversion.outputs.content }}
59-
6050
- name: Lint
6151
run: zig fmt --check .
6252

@@ -83,15 +73,8 @@ jobs:
8373
# - if: matrix.os == 'linux-large'
8474
# run: sudo apt update && sudo apt install libx11-6
8575

86-
- name: Read .zig-version
87-
id: zigversion
88-
uses: juliangruber/read-file-action@v1
89-
with:
90-
path: ./.zigversion
9176
- name: Install Zig
9277
uses: mlugg/setup-zig@v2
93-
with:
94-
version: ${{ steps.zigversion.outputs.content }}
9578

9679
- name: Build examples
9780
shell: bash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Zig binding is licensed by [WTFPL](LICENSE)
3737

3838
## Zig version
3939

40-
Minimal is `0.14.0`. But you know try your version and believe.
40+
Minimal is `0.15.1`. But you know try your version and believe.
4141

4242
## Bgfx version
4343

build.zig

Lines changed: 60 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,33 @@ pub fn build(b: *std.Build) !void {
5656
//
5757
const combine_bin_h = b.addExecutable(.{
5858
.name = "combine_bin_h",
59-
.optimize = optimize,
60-
.target = target,
61-
.root_source_file = b.path("tools/combine_bin_h.zig"),
59+
.root_module = b.createModule(.{
60+
.root_source_file = b.path("tools/combine_bin_h.zig"),
61+
.target = target,
62+
.optimize = optimize,
63+
}),
6264
});
6365
const combine_bin_zig = b.addExecutable(.{
6466
.name = "combine_bin_zig",
65-
.optimize = optimize,
66-
.target = target,
67-
.root_source_file = b.path("tools/combine_bin_zig.zig"),
67+
.root_module = b.createModule(.{
68+
.root_source_file = b.path("tools/combine_bin_zig.zig"),
69+
.target = target,
70+
.optimize = optimize,
71+
}),
6872
});
6973

7074
b.installArtifact(combine_bin_zig);
7175

7276
//
7377
// Bx
7478
//
75-
const bx = b.addStaticLibrary(.{
79+
const bx = b.addLibrary(.{
80+
.linkage = .static,
7681
.name = "bx",
77-
.target = target,
78-
.optimize = optimize,
82+
.root_module = b.createModule(.{
83+
.target = target,
84+
.optimize = optimize,
85+
}),
7986
});
8087
bx.addCSourceFiles(.{
8188
.flags = &cxx_options,
@@ -90,10 +97,13 @@ pub fn build(b: *std.Build) !void {
9097
//
9198
// Bimg
9299
//
93-
const bimg = b.addStaticLibrary(.{
100+
const bimg = b.addLibrary(.{
101+
.linkage = .static,
94102
.name = "bimg",
95-
.target = target,
96-
.optimize = optimize,
103+
.root_module = b.createModule(.{
104+
.target = target,
105+
.optimize = optimize,
106+
}),
97107
});
98108
bimg.addCSourceFiles(.{
99109
.flags = &cxx_options,
@@ -114,10 +124,13 @@ pub fn build(b: *std.Build) !void {
114124
// Bgfx
115125
//
116126
const bgfx_path = "libs/bgfx/";
117-
const bgfx = b.addStaticLibrary(.{
127+
const bgfx = b.addLibrary(.{
128+
.linkage = .static,
118129
.name = "bgfx",
119-
.target = target,
120-
.optimize = optimize,
130+
.root_module = b.createModule(.{
131+
.target = target,
132+
.optimize = optimize,
133+
}),
121134
});
122135
b.installArtifact(bgfx);
123136
bxInclude(b, bgfx, target, optimize);
@@ -197,17 +210,16 @@ pub fn build(b: *std.Build) !void {
197210
// Shaderc
198211
// Base steal from https://github.com/Interrupt/zig-bgfx-example/blob/main/build_shader_compiler.zig
199212
//
200-
var shaderc_variant = std.ArrayList(*std.Build.Step.Compile).init(b.allocator);
201-
defer shaderc_variant.deinit();
202-
203213
if (options.with_shaderc) {
204214
//
205215
// Shaderc executable
206216
//
207217
const shaderc = b.addExecutable(.{
208218
.name = "shaderc",
209-
.target = target,
210-
.optimize = optimize,
219+
.root_module = b.createModule(.{
220+
.target = target,
221+
.optimize = optimize,
222+
}),
211223
});
212224

213225
b.installArtifact(shaderc);
@@ -340,10 +352,13 @@ pub fn build(b: *std.Build) !void {
340352
};
341353

342354
const fcpp_path = "libs/bgfx/3rdparty/fcpp/";
343-
const fcpp_lib = b.addStaticLibrary(.{
355+
const fcpp_lib = b.addLibrary(.{
356+
.linkage = .static,
344357
.name = "fcpp",
345-
.target = target,
346-
.optimize = optimize,
358+
.root_module = b.createModule(.{
359+
.target = target,
360+
.optimize = optimize,
361+
}),
347362
});
348363

349364
fcpp_lib.addIncludePath(b.path(fcpp_path));
@@ -372,10 +387,12 @@ pub fn build(b: *std.Build) !void {
372387
"-fno-sanitize=undefined",
373388
};
374389

375-
const spirv_opt_lib = b.addStaticLibrary(.{
390+
const spirv_opt_lib = b.addLibrary(.{
376391
.name = "spirv-opt",
377-
.target = target,
378-
.optimize = optimize,
392+
.root_module = b.createModule(.{
393+
.target = target,
394+
.optimize = optimize,
395+
}),
379396
});
380397
spirv_opt_lib.addIncludePath(b.path(spirv_opt_path));
381398
spirv_opt_lib.addIncludePath(b.path(spirv_opt_path ++ "include"));
@@ -404,10 +421,12 @@ pub fn build(b: *std.Build) !void {
404421
};
405422

406423
const spirv_cross_path = "libs/bgfx/3rdparty/spirv-cross/";
407-
const spirv_cross_lib = b.addStaticLibrary(.{
424+
const spirv_cross_lib = b.addLibrary(.{
408425
.name = "spirv-cross",
409-
.target = target,
410-
.optimize = optimize,
426+
.root_module = b.createModule(.{
427+
.target = target,
428+
.optimize = optimize,
429+
}),
411430
});
412431
spirv_cross_lib.addIncludePath(b.path(spirv_cross_path ++ "include"));
413432
spirv_cross_lib.addCSourceFiles(.{
@@ -440,7 +459,13 @@ pub fn build(b: *std.Build) !void {
440459
"-fno-sanitize=undefined",
441460
};
442461

443-
const glslang_lib = b.addStaticLibrary(.{ .name = "glslang", .target = target, .optimize = optimize });
462+
const glslang_lib = b.addLibrary(.{
463+
.name = "glslang",
464+
.root_module = b.createModule(.{
465+
.target = target,
466+
.optimize = optimize,
467+
}),
468+
});
444469
glslang_lib.addIncludePath(b.path("libs/bgfx/3rdparty"));
445470
glslang_lib.addIncludePath(b.path(glslang_path));
446471
glslang_lib.addIncludePath(b.path(glslang_path ++ "include"));
@@ -504,10 +529,12 @@ pub fn build(b: *std.Build) !void {
504529
"-fno-sanitize=undefined",
505530
};
506531

507-
const glsl_optimizer_lib = b.addStaticLibrary(.{
532+
const glsl_optimizer_lib = b.addLibrary(.{
508533
.name = "glsl-optimizer",
509-
.target = target,
510-
.optimize = optimize,
534+
.root_module = b.createModule(.{
535+
.target = target,
536+
.optimize = optimize,
537+
}),
511538
});
512539
glsl_optimizer_lib.addIncludePath(b.path(glsl_optimizer_path ++ "include"));
513540
glsl_optimizer_lib.addIncludePath(b.path(glsl_optimizer_path ++ "src"));

build.zig.zon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.{
22
.name = .zbgfx,
33
.fingerprint = 0xc48ed871c4086e4a,
4-
.version = "0.4.0",
4+
.version = "0.5.0",
5+
.minimum_zig_version = "0.15.1",
56
.paths = .{
67
"includes",
78
"libs",

examples/00-minimal/build_sample.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const zbgfx = @import("zbgfx");
44

55
pub fn build(
66
b: *std.Build,
7-
optimize: std.builtin.Mode,
7+
optimize: std.builtin.OptimizeMode,
88
target: std.Build.ResolvedTarget,
99
) !void {
1010
//
@@ -81,8 +81,10 @@ pub fn build(
8181

8282
const exe = b.addExecutable(.{
8383
.name = "00-minimal",
84-
.root_source_file = b.path("00-minimal/src/main.zig"),
85-
.target = target,
84+
.root_module = b.createModule(.{
85+
.root_source_file = b.path("00-minimal/src/main.zig"),
86+
.target = target,
87+
}),
8688
});
8789
b.installArtifact(exe);
8890
exe.linkLibrary(zbgfx_dep.artifact("bgfx"));

examples/01-zgui/build_sample.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const zbgfx = @import("zbgfx");
44

55
pub fn build(
66
b: *std.Build,
7-
optimize: std.builtin.Mode,
7+
optimize: std.builtin.OptimizeMode,
88
target: std.Build.ResolvedTarget,
99
) !void {
1010

@@ -31,6 +31,7 @@ pub fn build(
3131
.target = target,
3232
.optimize = optimize,
3333
.backend = .glfw,
34+
.disable_obsolete = false, // TODO: this is needed because bgfx imgui backend use obsolete functions.
3435
},
3536
);
3637

@@ -46,8 +47,10 @@ pub fn build(
4647

4748
const exe = b.addExecutable(.{
4849
.name = "01-zgui",
49-
.root_source_file = b.path("01-zgui/src/main.zig"),
50-
.target = target,
50+
.root_module = b.createModule(.{
51+
.root_source_file = b.path("01-zgui/src/main.zig"),
52+
.target = target,
53+
}),
5154
});
5255
b.installArtifact(exe);
5356

examples/02-runtime-shaderc/build_sample.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const zbgfx = @import("zbgfx");
44

55
pub fn build(
66
b: *std.Build,
7-
optimize: std.builtin.Mode,
7+
optimize: std.builtin.OptimizeMode,
88
target: std.Build.ResolvedTarget,
99
) !void {
1010
//
@@ -40,8 +40,10 @@ pub fn build(
4040

4141
const exe = b.addExecutable(.{
4242
.name = "02-runtime-shaderc",
43-
.root_source_file = b.path("02-runtime-shaderc/src/main.zig"),
44-
.target = target,
43+
.root_module = b.createModule(.{
44+
.root_source_file = b.path("02-runtime-shaderc/src/main.zig"),
45+
.target = target,
46+
}),
4547
});
4648
b.installArtifact(exe);
4749
exe.linkLibrary(zbgfx_dep.artifact("bgfx"));

examples/02-runtime-shaderc/src/main.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ fn readFileFromShaderDirs(allocator: std.mem.Allocator, filename: []const u8) ![
376376
const f = try std.fs.cwd().openFile(path, .{});
377377
defer f.close();
378378
const max_size = (try f.getEndPos()) + 1;
379-
var data = std.ArrayList(u8).init(allocator);
380-
try f.reader().readAllArrayList(&data, max_size);
379+
var data = std.array_list.Managed(u8).init(allocator);
380+
try f.deprecatedReader().readAllArrayList(&data, max_size);
381381

382382
return try data.toOwnedSliceSentinel(0);
383383
}

examples/03-debugdraw/build_sample.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const zbgfx = @import("zbgfx");
44

55
pub fn build(
66
b: *std.Build,
7-
optimize: std.builtin.Mode,
7+
optimize: std.builtin.OptimizeMode,
88
target: std.Build.ResolvedTarget,
99
) !void {
1010
//
@@ -40,8 +40,10 @@ pub fn build(
4040

4141
const exe = b.addExecutable(.{
4242
.name = "03-debugdraw",
43-
.root_source_file = b.path("03-debugdraw/src/main.zig"),
44-
.target = target,
43+
.root_module = b.createModule(.{
44+
.root_source_file = b.path("03-debugdraw/src/main.zig"),
45+
.target = target,
46+
}),
4547
});
4648
b.installArtifact(exe);
4749
exe.linkLibrary(zbgfx_dep.artifact("bgfx"));

examples/build.zig.zon

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.name = .examples,
33
.fingerprint = 0x7bd0ad45636a9f2b,
44
.version = "0.1.0",
5+
.minimum_zig_version = "0.15.1",
56
.paths = .{
67
"build.zig",
78
"build.zig.zon",
@@ -11,18 +12,18 @@
1112
.zbgfx = .{ .path = "../" },
1213

1314
.zglfw = .{
14-
.url = "https://github.com/zig-gamedev/zglfw/archive/dcb1dae7d4a90f88b70dbae73300ab9b19fb250c.tar.gz",
15-
.hash = "zglfw-0.10.0-dev-zgVDNJmZIQCIiO_94Sp5jqrPtz4Eumk3bDcxS7dSZfIj",
15+
.url = "https://github.com/zig-gamedev/zglfw/archive/3a3f0d2c040902c717402d58e96ae1553bee550d.tar.gz",
16+
.hash = "zglfw-0.10.0-dev-zgVDNHOuIQC9B7kIg7w6a0K07ZKD_QKYf-OJ6SqiLwg1",
1617
},
1718

1819
.zgui = .{
19-
.url = "https://github.com/zig-gamedev/zgui/archive/020b27ef9356abbecceb9e32103b79d4798a7b4a.tar.gz",
20-
.hash = "zgui-0.6.0-dev--L6sZMGHaAB-y1HhtLJ3CXhfoMOOi4RAJDdnr_IGYKoh",
20+
.url = "https://github.com/zig-gamedev/zgui/archive/1082a309eb423bde95dce0d57db7f8a0a5091b33.tar.gz",
21+
.hash = "zgui-0.6.0-dev--L6sZAzobQDQSKMsQdqmeqqvgN3ck6AgpY5E0uWGqRhM",
2122
},
2223

2324
.zmath = .{
24-
.url = "https://github.com/zig-gamedev/zmath/archive/ccf7297ef6c01e21b2d51ad81b5b6ce929e86a00.tar.gz",
25-
.hash = "zmath-0.11.0-dev-wjwivZY1AwDO7yxNmZ5HWoU03f9mFBet8LN9-oYc3i29",
25+
.url = "https://github.com/zig-gamedev/zmath/archive/3a5955b2b72cd081563fbb084eff05bffd1e3fbb.tar.gz",
26+
.hash = "zmath-0.11.0-dev-wjwivdMsAwD-xaLj76YHUq3t9JDH-X16xuMTmnDzqbu2",
2627
},
2728
},
2829
}

0 commit comments

Comments
 (0)