| ... | @@ -269,7 +269,7 @@ pub fn writeVersionMinLC(platform: Platform, sdk_version: ?std.SemanticVersion, | ... | @@ -269,7 +269,7 @@ pub fn writeVersionMinLC(platform: Platform, sdk_version: ?std.SemanticVersion, |
| 269 | try lc_writer.writeAll(mem.asBytes(&macho.version_min_command{ | 269 | try lc_writer.writeAll(mem.asBytes(&macho.version_min_command{ |
| 270 | .cmd = cmd, | 270 | .cmd = cmd, |
| 271 | .version = platform.toAppleVersion(), | 271 | .version = platform.toAppleVersion(), |
| 272 | .sdk = if (sdk_version) |ver| Platform.semanticVersionToAppleVersion(ver) else platform.toAppleVersion(), | 272 | .sdk = if (sdk_version) |ver| semanticVersionToAppleVersion(ver) else platform.toAppleVersion(), |
| 273 | })); | 273 | })); |
| 274 | } | 274 | } |
| 275 | | 275 | |
| ... | @@ -279,7 +279,7 @@ pub fn writeBuildVersionLC(platform: Platform, sdk_version: ?std.SemanticVersion | ... | @@ -279,7 +279,7 @@ pub fn writeBuildVersionLC(platform: Platform, sdk_version: ?std.SemanticVersion |
| 279 | .cmdsize = cmdsize, | 279 | .cmdsize = cmdsize, |
| 280 | .platform = platform.toApplePlatform(), | 280 | .platform = platform.toApplePlatform(), |
| 281 | .minos = platform.toAppleVersion(), | 281 | .minos = platform.toAppleVersion(), |
| 282 | .sdk = if (sdk_version) |ver| Platform.semanticVersionToAppleVersion(ver) else platform.toAppleVersion(), | 282 | .sdk = if (sdk_version) |ver| semanticVersionToAppleVersion(ver) else platform.toAppleVersion(), |
| 283 | .ntools = 1, | 283 | .ntools = 1, |
| 284 | }); | 284 | }); |
| 285 | try lc_writer.writeAll(mem.asBytes(&macho.build_tool_version{ | 285 | try lc_writer.writeAll(mem.asBytes(&macho.build_tool_version{ |
| ... | @@ -383,21 +383,6 @@ pub const Platform = struct { | ... | @@ -383,21 +383,6 @@ pub const Platform = struct { |
| 383 | } | 383 | } |
| 384 | return false; | 384 | return false; |
| 385 | } | 385 | } |
| 386 | | | |
| 387 | pub inline fn semanticVersionToAppleVersion(version: std.SemanticVersion) u32 { | | |
| 388 | const major = version.major; | | |
| 389 | const minor = version.minor; | | |
| 390 | const patch = version.patch; | | |
| 391 | return (@as(u32, @intCast(major)) << 16) | (@as(u32, @intCast(minor)) << 8) | @as(u32, @intCast(patch)); | | |
| 392 | } | | |
| 393 | | | |
| 394 | inline fn appleVersionToSemanticVersion(version: u32) std.SemanticVersion { | | |
| 395 | return .{ | | |
| 396 | .major = @as(u16, @truncate(version >> 16)), | | |
| 397 | .minor = @as(u8, @truncate(version >> 8)), | | |
| 398 | .patch = @as(u8, @truncate(version)), | | |
| 399 | }; | | |
| 400 | } | | |
| 401 | }; | 386 | }; |
| 402 | | 387 | |
| 403 | const SupportedPlatforms = struct { | 388 | const SupportedPlatforms = struct { |
| ... | @@ -419,6 +404,21 @@ const supported_platforms = [_]SupportedPlatforms{ | ... | @@ -419,6 +404,21 @@ const supported_platforms = [_]SupportedPlatforms{ |
| 419 | .{ .watchos, .simulator, 0x60000, 0x20000, null }, | 404 | .{ .watchos, .simulator, 0x60000, 0x20000, null }, |
| 420 | }; | 405 | }; |
| 421 | | 406 | |
| | 407 | pub inline fn semanticVersionToAppleVersion(version: std.SemanticVersion) u32 { |
| | 408 | const major = version.major; |
| | 409 | const minor = version.minor; |
| | 410 | const patch = version.patch; |
| | 411 | return (@as(u32, @intCast(major)) << 16) | (@as(u32, @intCast(minor)) << 8) | @as(u32, @intCast(patch)); |
| | 412 | } |
| | 413 | |
| | 414 | inline fn appleVersionToSemanticVersion(version: u32) std.SemanticVersion { |
| | 415 | return .{ |
| | 416 | .major = @as(u16, @truncate(version >> 16)), |
| | 417 | .minor = @as(u8, @truncate(version >> 8)), |
| | 418 | .patch = @as(u8, @truncate(version)), |
| | 419 | }; |
| | 420 | } |
| | 421 | |
| 422 | pub fn inferSdkVersionFromSdkPath(path: []const u8) ?std.SemanticVersion { | 422 | pub fn inferSdkVersionFromSdkPath(path: []const u8) ?std.SemanticVersion { |
| 423 | const stem = std.fs.path.stem(path); | 423 | const stem = std.fs.path.stem(path); |
| 424 | const start = for (stem, 0..) |c, i| { | 424 | const start = for (stem, 0..) |c, i| { |