authorgravatar for 2179872-misanthrop@users.noreply.gitlab.comSashko <2179872-misanthrop@users.noreply.gitlab.com> 2024-03-12 09:08:03+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-01 16:36:13-07:00
log604a332e21f9aaff13c7b13331d9c6926c6c9d52
tree8d5b8515871329a287015b017a02f4abb27b5248
parentcb308ba3ac2d7e3735d1cb42ef085edb1e6db723

Extract getZigArgs function in std.Build.Step.Compile


1 files changed, 13 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,10 +989,10 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking
989 return path;989 return path;
990}990}
991991
992fn make(step: *Step, prog_node: std.Progress.Node) !void {992fn getZigArgs(compile: *Compile) ![][]const u8 {
993 const step = &compile.step;
993 const b = step.owner;994 const b = step.owner;
994 const arena = b.allocator;995 const arena = b.allocator;
995 const compile: *Compile = @fieldParentPtr("step", step);
996996
997 var zig_args = ArrayList([]const u8).init(arena);997 var zig_args = ArrayList([]const u8).init(arena);
998 defer zig_args.deinit();998 defer zig_args.deinit();
...@@ -1298,6 +1298,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {...@@ -1298,6 +1298,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
1298 // We need to emit the --mod argument here so that the above link objects1298 // We need to emit the --mod argument here so that the above link objects
1299 // have the correct parent module, but only if the module is part of1299 // have the correct parent module, but only if the module is part of
1300 // this compilation.1300 // this compilation.
1301 if (!my_responsibility) continue;
1301 if (cli_named_modules.modules.getIndex(dep.module)) |module_cli_index| {1302 if (cli_named_modules.modules.getIndex(dep.module)) |module_cli_index| {
1302 const module_cli_name = cli_named_modules.names.keys()[module_cli_index];1303 const module_cli_name = cli_named_modules.names.keys()[module_cli_index];
1303 try dep.module.appendZigProcessFlags(&zig_args, step);1304 try dep.module.appendZigProcessFlags(&zig_args, step);
...@@ -1724,7 +1725,16 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {...@@ -1724,7 +1725,16 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
1724 try zig_args.append(resolved_args_file);1725 try zig_args.append(resolved_args_file);
1725 }1726 }
17261727
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
1731fn 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 error.NeedCompileErrorCheck => {1738 error.NeedCompileErrorCheck => {
1729 assert(compile.expect_errors != null);1739 assert(compile.expect_errors != null);
1730 try checkCompileErrors(compile);1740 try checkCompileErrors(compile);