authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-30 20:29:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-30 20:29:33-04:00
log97f6b6093c082c232c0769d2e82e7503c7891248
tree16840f384b702d40a90faf57827b721c7f5fc537
parent2c6827064cf35be261790bfec29f88244c387c06

zig build can build and install static C libraries

See #332

1 files changed, 19 insertions(+), 2 deletions(-)

std/build.zig+19-2
...@@ -1032,7 +1032,7 @@ pub const CLibExeObjStep = struct {...@@ -1032,7 +1032,7 @@ pub const CLibExeObjStep = struct {
10321032
1033 pub fn createSharedLibrary(builder: &Builder, name: []const u8, version: &const Version) -> &CLibExeObjStep {1033 pub fn createSharedLibrary(builder: &Builder, name: []const u8, version: &const Version) -> &CLibExeObjStep {
1034 const self = %%builder.allocator.create(CLibExeObjStep);1034 const self = %%builder.allocator.create(CLibExeObjStep);
1035 *self = init(builder, name, Kind.Lib, builder.version(0, 0, 0), false);1035 *self = init(builder, name, Kind.Lib, version, false);
1036 return self;1036 return self;
1037 }1037 }
10381038
...@@ -1238,7 +1238,24 @@ pub const CLibExeObjStep = struct {...@@ -1238,7 +1238,24 @@ pub const CLibExeObjStep = struct {
1238 }1238 }
12391239
1240 if (self.static) {1240 if (self.static) {
1241 debug.panic("TODO static library");1241 // ar
1242 %%cc_args.resize(0);
1243 %%cc_args.append("qc");
1244
1245 const output_path = builder.pathFromRoot(self.getOutputPath());
1246 %%cc_args.append(output_path);
1247
1248 for (self.object_files.toSliceConst()) |object_file| {
1249 %%cc_args.append(builder.pathFromRoot(object_file));
1250 }
1251
1252 %return builder.spawnChild("ar", cc_args.toSliceConst());
1253
1254 // ranlib
1255 %%cc_args.resize(0);
1256 %%cc_args.append(output_path);
1257
1258 %return builder.spawnChild("ranlib", cc_args.toSliceConst());
1242 } else {1259 } else {
1243 %%cc_args.resize(0);1260 %%cc_args.resize(0);
12441261