From f92a48cde1a198ca536043ea8dcfbf17cf5f7460 Mon Sep 17 00:00:00 2001 From: andrewkraevskii Date: Thu, 19 Dec 2024 00:48:59 +0300 Subject: [PATCH] fix zig master build.zig --- build.zig | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/build.zig b/build.zig index a43dd10..f9cee5c 100644 --- a/build.zig +++ b/build.zig @@ -361,19 +361,40 @@ pub fn emLinkStep(b: *Build, options: EmLinkOptions) !*Build.Step.InstallDir { // add the main lib, and then scan for library dependencies and add those too emcc.addArtifactArg(options.lib_main); - var it = options.lib_main.root_module.iterateDependencies(options.lib_main, false); - while (it.next()) |item| { - for (item.module.link_objects.items) |link_object| { - switch (link_object) { - .other_step => |compile_step| { - switch (compile_step.kind) { - .lib => { - emcc.addArtifactArg(compile_step); - }, - else => {}, - } - }, - else => {}, + + // TODO: This is hack to support master and 0.13.0 zig versions. Remove after 0.14.0. + if (@tagName(@typeInfo(@TypeOf(options.lib_main.root_module)))[0] == 'p') { + const it = options.lib_main.getCompileDependencies(false); + for (it) |item| { + for (item.root_module.link_objects.items) |link_object| { + switch (link_object) { + .other_step => |compile_step| { + switch (compile_step.kind) { + .lib => { + emcc.addArtifactArg(compile_step); + }, + else => {}, + } + }, + else => {}, + } + } + } + } else { + var it = options.lib_main.root_module.iterateDependencies(options.lib_main, false); + while (it.next()) |item| { + for (item.module.link_objects.items) |link_object| { + switch (link_object) { + .other_step => |compile_step| { + switch (compile_step.kind) { + .lib => { + emcc.addArtifactArg(compile_step); + }, + else => {}, + } + }, + else => {}, + } } } }