From 3c4535a32111fc995d805c015f8f89b9b608e01d Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Thu, 29 Sep 2022 20:48:37 +0100 Subject: [PATCH] support 0.9.1 (#691) --- src/special/build_runner.zig | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/special/build_runner.zig b/src/special/build_runner.zig index 1cdc3d1..66a5b26 100644 --- a/src/special/build_runner.zig +++ b/src/special/build_runner.zig @@ -118,7 +118,10 @@ pub fn main() !void { ); } -fn reifyOptions(step: *std.build.Step) !void { +fn reifyOptions(step: *std.build.Step) anyerror!void { + // Support Zig 0.9.1 + if (!@hasDecl(OptionsStep, "base_id")) return; + if (step.cast(OptionsStep)) |option| { // We don't know how costly the dependency tree might be, so err on the side of caution if (step.dependencies.items.len == 0) { @@ -138,8 +141,8 @@ fn processStep( step: *std.build.Step, ) anyerror!void { if (step.cast(InstallArtifactStep)) |install_exe| { - if(install_exe.artifact.root_src) |src| { - try packages.append(allocator, .{.name = "root", .path = src.path }); + if (install_exe.artifact.root_src) |src| { + try packages.append(allocator, .{ .name = "root", .path = src.path }); } try processIncludeDirs(allocator, include_dirs, install_exe.artifact.include_dirs.items); @@ -148,8 +151,8 @@ fn processStep( try processPackage(allocator, packages, pkg); } } else if (step.cast(LibExeObjStep)) |exe| { - if(exe.root_src) |src| { - try packages.append(allocator, .{.name = "root", .path = src.path }); + if (exe.root_src) |src| { + try packages.append(allocator, .{ .name = "root", .path = src.path }); } try processIncludeDirs(allocator, include_dirs, exe.include_dirs.items); try processPkgConfig(allocator, include_dirs, exe); @@ -172,7 +175,9 @@ fn processPackage( if (std.mem.eql(u8, package.name, pkg.name)) return; } + // Support Zig 0.9.1 const source = if (@hasField(std.build.Pkg, "source")) pkg.source else pkg.path; + const maybe_path = switch (source) { .path => |path| path, .generated => |generated| generated.path, @@ -216,6 +221,9 @@ fn processPkgConfig( if (link_object != .system_lib) continue; const system_lib = link_object.system_lib; + // Support Zig 0.9.1 + if (@TypeOf(system_lib) == []const u8) return; + if (system_lib.use_pkg_config == .no) continue; getPkgConfigIncludes(allocator, include_dirs, exe, system_lib.name) catch |err| switch (err) {