Skip to content

Commit

Permalink
[msbuild] Provide the correct value for the operating system for tvOS…
Browse files Browse the repository at this point in the history
… and watchOS to a few tasks. Fixes xamarin#6200. (xamarin#7226)

The problem with xamarin#6200 was that we'd pass -mios-version-min=x.y to the metal
tool even for tvOS apps. This fixes it so that now pass -mtvos-version-min.

Fixes xamarin#6200.
  • Loading branch information
rolfbjarne committed Feb 26, 2020
1 parent dd83fbe commit 0220151
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 28 deletions.
3 changes: 0 additions & 3 deletions msbuild/Xamarin.Mac.Tasks/Tasks/CompileSceneKitAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ namespace Xamarin.Mac.Tasks
{
public class CompileSceneKitAssets : CompileSceneKitAssetsTaskBase
{
protected override string OperatingSystem {
get { return "osx"; }
}
}
}
4 changes: 0 additions & 4 deletions msbuild/Xamarin.Mac.Tasks/Tasks/Metal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ namespace Xamarin.Mac.Tasks
{
public class Metal : MetalTaskBase
{
protected override string OperatingSystem {
get { return "macosx"; }
}

#if !MTOUCH_TESTS
protected override string MinimumDeploymentTargetKey {
get { return ManifestKeys.LSMinimumSystemVersion; }
Expand Down
3 changes: 0 additions & 3 deletions msbuild/Xamarin.Mac.Tasks/Tasks/ScnTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ namespace Xamarin.Mac.Tasks
{
public class ScnTool : ScnToolTaskBase
{
protected override string OperatingSystem {
get { return "osx"; }
}
}
}
3 changes: 3 additions & 0 deletions msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
IntermediateOutputPath="$(IntermediateOutputPath)"
AppManifest="$(_AppManifest)"
ProjectDir="$(MSBuildProjectDirectory)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
ResourcePrefix="$(XamMacResourcePrefix)"
SdkDevPath="$(_SdkDevPath)"
SdkRoot="$(_SdkRoot)"
Expand Down Expand Up @@ -588,6 +589,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
SdkRoot="$(_SdkRoot)"
SdkDevPath="$(_SdkDevPath)"
SdkVersion="$(MacOSXSdkVersion)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
IntermediateOutputPath="$(IntermediateOutputPath)"
InputScene="%(_ColladaAssetWithLogicalName.Identity)"
OutputScene="$(IntermediateOutputPath)%(_ColladaAssetWithLogicalName.LogicalName)">
Expand Down Expand Up @@ -675,6 +677,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
ToolPath="$(CopySceneKitAssetsPath)"
SceneKitAssets="@(SceneKitAsset)"
IntermediateOutputPath="$(IntermediateOutputPath)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
ProjectDir="$(MSBuildProjectDirectory)"
ResourcePrefix="$(XamMacResourcePrefix)"
SdkPlatform="MacOSX"
Expand Down
17 changes: 17 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks.Core/PlatformFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,22 @@ public static PlatformFramework GetFramework (string targetFrameworkIdentifier)
throw new InvalidOperationException ("Unknown TargetFrameworkIdentifier: " + targetFrameworkIdentifier);
}
}

public static string GetOperatingSystem (string targetFrameworkIdentifier)
{
var framework = PlatformFrameworkHelper.GetFramework (targetFrameworkIdentifier);
switch (framework) {
case PlatformFramework.WatchOS:
return "watchos";
case PlatformFramework.TVOS:
return "tvos";
case PlatformFramework.MacOS:
return "osx";
case PlatformFramework.iOS:
return "ios";
default:
throw new InvalidOperationException (string.Format ("Unknown target framework {0} for target framework identifier {2}.", framework, targetFrameworkIdentifier));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public abstract class CompileSceneKitAssetsTaskBase : Task
[Required]
public string SdkVersion { get; set; }

[Required]
public string TargetFrameworkIdentifier { get; set; }

public string ToolExe {
get { return toolExe ?? ToolName; }
set { toolExe = value; }
Expand All @@ -67,8 +70,10 @@ static string ToolName {
get { return "copySceneKitAssets"; }
}

protected abstract string OperatingSystem {
get;
protected virtual string OperatingSystem {
get {
return PlatformFrameworkHelper.GetOperatingSystem (TargetFrameworkIdentifier);
}
}

string DeveloperRootBinDir {
Expand Down
21 changes: 19 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks.Core/Tasks/MetalTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public abstract class MetalTaskBase : ToolTask
[Required]
public ITaskItem SourceFile { get; set; }

[Required]
public string TargetFrameworkIdentifier { get; set; }

#endregion

[Output]
Expand All @@ -48,8 +51,22 @@ protected abstract string MinimumDeploymentTargetKey {
get;
}

protected abstract string OperatingSystem {
get;
protected virtual string OperatingSystem {
get {
switch (PlatformFrameworkHelper.GetFramework (TargetFrameworkIdentifier)) {
case PlatformFramework.WatchOS:
return "watchos";
case PlatformFramework.TVOS:
return "tvos";
case PlatformFramework.MacOS:
return "macosx";
case PlatformFramework.iOS:
return "ios";
default:
Log.LogError ($"Unknown target framework identifier: {TargetFrameworkIdentifier}.");
return string.Empty;
}
}
}

protected abstract string DevicePlatformBinDir {
Expand Down
9 changes: 7 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks.Core/Tasks/ScnToolTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ public string SdkDevPath {
}
}

[Required]
public string TargetFrameworkIdentifier { get; set; }

#endregion

string DevicePlatformBinDir {
get { return Path.Combine (SdkDevPath, "usr", "bin"); }
}

protected abstract string OperatingSystem {
get;
protected virtual string OperatingSystem {
get {
return PlatformFrameworkHelper.GetOperatingSystem (TargetFrameworkIdentifier);
}
}

protected override string ToolName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
{
public abstract class CompileSceneKitAssetsTaskBase : Xamarin.MacDev.Tasks.CompileSceneKitAssetsTaskBase
{
protected override string OperatingSystem {
get { return "ios"; }
}
}
}
4 changes: 0 additions & 4 deletions msbuild/Xamarin.iOS.Tasks.Core/Tasks/MetalTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ namespace Xamarin.iOS.Tasks
{
public abstract class MetalTaskBase : Xamarin.MacDev.Tasks.MetalTaskBase
{
protected override string OperatingSystem {
get { return "ios"; }
}

protected override string MinimumDeploymentTargetKey {
get { return ManifestKeys.MinimumOSVersion; }
}
Expand Down
3 changes: 0 additions & 3 deletions msbuild/Xamarin.iOS.Tasks.Core/Tasks/ScnToolTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
{
public abstract class ScnToolTaskBase : Xamarin.MacDev.Tasks.ScnToolTaskBase
{
protected override string OperatingSystem {
get { return "ios"; }
}
}
}
3 changes: 3 additions & 0 deletions msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
AppManifest="$(_AppManifest)"
ProjectDir="$(MSBuildProjectDirectory)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
ResourcePrefix="$(IPhoneResourcePrefix)"
SdkDevPath="$(_SdkDevPath)"
SdkRoot="$(_SdkRoot)"
Expand Down Expand Up @@ -1220,6 +1221,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
SdkRoot="$(_SdkRoot)"
SdkDevPath="$(_SdkDevPath)"
SdkVersion="$(MtouchSdkVersion)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
InputScene="%(_ColladaAssetWithLogicalName.Identity)"
OutputScene="$(DeviceSpecificIntermediateOutputPath)%(_ColladaAssetWithLogicalName.LogicalName)">
Expand Down Expand Up @@ -1333,6 +1335,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
ToolPath="$(CopySceneKitAssetsPath)"
SceneKitAssets="@(SceneKitAsset)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
ProjectDir="$(MSBuildProjectDirectory)"
ResourcePrefix="$(IPhoneResourcePrefix)"
IsWatchApp="$(IsWatchApp)"
Expand Down
7 changes: 5 additions & 2 deletions tests/mtouch/ToolTasksBinPathTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ namespace Xamarin.MacDev.Tasks {

public abstract class MetalTaskBase {

protected abstract string OperatingSystem {
get;
protected virtual string OperatingSystem {
get {
throw new NotImplementedException ();
}
}

protected abstract string DevicePlatformBinDir {
Expand Down Expand Up @@ -82,6 +84,7 @@ public void CheckToolBinDir (string taskName, string binDirToCheck)
RedirectStandardError = true,
};
psi.EnvironmentVariables.Add ("DEVELOPER_DIR", Configuration.xcode_root);
psi.EnvironmentVariables.Remove ("XCODE_DEVELOPER_DIR_PATH"); // VSfM sets XCODE_DEVELOPER_DIR_PATH, which confuses the command-line tools if it doesn't match xcode-select, so just unset it.
var proc = Process.Start (psi);

string output = proc.StandardOutput.ReadToEnd ();
Expand Down

0 comments on commit 0220151

Please sign in to comment.