Function resolveInstallPrefix [src]
This function is intended to be called by lib/build_runner.zig, not a build.zig file.
Prototype
pub fn resolveInstallPrefix(b: *Build, install_prefix: ?[]const u8, dir_list: DirList) void
Parameters
b: *Build
install_prefix: ?[]const u8
dir_list: DirList
Source
pub fn resolveInstallPrefix(b: *Build, install_prefix: ?[]const u8, dir_list: DirList) void {
if (b.dest_dir) |dest_dir| {
b.install_prefix = install_prefix orelse "/usr";
b.install_path = b.pathJoin(&.{ dest_dir, b.install_prefix });
} else {
b.install_prefix = install_prefix orelse
(b.build_root.join(b.allocator, &.{"zig-out"}) catch @panic("unhandled error"));
b.install_path = b.install_prefix;
}
var lib_list = [_][]const u8{ b.install_path, "lib" };
var exe_list = [_][]const u8{ b.install_path, "bin" };
var h_list = [_][]const u8{ b.install_path, "include" };
if (dir_list.lib_dir) |dir| {
if (fs.path.isAbsolute(dir)) lib_list[0] = b.dest_dir orelse "";
lib_list[1] = dir;
}
if (dir_list.exe_dir) |dir| {
if (fs.path.isAbsolute(dir)) exe_list[0] = b.dest_dir orelse "";
exe_list[1] = dir;
}
if (dir_list.include_dir) |dir| {
if (fs.path.isAbsolute(dir)) h_list[0] = b.dest_dir orelse "";
h_list[1] = dir;
}
b.lib_dir = b.pathJoin(&lib_list);
b.exe_dir = b.pathJoin(&exe_list);
b.h_dir = b.pathJoin(&h_list);
}