Skip to content

Commit

Permalink
[Xamarin.MacDev] Fix computing DTSDKBuild. Fixes #xamarin/xamarin-mac…
Browse files Browse the repository at this point in the history
…ios@19733. (#116)

We were accidentally getting the ProductBuildVersion value (which is used for
DTSDKBuild) from the system, not from the SDK used during the build.

This happened because we were trying to Path.Combine two rooted paths - in
which case Path.Combine returns the second path, without combining anything.

The fix is to compute the path of the plist where the ProductBuildVersion
value is located correctly.

Fixing the Path.Combine issue also revealed that the first path passed to
Path.Combine was wrong, so that got fixed too.

And finally make sure we don't Path.Combine two rooted paths anywhere else -
in all other cases we're supposed to just use the second path without
prepending the first, so just remove the Path.Combine call completely in those
cases.

Fixes xamarin/xamarin-macios#19733.
  • Loading branch information
rolfbjarne authored Jan 3, 2024
1 parent b454d45 commit 3a89218
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Xamarin.MacDev/AppleSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ public AppleDTSettings GetDTSettings ()

var dict = PDictionary.FromFile (Path.Combine (DevicePlatform, "Info.plist"));
var infos = dict.Get<PDictionary> ("AdditionalInfo");
var systemVersionPlist = Path.Combine (DeveloperRoot, SYSTEM_VERSION_PLIST);

return (dtSettings = new AppleDTSettings {
DTPlatformVersion = infos.Get<PString> ("DTPlatformVersion").Value,
DTPlatformBuild = GrabRootString (Path.Combine (DevicePlatform, "version.plist"), "ProductBuildVersion"),
DTXcodeBuild = GrabRootString (VersionPlist, "ProductBuildVersion"),
BuildMachineOSBuild = GrabRootString (systemVersionPlist, "ProductBuildVersion"),
BuildMachineOSBuild = GrabRootString (SYSTEM_VERSION_PLIST, "ProductBuildVersion"),
});
}

Expand Down
8 changes: 5 additions & 3 deletions Xamarin.MacDev/MacOSXSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ AppleDTSdkSettings LoadSdkSettings (IAppleSdkVersion sdk)
else
settings.DTCompiler = gcc.Value;

settings.DTSDKBuild = GrabRootString (Path.Combine (DeveloperRoot, SYSTEM_VERSION_PLIST), "ProductBuildVersion");
var sdkPath = GetSdkPath (sdk.ToString ());
// Do not do 'Path.Combine (sdkPath, SYSTEM_VERSION_PLIST)', because SYSTEM_VERSION_PLIST starts with a slash,
// and thus Path.Combine wouldn't combine, just return SYSTEM_VERSION_PLIST.
settings.DTSDKBuild = GrabRootString (sdkPath + SYSTEM_VERSION_PLIST, "ProductBuildVersion");

return settings;
}
Expand All @@ -278,13 +281,12 @@ DTSettings GetSettings ()

var dict = PDictionary.FromFile (Path.Combine (DesktopPlatform, "Info.plist"));
var infos = dict.Get<PDictionary> ("AdditionalInfo");
var systemVersionPlist = Path.Combine (DeveloperRoot, SYSTEM_VERSION_PLIST);

return (dtSettings = new DTSettings {
DTPlatformVersion = infos.Get<PString> ("DTPlatformVersion").Value,
DTPlatformBuild = GrabRootString (Path.Combine (DesktopPlatform, "version.plist"), "ProductBuildVersion") ?? GrabRootString (VersionPlist, "ProductBuildVersion"),
DTXcodeBuild = GrabRootString (VersionPlist, "ProductBuildVersion"),
BuildMachineOSBuild = GrabRootString (systemVersionPlist, "ProductBuildVersion"),
BuildMachineOSBuild = GrabRootString (SYSTEM_VERSION_PLIST, "ProductBuildVersion"),
});
}

Expand Down

0 comments on commit 3a89218

Please sign in to comment.