| ... | @@ -2075,7 +2075,7 @@ fn findPkgHashOrFatal(b: *Build, name: []const u8) []const u8 { | ... | @@ -2075,7 +2075,7 @@ fn findPkgHashOrFatal(b: *Build, name: []const u8) []const u8 { |
| 2075 | for (b.available_deps) |dep| { | 2075 | for (b.available_deps) |dep| { |
| 2076 | if (mem.eql(u8, dep[0], name)) return dep[1]; | 2076 | if (mem.eql(u8, dep[0], name)) return dep[1]; |
| 2077 | } | 2077 | } |
| 2078 | std.log.info("all dependencies used by build.zig must be declared in corresponding build.zig.zon", .{}); | 2078 | log.info("all dependencies used by build.zig must be declared in corresponding build.zig.zon", .{}); |
| 2079 | if (b.pkg_hash.len == 0) panic("no dependency named {s}", .{name}); | 2079 | if (b.pkg_hash.len == 0) panic("no dependency named {s}", .{name}); |
| 2080 | panic("no dependency named {s} in {s} ({s})", .{ name, b.dep_prefix, b.pkg_hash }); | 2080 | panic("no dependency named {s} in {s} ({s})", .{ name, b.dep_prefix, b.pkg_hash }); |
| 2081 | } | 2081 | } |
| ... | @@ -2335,7 +2335,7 @@ fn dependencyInner( | ... | @@ -2335,7 +2335,7 @@ fn dependencyInner( |
| 2335 | | 2335 | |
| 2336 | const sub_builder = b.createChild(name, dep_root, pkg_hash, pkg_deps, user_input_options) catch @panic("OOM"); | 2336 | const sub_builder = b.createChild(name, dep_root, pkg_hash, pkg_deps, user_input_options) catch @panic("OOM"); |
| 2337 | if (build_zig) |bz| { | 2337 | if (build_zig) |bz| { |
| 2338 | sub_builder.runBuild(bz); | 2338 | sub_builder.runPackageScript(bz); |
| 2339 | | 2339 | |
| 2340 | if (sub_builder.validateUserInputDidItFail()) { | 2340 | if (sub_builder.validateUserInputDidItFail()) { |
| 2341 | std.debug.dumpCurrentStackTrace(.{ .first_address = @returnAddress() }); | 2341 | std.debug.dumpCurrentStackTrace(.{ .first_address = @returnAddress() }); |
| ... | @@ -2353,11 +2353,19 @@ fn dependencyInner( | ... | @@ -2353,11 +2353,19 @@ fn dependencyInner( |
| 2353 | } | 2353 | } |
| 2354 | | 2354 | |
| 2355 | /// Build system implementation detail. | 2355 | /// Build system implementation detail. |
| 2356 | pub fn runBuild(b: *Build, build_zig: anytype) void { | 2356 | pub inline fn runPackageScript(b: *Build, comptime build_zig: anytype) void { |
| 2357 | switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).@"fn".return_type.?)) { | 2357 | const result: anyerror!void = build_zig.build(b); |
| 2358 | .error_union => return build_zig.build(b) catch unreachable, | 2358 | result catch |err| switch (err) { |
| 2359 | else => return build_zig.build(b), | 2359 | error.LazyDependencyNeeded => assert(b.graph.needed_lazy_dependencies.count() != 0), |
| 2360 | } | 2360 | else => { |
| | 2361 | if (@errorReturnTrace()) |trace| std.debug.dumpErrorReturnTrace(trace); |
| | 2362 | if (b.dep_prefix.len == 0) { |
| | 2363 | process.fatal("package {q} configuration failed: {t}", .{ b.dep_prefix, err }); |
| | 2364 | } else { |
| | 2365 | process.fatal("configuration failed: {t}", .{err}); |
| | 2366 | } |
| | 2367 | }, |
| | 2368 | }; |
| 2361 | } | 2369 | } |
| 2362 | | 2370 | |
| 2363 | // dirnameAllowEmpty is a variant of fs.path.dirname | 2371 | // dirnameAllowEmpty is a variant of fs.path.dirname |