Allocate build_runner args directly
This commit is contained in:
parent
399fa7fd09
commit
cbc6feeb76
@ -178,38 +178,33 @@ fn loadBuildConfiguration(context: LoadBuildConfigContext) !void {
|
|||||||
defer if (context.build_file_path == null) allocator.free(build_file_path);
|
defer if (context.build_file_path == null) allocator.free(build_file_path);
|
||||||
const directory_path = build_file_path[0 .. build_file_path.len - "build.zig".len];
|
const directory_path = build_file_path[0 .. build_file_path.len - "build.zig".len];
|
||||||
|
|
||||||
// enough capacity for arguments always passed to the build runner plus a couple build options
|
const standard_args = &[_][]const u8{
|
||||||
var arglist = try std.ArrayListUnmanaged([]const u8).initCapacity(arena_allocator, 32);
|
zig_exe_path,
|
||||||
defer arglist.deinit(arena_allocator);
|
"run",
|
||||||
|
build_runner_path,
|
||||||
|
"--cache-dir",
|
||||||
|
global_cache_path,
|
||||||
|
"--pkg-begin",
|
||||||
|
"@build@",
|
||||||
|
build_file_path,
|
||||||
|
"--pkg-end",
|
||||||
|
"--",
|
||||||
|
zig_exe_path,
|
||||||
|
directory_path,
|
||||||
|
context.cache_root,
|
||||||
|
context.global_cache_root,
|
||||||
|
};
|
||||||
|
|
||||||
try arglist.appendSlice(
|
var args = try arena_allocator.alloc([]const u8, standard_args.len + if (build_file.build_options) |opts| opts.len else 0);
|
||||||
arena_allocator,
|
defer arena_allocator.free(args);
|
||||||
&[_][]const u8{
|
|
||||||
zig_exe_path,
|
|
||||||
"run",
|
|
||||||
build_runner_path,
|
|
||||||
"--cache-dir",
|
|
||||||
global_cache_path,
|
|
||||||
"--pkg-begin",
|
|
||||||
"@build@",
|
|
||||||
build_file_path,
|
|
||||||
"--pkg-end",
|
|
||||||
"--",
|
|
||||||
zig_exe_path,
|
|
||||||
directory_path,
|
|
||||||
context.cache_root,
|
|
||||||
context.global_cache_root,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
|
args[0..standard_args.len].* = standard_args.*;
|
||||||
if (build_file.build_options) |opts| {
|
if (build_file.build_options) |opts| {
|
||||||
for (opts) |opt| {
|
for (opts) |opt, i| {
|
||||||
try arglist.append(allocator, try opt.formatParam(arena_allocator));
|
args[standard_args.len + i] = try opt.formatParam(arena_allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const args: []const []const u8 = arglist.items;
|
|
||||||
|
|
||||||
const zig_run_result = try std.ChildProcess.exec(.{
|
const zig_run_result = try std.ChildProcess.exec(.{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.argv = args,
|
.argv = args,
|
||||||
|
Loading…
Reference in New Issue
Block a user