Commit d39dcd6d9d

Andrew Kelley <andrew@ziglang.org>
2019-07-07 17:31:07
zig build: add setLibCFile API
1 parent 38ba412
Changed files (1)
std/build.zig
@@ -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,