| author | |
| committer | |
| log | fed8d9054ca2cf8aca9c3583177ffd0263fc76ac |
| tree | f1bd00cca3c4ad175132dca756711acea6ae957d |
| parent | 8ef24461a0016062e0ca20d1a152dd82fac511ab |
| parent | 8db1490b8a36155d85a2d5741f97984ff583cfde |
| signature |
Fix adding module arguments for Step.Compile6 files changed, 69 insertions(+), 3 deletions(-)
lib/std/Build/Step/Compile.zig+13-3| ... | ... | @@ -989,10 +989,10 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking |
| 989 | 989 | return path; |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 992 | fn getZigArgs(compile: *Compile) ![][]const u8 { | |
| 993 | const step = &compile.step; | |
| 993 | 994 | const b = step.owner; |
| 994 | 995 | const arena = b.allocator; |
| 995 | const compile: *Compile = @fieldParentPtr("step", step); | |
| 996 | 996 | |
| 997 | 997 | var zig_args = ArrayList([]const u8).init(arena); |
| 998 | 998 | defer zig_args.deinit(); |
| ... | ... | @@ -1298,6 +1298,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { |
| 1298 | 1298 | // We need to emit the --mod argument here so that the above link objects |
| 1299 | 1299 | // have the correct parent module, but only if the module is part of |
| 1300 | 1300 | // this compilation. |
| 1301 | if (!my_responsibility) continue; | |
| 1301 | 1302 | if (cli_named_modules.modules.getIndex(dep.module)) |module_cli_index| { |
| 1302 | 1303 | const module_cli_name = cli_named_modules.names.keys()[module_cli_index]; |
| 1303 | 1304 | try dep.module.appendZigProcessFlags(&zig_args, step); |
| ... | ... | @@ -1724,7 +1725,16 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { |
| 1724 | 1725 | try zig_args.append(resolved_args_file); |
| 1725 | 1726 | } |
| 1726 | 1727 | |
| 1727 | const maybe_output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) { | |
| 1728 | return try zig_args.toOwnedSlice(); | |
| 1729 | } | |
| 1730 | ||
| 1731 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | |
| 1732 | const b = step.owner; | |
| 1733 | const compile: *Compile = @fieldParentPtr("step", step); | |
| 1734 | ||
| 1735 | const zig_args = try getZigArgs(compile); | |
| 1736 | ||
| 1737 | const maybe_output_bin_path = step.evalZigProcess(zig_args, prog_node) catch |err| switch (err) { | |
| 1728 | 1738 | error.NeedCompileErrorCheck => { |
| 1729 | 1739 | assert(compile.expect_errors != null); |
| 1730 | 1740 | try checkCompileErrors(compile); |
test/standalone/build.zig.zon+3| ... | ... | @@ -86,6 +86,9 @@ |
| 86 | 86 | .dirname = .{ |
| 87 | 87 | .path = "dirname", |
| 88 | 88 | }, |
| 89 | .dep_duplicate_module = .{ | |
| 90 | .path = "dep_duplicate_module", | |
| 91 | }, | |
| 89 | 92 | .empty_env = .{ |
| 90 | 93 | .path = "empty_env", |
| 91 | 94 | }, |
test/standalone/dep_duplicate_module/build.zig created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn build(b: *std.Build) void { | |
| 4 | const target = b.standardTargetOptions(.{}); | |
| 5 | const optimize = b.standardOptimizeOption(.{}); | |
| 6 | ||
| 7 | const mod = b.addModule("mod", .{ | |
| 8 | .root_source_file = b.path("mod.zig"), | |
| 9 | .target = target, | |
| 10 | .optimize = optimize, | |
| 11 | }); | |
| 12 | ||
| 13 | const lib = b.addStaticLibrary(.{ | |
| 14 | .name = "lib", | |
| 15 | .root_source_file = b.path("lib.zig"), | |
| 16 | .target = target, | |
| 17 | .optimize = optimize, | |
| 18 | }); | |
| 19 | lib.root_module.addImport("mod", mod); | |
| 20 | ||
| 21 | const exe = b.addExecutable(.{ | |
| 22 | .name = "app", | |
| 23 | .root_source_file = b.path("main.zig"), | |
| 24 | .target = target, | |
| 25 | .optimize = optimize, | |
| 26 | }); | |
| 27 | ||
| 28 | exe.root_module.addImport("mod", mod); | |
| 29 | exe.root_module.linkLibrary(lib); | |
| 30 | ||
| 31 | b.installArtifact(exe); | |
| 32 | } |
test/standalone/dep_duplicate_module/lib.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | const std = @import("std"); | |
| 2 | const mod = @import("mod"); | |
| 3 | ||
| 4 | export fn work(x: u32) u32 { | |
| 5 | return mod.double(x); | |
| 6 | } |
test/standalone/dep_duplicate_module/main.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | const std = @import("std"); | |
| 2 | const mod = @import("mod"); | |
| 3 | ||
| 4 | extern fn work(x: u32) u32; | |
| 5 | ||
| 6 | pub fn main() !void { | |
| 7 | _ = work(mod.half(25)); | |
| 8 | } |
test/standalone/dep_duplicate_module/mod.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | pub fn double(v: u32) u32 { | |
| 2 | return v * 2; | |
| 3 | } | |
| 4 | ||
| 5 | pub fn half(v: u32) u32 { | |
| 6 | return v / 2; | |
| 7 | } |