std/build: add --sysroot general option

This commit is contained in:
Isaac Freund 2021-06-25 14:04:38 +02:00
parent 16228e87d6
commit e75dfbcb3f
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
2 changed files with 12 additions and 0 deletions

View File

@ -57,6 +57,7 @@ pub const Builder = struct {
exe_dir: []const u8,
h_dir: []const u8,
install_path: []const u8,
sysroot: ?[]const u8 = null,
search_prefixes: ArrayList([]const u8),
libc_file: ?[]const u8 = null,
installed_files: ArrayList(InstalledFile),
@ -2601,6 +2602,10 @@ pub const LibExeObjStep = struct {
}
}
if (builder.sysroot) |sysroot| {
try zig_args.appendSlice(&[_][]const u8{ "--sysroot", sysroot });
}
for (builder.search_prefixes.items) |search_prefix| {
try zig_args.append("-L");
try zig_args.append(try fs.path.join(builder.allocator, &[_][]const u8{

View File

@ -87,6 +87,12 @@ pub fn main() !void {
warn("Expected argument after {s}\n\n", .{arg});
return usageAndErr(builder, false, stderr_stream);
};
} else if (mem.eql(u8, arg, "--sysroot")) {
const sysroot = nextArg(args, &arg_idx) orelse {
warn("Expected argument after --sysroot\n\n", .{});
return usageAndErr(builder, false, stderr_stream);
};
builder.sysroot = sysroot;
} else if (mem.eql(u8, arg, "--search-prefix")) {
const search_prefix = nextArg(args, &arg_idx) orelse {
warn("Expected argument after --search-prefix\n\n", .{});
@ -195,6 +201,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
\\ -h, --help Print this help and exit
\\ --verbose Print commands before executing them
\\ -p, --prefix [path] Override default install prefix
\\ --sysroot [path] Set the system root directory (usually /)
\\ --search-prefix [path] Add a path to look for binaries, libraries, headers
\\ --libc [file] Provide a file which specifies libc paths
\\ --color [auto|off|on] Enable or disable colored error messages