zig build: add setLibCFile API

This commit is contained in:
Andrew Kelley 2019-07-07 11:31:07 -04:00
parent 38ba412729
commit d39dcd6d9d
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -1053,6 +1053,8 @@ pub const LibExeObjStep = struct {
installed_path: ?[]const u8,
install_step: ?*InstallArtifactStep,
libc_file: ?[]const u8,
const LinkObject = union(enum) {
StaticPath: []const u8,
OtherStep: *LibExeObjStep,
@ -1146,6 +1148,7 @@ pub const LibExeObjStep = struct {
.single_threaded = false,
.installed_path = null,
.install_step = null,
.libc_file = null,
};
self.computeOutFileNames();
return self;
@ -1321,6 +1324,10 @@ pub const LibExeObjStep = struct {
self.disable_gen_h = value;
}
pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void {
self.libc_file = libc_file;
}
/// Unless setOutputDir was called, this function must be called only in
/// the make step, from a step that has declared a dependency on this one.
/// To run an executable built with zig build, use `run`, or create an install step and invoke it.
@ -1525,6 +1532,11 @@ pub const LibExeObjStep = struct {
try zig_args.append("--single-threaded");
}
if (self.libc_file) |libc_file| {
try zig_args.append("--libc");
try zig_args.append(builder.pathFromRoot(libc_file));
}
switch (self.build_mode) {
builtin.Mode.Debug => {},
builtin.Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,