@@ -258,9 +258,15 @@ pub const Builder = struct {
258258 }));
259259 }
260260
261- pub fn addSharedLibrary (self : * Builder , name : []const u8 , root_src : ? []const u8 , ver : Version ) * LibExeObjStep {
261+ pub fn addSharedLibrary (self : * Builder , name : []const u8 , root_src : ? []const u8 , kind : union (enum ) {
262+ versioned : Version ,
263+ unversioned : void ,
264+ }) * LibExeObjStep {
262265 const root_src_param = if (root_src ) | p | @as (FileSource , .{ .path = p }) else null ;
263- return LibExeObjStep .createSharedLibrary (self , name , root_src_param , ver );
266+ return LibExeObjStep .createSharedLibrary (self , name , root_src_param , switch (kind ) {
267+ .versioned = > | ver | ver ,
268+ .unversioned = > null ,
269+ });
264270 }
265271
266272 pub fn addStaticLibrary (self : * Builder , name : []const u8 , root_src : ? []const u8 ) * LibExeObjStep {
@@ -1166,7 +1172,7 @@ pub const LibExeObjStep = struct {
11661172 version_script : ? []const u8 = null ,
11671173 out_filename : []const u8 ,
11681174 is_dynamic : bool ,
1169- version : Version ,
1175+ version : ? Version ,
11701176 build_mode : builtin.Mode ,
11711177 kind : Kind ,
11721178 major_only_filename : []const u8 ,
@@ -1268,33 +1274,33 @@ pub const LibExeObjStep = struct {
12681274 Test ,
12691275 };
12701276
1271- pub fn createSharedLibrary (builder : * Builder , name : []const u8 , root_src : ? FileSource , ver : Version ) * LibExeObjStep {
1277+ pub fn createSharedLibrary (builder : * Builder , name : []const u8 , root_src : ? FileSource , ver : ? Version ) * LibExeObjStep {
12721278 const self = builder .allocator .create (LibExeObjStep ) catch unreachable ;
12731279 self .* = initExtraArgs (builder , name , root_src , Kind .Lib , true , ver );
12741280 return self ;
12751281 }
12761282
12771283 pub fn createStaticLibrary (builder : * Builder , name : []const u8 , root_src : ? FileSource ) * LibExeObjStep {
12781284 const self = builder .allocator .create (LibExeObjStep ) catch unreachable ;
1279- self .* = initExtraArgs (builder , name , root_src , Kind .Lib , false , builder . version ( 0 , 0 , 0 ) );
1285+ self .* = initExtraArgs (builder , name , root_src , Kind .Lib , false , null );
12801286 return self ;
12811287 }
12821288
12831289 pub fn createObject (builder : * Builder , name : []const u8 , root_src : ? FileSource ) * LibExeObjStep {
12841290 const self = builder .allocator .create (LibExeObjStep ) catch unreachable ;
1285- self .* = initExtraArgs (builder , name , root_src , Kind .Obj , false , builder . version ( 0 , 0 , 0 ) );
1291+ self .* = initExtraArgs (builder , name , root_src , Kind .Obj , false , null );
12861292 return self ;
12871293 }
12881294
12891295 pub fn createExecutable (builder : * Builder , name : []const u8 , root_src : ? FileSource , is_dynamic : bool ) * LibExeObjStep {
12901296 const self = builder .allocator .create (LibExeObjStep ) catch unreachable ;
1291- self .* = initExtraArgs (builder , name , root_src , Kind .Exe , is_dynamic , builder . version ( 0 , 0 , 0 ) );
1297+ self .* = initExtraArgs (builder , name , root_src , Kind .Exe , is_dynamic , null );
12921298 return self ;
12931299 }
12941300
12951301 pub fn createTest (builder : * Builder , name : []const u8 , root_src : FileSource ) * LibExeObjStep {
12961302 const self = builder .allocator .create (LibExeObjStep ) catch unreachable ;
1297- self .* = initExtraArgs (builder , name , root_src , Kind .Test , false , builder . version ( 0 , 0 , 0 ) );
1303+ self .* = initExtraArgs (builder , name , root_src , Kind .Test , false , null );
12981304 return self ;
12991305 }
13001306
@@ -1304,7 +1310,7 @@ pub const LibExeObjStep = struct {
13041310 root_src : ? FileSource ,
13051311 kind : Kind ,
13061312 is_dynamic : bool ,
1307- ver : Version ,
1313+ ver : ? Version ,
13081314 ) LibExeObjStep {
13091315 if (mem .indexOf (u8 , name , "/" ) != null or mem .indexOf (u8 , name , "\\ " ) != null ) {
13101316 panic ("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name." , .{name });
@@ -1375,17 +1381,17 @@ pub const LibExeObjStep = struct {
13751381 self .target .staticLibSuffix (),
13761382 });
13771383 self .out_lib_filename = self .out_filename ;
1378- } else {
1384+ } else if ( self . version ) | version | {
13791385 if (self .target .isDarwin ()) {
13801386 self .out_filename = self .builder .fmt ("lib{}.{d}.{d}.{d}.dylib" , .{
13811387 self .name ,
1382- self . version .major ,
1383- self . version .minor ,
1384- self . version .patch ,
1388+ version .major ,
1389+ version .minor ,
1390+ version .patch ,
13851391 });
13861392 self .major_only_filename = self .builder .fmt ("lib{}.{d}.dylib" , .{
13871393 self .name ,
1388- self . version .major ,
1394+ version .major ,
13891395 });
13901396 self .name_only_filename = self .builder .fmt ("lib{}.dylib" , .{self .name });
13911397 self .out_lib_filename = self .out_filename ;
@@ -1395,14 +1401,25 @@ pub const LibExeObjStep = struct {
13951401 } else {
13961402 self .out_filename = self .builder .fmt ("lib{}.so.{d}.{d}.{d}" , .{
13971403 self .name ,
1398- self . version .major ,
1399- self . version .minor ,
1400- self . version .patch ,
1404+ version .major ,
1405+ version .minor ,
1406+ version .patch ,
14011407 });
1402- self .major_only_filename = self .builder .fmt ("lib{}.so.{d}" , .{ self .name , self . version .major });
1408+ self .major_only_filename = self .builder .fmt ("lib{}.so.{d}" , .{ self .name , version .major });
14031409 self .name_only_filename = self .builder .fmt ("lib{}.so" , .{self .name });
14041410 self .out_lib_filename = self .out_filename ;
14051411 }
1412+ } else {
1413+ if (self .target .isDarwin ()) {
1414+ self .out_filename = self .builder .fmt ("lib{}.dylib" , .{self .name });
1415+ self .out_lib_filename = self .out_filename ;
1416+ } else if (self .target .isWindows ()) {
1417+ self .out_filename = self .builder .fmt ("{}.dll" , .{self .name });
1418+ self .out_lib_filename = self .builder .fmt ("{}.lib" , .{self .name });
1419+ } else {
1420+ self .out_filename = self .builder .fmt ("lib{}.so" , .{self .name });
1421+ self .out_lib_filename = self .out_filename ;
1422+ }
14061423 }
14071424 },
14081425 }
@@ -2037,14 +2054,16 @@ pub const LibExeObjStep = struct {
20372054 zig_args .append (self .name ) catch unreachable ;
20382055
20392056 if (self .kind == Kind .Lib and self .is_dynamic ) {
2040- zig_args .append ("--ver-major" ) catch unreachable ;
2041- zig_args .append (builder .fmt ("{}" , .{self .version .major })) catch unreachable ;
2057+ if (self .version ) | version | {
2058+ zig_args .append ("--ver-major" ) catch unreachable ;
2059+ zig_args .append (builder .fmt ("{}" , .{version .major })) catch unreachable ;
20422060
2043- zig_args .append ("--ver-minor" ) catch unreachable ;
2044- zig_args .append (builder .fmt ("{}" , .{self . version .minor })) catch unreachable ;
2061+ zig_args .append ("--ver-minor" ) catch unreachable ;
2062+ zig_args .append (builder .fmt ("{}" , .{version .minor })) catch unreachable ;
20452063
2046- zig_args .append ("--ver-patch" ) catch unreachable ;
2047- zig_args .append (builder .fmt ("{}" , .{self .version .patch })) catch unreachable ;
2064+ zig_args .append ("--ver-patch" ) catch unreachable ;
2065+ zig_args .append (builder .fmt ("{}" , .{version .patch })) catch unreachable ;
2066+ }
20482067 }
20492068 if (self .is_dynamic ) {
20502069 try zig_args .append ("-dynamic" );
@@ -2285,7 +2304,7 @@ pub const LibExeObjStep = struct {
22852304 }
22862305 }
22872306
2288- if (self .kind == Kind .Lib and self .is_dynamic and self .target .wantSharedLibSymLinks ()) {
2307+ if (self .kind == Kind .Lib and self .is_dynamic and self .version != null and self . target .wantSharedLibSymLinks ()) {
22892308 try doAtomicSymLinks (builder .allocator , self .getOutputPath (), self .major_only_filename , self .name_only_filename );
22902309 }
22912310 }
@@ -2329,8 +2348,10 @@ pub const InstallArtifactStep = struct {
23292348
23302349 builder .pushInstalledFile (self .dest_dir , artifact .out_filename );
23312350 if (self .artifact .isDynamicLibrary ()) {
2332- builder .pushInstalledFile (.Lib , artifact .major_only_filename );
2333- builder .pushInstalledFile (.Lib , artifact .name_only_filename );
2351+ if (self .artifact .version != null ) {
2352+ builder .pushInstalledFile (.Lib , artifact .major_only_filename );
2353+ builder .pushInstalledFile (.Lib , artifact .name_only_filename );
2354+ }
23342355 if (self .artifact .target .isWindows ()) {
23352356 builder .pushInstalledFile (.Lib , artifact .out_lib_filename );
23362357 }
@@ -2350,7 +2371,7 @@ pub const InstallArtifactStep = struct {
23502371
23512372 const full_dest_path = builder .getInstallPath (self .dest_dir , self .artifact .out_filename );
23522373 try builder .updateFile (self .artifact .getOutputPath (), full_dest_path );
2353- if (self .artifact .isDynamicLibrary () and self .artifact .target .wantSharedLibSymLinks ()) {
2374+ if (self .artifact .isDynamicLibrary () and self .artifact .version != null and self . artifact . target .wantSharedLibSymLinks ()) {
23542375 try doAtomicSymLinks (builder .allocator , full_dest_path , self .artifact .major_only_filename , self .artifact .name_only_filename );
23552376 }
23562377 if (self .pdb_dir ) | pdb_dir | {
0 commit comments