Zig 0.13.0 update

This commit is contained in:
sergeypdev 2024-07-13 20:05:53 +04:00
parent 8033d99423
commit 23f5c6836a
4 changed files with 24 additions and 22 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
zig-out
zig-cache
.zig-cache
dbg.rdbg
assetc.rdbg
.vs

View File

@ -25,8 +25,8 @@ pub fn build(b: *Build) void {
const zalgebra_dep = b.dependency("zalgebra", .{});
const assets_mod = b.addModule("assets", .{ .root_source_file = .{ .path = "src/assets/root.zig" } });
const asset_manifest_mod = b.addModule("asset_manifest", .{ .root_source_file = .{ .path = "src/gen/asset_manifest.zig" } });
const assets_mod = b.addModule("assets", .{ .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/assets/root.zig" } } });
const asset_manifest_mod = b.addModule("asset_manifest", .{ .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/gen/asset_manifest.zig" } } });
asset_manifest_mod.addImport("assets", assets_mod);
const assets_step = b.step("assets", "Build and install assets");
@ -47,12 +47,12 @@ pub fn build(b: *Build) void {
const lib = b.addSharedLibrary(.{
.name = "learnopengl",
.root_source_file = .{ .path = "src/game.zig" },
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/game.zig" } },
.target = target,
.optimize = optimize,
});
const lib_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/game.zig" },
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/game.zig" } },
.target = target,
.optimize = optimize,
});
@ -71,15 +71,17 @@ pub fn build(b: *Build) void {
.name = "learnopengl",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } },
.target = target,
.optimize = optimize,
});
if (b.systemIntegrationOption("SDL2", .{ .default = b.host.result.os.tag != .windows })) {
exe.linkSystemLibrary("SDL2");
exe.linkLibC();
inline for (lib_compiles) |l| {
l.linkSystemLibrary("SDL2");
l.linkLibC();
}
} else {
const sdl_dep = b.dependency("SDL", .{
@ -128,7 +130,7 @@ pub fn build(b: *Build) void {
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const exe_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } },
.target = target,
.optimize = optimize,
});
@ -190,7 +192,7 @@ fn buildAssets(b: *std.Build, install_assetc_step: *Step, step: *Step, assetc: *
run_assetc.addPathDir(b.pathFromRoot("libs/ispc_texcomp/lib"));
// Absolute input file arg, this will add it to step deps, cache and all that good stuff
run_assetc.addFileArg(.{ .path = b.pathJoin(&.{ path, entry.path }) });
run_assetc.addFileArg(.{ .src_path = .{ .owner = b, .sub_path = b.pathJoin(&.{ path, entry.path }) } });
// Generated output dir. Output asset(s) will be placed there at the same relative path as input
const result_dir = run_assetc.addOutputFileArg("assets");
@ -220,7 +222,7 @@ fn buildAssetCompiler(b: *Build, optimize: std.builtin.OptimizeMode, assets_mod:
const assetc = b.addExecutable(.{
.name = "assetc",
.target = b.host,
.root_source_file = .{ .path = "tools/asset_compiler.zig" },
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "tools/asset_compiler.zig" } },
.optimize = optimize,
});
assetc.linkLibC();
@ -229,12 +231,12 @@ fn buildAssetCompiler(b: *Build, optimize: std.builtin.OptimizeMode, assets_mod:
b.installFile("libs/ispc_texcomp/lib/ispc_texcomp.dll", "ispc_texcomp.dll");
b.installFile("libs/ispc_texcomp/lib/ispc_texcomp.pdb", "ispc_texcomp.pdb");
}
assetc.addLibraryPath(.{ .path = "libs/ispc_texcomp/lib" });
assetc.addIncludePath(.{ .path = "libs/ispc_texcomp/include" });
assetc.addLibraryPath(.{ .src_path = .{ .owner = b, .sub_path = "libs/ispc_texcomp/lib" } });
assetc.addIncludePath(.{ .src_path = .{ .owner = b, .sub_path = "libs/ispc_texcomp/include" } });
assetc.linkSystemLibrary("ispc_texcomp");
const zalgebra_mod = zalgebra_dep.module("zalgebra");
const formats_mod = b.addModule("formats", .{ .root_source_file = .{ .path = "src/formats.zig" } });
const formats_mod = b.addModule("formats", .{ .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/formats.zig" } } });
formats_mod.addImport("zalgebra", zalgebra_mod);
formats_mod.addImport("assets", assets_mod);
assetc.root_module.addImport("formats", formats_mod);
@ -245,8 +247,8 @@ fn buildAssetCompiler(b: *Build, optimize: std.builtin.OptimizeMode, assets_mod:
assetc.linkLibC();
assetc.linkLibCpp();
assetc.addCSourceFile(.{ .file = .{ .path = "libs/stb/stb_image.c" }, .flags = &.{"-std=c99"} });
assetc.addIncludePath(.{ .path = "libs/stb" });
assetc.addCSourceFile(.{ .file = .{ .src_path = .{ .owner = b, .sub_path = "libs/stb/stb_image.c" } }, .flags = &.{"-std=c99"} });
assetc.addIncludePath(.{ .src_path = .{ .owner = b, .sub_path = "libs/stb" } });
return assetc;
}

View File

@ -16,16 +16,16 @@
// internet connectivity.
.dependencies = .{
.SDL = .{
.url = "https://github.com/sergeypdev/SDL/tarball/d676fac90d338b10453966bee173ffe299b6f851",
.hash = "12201f4fc3c26377eb3f7645cf6b2dd588b5868ba6b85e60fa36b5ea568b28243d62",
.url = "https://github.com/sergeypdev/SDL/tarball/9345142fc69669541ccff66dd531edf74f7055c5",
.hash = "122098348d9cee1436ba220e9ea1cc6056b775fa4d70681adf7b63c99c5f105b7dc0",
},
.@"zig-assimp" = .{
.url = "https://github.com/sergeypdev/zig-assimp/tarball/b10b2f03e2f3ab4a56948c583632dee61cc5fa21",
.hash = "1220c43c5a676ba3113f4b3c1b35d8e7eab272f87ec9e78057077e685ecee655beed",
.url = "https://github.com/sergeypdev/zig-assimp/tarball/dd20d3d3555136f5d108a4f5e04e0a696ed4774f",
.hash = "1220e845d7a9eb54d0bd93409ff594c7e8522881119521e3848bf9ba450b43d1af7c",
},
.zalgebra = .{
.url = "https://github.com/sergeypdev/zalgebra/tarball/f6aa18f74b8935887595d5793d73181d44a80735",
.hash = "1220fb0aa4a9e27e1e74c94072827e21114609b7122d4038e30aa9e4f66f6c6fc00d",
.url = "https://github.com/sergeypdev/zalgebra/tarball/43371bf211ad574cde90f653fea171f1cccb1716",
.hash = "1220e1439198c5206dbb924420aac0f57dd11fd4b6639e1aa9559abc09f91bfd2c9a",
},
},
.paths = .{

View File

@ -30,7 +30,7 @@ pub fn create(b: *Build) *GenerateAssetManifest {
}
pub fn getAssetManifest(self: *const GenerateAssetManifest) Build.LazyPath {
return Build.LazyPath{ .generated = &self.generated_manifest };
return Build.LazyPath{ .generated = .{ .file = &self.generated_manifest } };
}
pub fn addAssetListFile(self: *GenerateAssetManifest, file: Build.LazyPath) void {
@ -40,7 +40,7 @@ pub fn addAssetListFile(self: *GenerateAssetManifest, file: Build.LazyPath) void
const AssetMap = std.AutoHashMap(types.AssetType, NestedAssetDef);
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
fn make(step: *Step, prog_node: std.Progress.Node) !void {
_ = prog_node; // autofix
const b = step.owner;
var arena = std.heap.ArenaAllocator.init(b.allocator);