Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ endif

# Tell both Xcode and our build logic which Xcode we're using.
export DEVELOPER_DIR=$(XCODE_DEVELOPER_ROOT)
export MD_APPLE_SDK_ROOT=$(abspath $(XCODE_DEVELOPER_ROOT)/../..)

# We don't need to be told there are workload updates
export DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE=true
Expand Down
10 changes: 8 additions & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@
</Target>

<Target Name="_CopyDirectoriesToBundle"
DependsOnTargets="_CollectDecompressedPlugins;_ComputeFrameworkFilesToPublish;_CollectDecompressedXpcServices;_CreateStampLocationForCopyDirectoriesToBundle"
DependsOnTargets="_CollectDecompressedPlugins;_ComputeFrameworkFilesToPublish;_CollectDecompressedXpcServices;_CreateStampLocationForCopyDirectoriesToBundle;_DetectSdkLocations"
Inputs="@(_DirectoriesToPublish)"
Outputs="@(_DirectoriesToPublish -> '%(StampLocation)')"
>
Expand All @@ -967,6 +967,7 @@
Source="%(_DirectoriesToPublish.SourceDirectory)"
Destination="%(_DirectoriesToPublish.TargetDirectory)"
TouchDestinationFiles="true"
SdkDevPath="$(_SdkDevPath)"
StampFile="%(_DirectoriesToPublish.StampLocation)"
CreateOutputFiles="false"
/>
Expand Down Expand Up @@ -1274,7 +1275,7 @@
<Warning Condition="'$(GenerateRuntimeConfigurationFiles)' != 'true'" Text="Some features may not work correctly, because the generation of the runtime configure file (*.runtimeconfig.json) has been disabled." />
</Target>

<Target Name="_FindAotCompiler" DependsOnTargets="_ComputeVariables">
<Target Name="_FindAotCompiler" DependsOnTargets="_ComputeVariables;_DetectSdkLocations">
<PropertyGroup>
<_XamarinAOTCompilerCachePath>$(DeviceSpecificIntermediateOutputPath)aot-compiler-path-$(NETCoreSdkVersion).txt</_XamarinAOTCompilerCachePath>
</PropertyGroup>
Expand All @@ -1293,6 +1294,7 @@
KeepTemporaryOutput="$(FindAotCompilerKeepKeepTemporaryOutput)"
MonoAotCrossCompiler="@(MonoAotCrossCompiler)"
RuntimeIdentifier="$(RuntimeIdentifier)"
SdkDevPath="$(_SdkDevPath)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
<Output TaskParameter="AotCompiler" PropertyName="_XamarinAOTCompiler" />
Expand Down Expand Up @@ -1972,6 +1974,7 @@
_DetectSigningIdentity;
_PrepareResourceRules;
_AddDebugSymbolsToBundle;
_DetectSdkLocations;
</_ComputePublishLocationDependsOn>
</PropertyGroup>

Expand Down Expand Up @@ -2203,6 +2206,7 @@
FrameworksDirectory="$(_AppFrameworksRelativePath)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
NativeReferences="@(_NativeReferencesToResolve)"
SdkDevPath="$(_SdkDevPath)"
SdkIsSimulator="$(_SdkIsSimulator)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
Expand Down Expand Up @@ -2264,6 +2268,7 @@
Condition="'$(IsMacEnabled)' == 'true'"
ZipFilePath="%(_CompressedPlugIns.Identity)"
ExtractionPath="%(_CompressedPlugIns.ExtractionPath)"
SdkDevPath="$(_SdkDevPath)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Unzip>
Expand Down Expand Up @@ -2307,6 +2312,7 @@
CopyToWindows="true"
ZipFilePath="%(_CompressedXpcServices.Identity)"
ExtractionPath="%(_CompressedXpcServices.ExtractionPath)"
SdkDevPath="$(_SdkDevPath)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Unzip>
Expand Down
24 changes: 24 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1629,4 +1629,28 @@
<data name="E7163" xml:space="preserve">
<value>Unable to copy the inputs to this task to the remote build server for unknown reasons. The build log may have more information.</value>
</data>

<data name="E7164" xml:space="preserve">
<value>The task '{0}' is trying to call an external process, but a path to Xcode has not been provided. Please file an issue at https://github.com/dotnet/macios/issues/new/choose.</value>
</data>

<data name="W7165" xml:space="preserve">
<value>The environment variable '{0}' is deprecated, and will be ignored in .NET 11+. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="W7166" xml:space="preserve">
<value>The environment variable '{0}' is deprecated, and will be ignored. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="W7167" xml:space="preserve">
<value>The settings file '{0}' is deprecated, and will be ignored in .NET 11+. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="W7168" xml:space="preserve">
<value>The settings file '{0}' is deprecated, and will be ignored. Please set use the 'DEVELOPER_DIR' environment variable or the 'XcodeLocation' MSBuild property to choose which Xcode to use.</value>
</data>

<data name="E7169" xml:space="preserve">
<value>The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose.</value>
</data>
</root>
35 changes: 21 additions & 14 deletions msbuild/Xamarin.MacDev.Tasks/Decompress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ static string CanonicalizeZipEntryPath (string path)
/// <param name="cancellationToken">The cancellation token (if any=</param>
/// <param name="decompressedResource">The location on disk to the extracted resource</param>
/// <returns>True if successfully decompressed, false otherwise.</returns>
public static bool TryDecompress (TaskLoggingHelper log, string zip, string resource, string decompressionDir, List<string> createdFiles, CancellationToken? cancellationToken, [NotNullWhen (true)] out string? decompressedResource)
public static bool TryDecompress (XamarinTask task, string zip, string resource, string decompressionDir, List<string> createdFiles, CancellationToken? cancellationToken, [NotNullWhen (true)] out string? decompressedResource)
{
var log = task.Log;

decompressedResource = Path.Combine (decompressionDir, resource);

var stampFile = decompressedResource.TrimEnd ('\\', '/') + ".stamp";
Expand All @@ -118,11 +120,11 @@ public static bool TryDecompress (TaskLoggingHelper log, string zip, string reso

bool rv;
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
rv = TryDecompressUsingSystemIOCompression (log, zip, resource, decompressionDir, cancellationToken);
rv = TryDecompressUsingSystemIOCompression (task, zip, resource, decompressionDir, cancellationToken);
} else if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("XAMARIN_USE_SYSTEM_IO_COMPRESSION"))) {
rv = TryDecompressUsingSystemIOCompression (log, zip, resource, decompressionDir, cancellationToken);
rv = TryDecompressUsingSystemIOCompression (task, zip, resource, decompressionDir, cancellationToken);
} else {
rv = TryDecompressUsingUnzip (log, zip, resource, decompressionDir, cancellationToken);
rv = TryDecompressUsingUnzip (task, zip, resource, decompressionDir, cancellationToken);
}

if (rv) {
Expand All @@ -145,8 +147,9 @@ public static bool TryDecompress (TaskLoggingHelper log, string zip, string reso
// The dir separator character in zip files is always "/", even on Windows
const char zipDirectorySeparator = '/';

static bool TryDecompressUsingUnzip (TaskLoggingHelper log, string zip, string resource, string decompressionDir, CancellationToken? cancellationToken)
static bool TryDecompressUsingUnzip (XamarinTask task, string zip, string resource, string decompressionDir, CancellationToken? cancellationToken)
{
var log = task.Log;
Directory.CreateDirectory (decompressionDir);
var args = new List<string> {
"-u", "-o",
Expand Down Expand Up @@ -176,12 +179,13 @@ static bool TryDecompressUsingUnzip (TaskLoggingHelper log, string zip, string r
args.Add (zipPattern);
}

var rv = XamarinTask.ExecuteAsync (log, "unzip", args, cancellationToken: cancellationToken).Result;
var rv = task.ExecuteAsync ("unzip", args, cancellationToken: cancellationToken).Result;
return rv.ExitCode == 0;
}

static bool TryDecompressUsingSystemIOCompression (TaskLoggingHelper log, string zip, string resource, string decompressionDir, CancellationToken? cancellationToken)
static bool TryDecompressUsingSystemIOCompression (XamarinTask task, string zip, string resource, string decompressionDir, CancellationToken? cancellationToken)
{
var log = task.Log;
var rv = true;

// canonicalize input
Expand Down Expand Up @@ -270,8 +274,9 @@ static bool TryDecompressUsingSystemIOCompression (TaskLoggingHelper log, string
/// testing the System.IO.Compression implementation locally (with the caveat that if the resources
/// to compress has symlinks, it may not work).
/// </remarks>
public static bool TryCompress (TaskLoggingHelper log, string zip, IEnumerable<string> resources, bool overwrite, string workingDirectory, bool maxCompression = false)
public static bool TryCompress (XamarinTask task, string zip, IEnumerable<string> resources, bool overwrite, string workingDirectory, bool maxCompression = false)
{
var log = task.Log;
if (overwrite) {
if (File.Exists (zip)) {
log.LogMessage (MessageImportance.Low, "Replacing zip file {0} with {1}", zip, string.Join (", ", resources));
Expand All @@ -293,19 +298,20 @@ public static bool TryCompress (TaskLoggingHelper log, string zip, IEnumerable<s

bool rv;
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
rv = TryCompressUsingSystemIOCompression (log, zip, resources, workingDirectory, maxCompression);
rv = TryCompressUsingSystemIOCompression (task, zip, resources, workingDirectory, maxCompression);
} else if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("XAMARIN_USE_SYSTEM_IO_COMPRESSION"))) {
rv = TryCompressUsingSystemIOCompression (log, zip, resources, workingDirectory, maxCompression);
rv = TryCompressUsingSystemIOCompression (task, zip, resources, workingDirectory, maxCompression);
} else {
rv = TryCompressUsingZip (log, zip, resources, workingDirectory, maxCompression);
rv = TryCompressUsingZip (task, zip, resources, workingDirectory, maxCompression);
}

return rv;
}

// Will always add to an existing zip file (not replace)
static bool TryCompressUsingZip (TaskLoggingHelper log, string zip, IEnumerable<string> resources, string workingDirectory, bool maxCompression)
static bool TryCompressUsingZip (XamarinTask task, string zip, IEnumerable<string> resources, string workingDirectory, bool maxCompression)
{
var log = task.Log;
var zipArguments = new List<string> ();
if (maxCompression)
zipArguments.Add ("-9");
Expand All @@ -318,7 +324,7 @@ static bool TryCompressUsingZip (TaskLoggingHelper log, string zip, IEnumerable<
var relativePath = PathUtils.AbsoluteToRelative (workingDirectory, fullPath);
zipArguments.Add (relativePath);
}
var rv = XamarinTask.ExecuteAsync (log, "zip", zipArguments, workingDirectory: workingDirectory).Result;
var rv = task.ExecuteAsync ("zip", zipArguments, workingDirectory: workingDirectory).Result;
log.LogMessage (MessageImportance.Low, "Updated {0} with {1}: {2}", zip, string.Join (", ", resources), rv.ExitCode == 0);
return rv.ExitCode == 0;
}
Expand All @@ -330,8 +336,9 @@ static bool TryCompressUsingZip (TaskLoggingHelper log, string zip, IEnumerable<
#endif

// Will always add to an existing zip file (not replace)
static bool TryCompressUsingSystemIOCompression (TaskLoggingHelper log, string zip, IEnumerable<string> resources, string workingDirectory, bool maxCompression)
static bool TryCompressUsingSystemIOCompression (XamarinTask task, string zip, IEnumerable<string> resources, string workingDirectory, bool maxCompression)
{
var log = task.Log;
var rv = true;

workingDirectory = Path.GetFullPath (workingDirectory);
Expand Down
41 changes: 6 additions & 35 deletions msbuild/Xamarin.MacDev.Tasks/Sdks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,24 @@

namespace Xamarin.MacDev {
public static class Sdks {
public static AppleIPhoneSdk IOS { get; private set; }
public static MacOSXSdk MacOS { get; private set; }
public static AppleTVOSSdk TVOS { get; private set; }

static Sdks ()
{
IOS = new AppleIPhoneSdk (AppleSdkSettings.DeveloperRoot, AppleSdkSettings.DeveloperRootVersionPlist);
TVOS = new AppleTVOSSdk (AppleSdkSettings.DeveloperRoot, AppleSdkSettings.DeveloperRootVersionPlist);
MacOS = new MacOSXSdk (AppleSdkSettings.DeveloperRoot, AppleSdkSettings.DeveloperRootVersionPlist);
}

public static AppleSdk GetSdk (ApplePlatform framework)
public static IAppleSdk GetAppleSdk (ApplePlatform framework, XcodeLocator appleSdk)
{
switch (framework) {
case ApplePlatform.iOS:
return IOS;
return new AppleIPhoneSdk (appleSdk.DeveloperRoot, appleSdk.DeveloperRootVersionPlist);
case ApplePlatform.TVOS:
return TVOS;
default:
throw new InvalidOperationException (string.Format (MSBStrings.InvalidFramework, framework));
}
}

public static AppleSdk GetSdk (string targetFrameworkMoniker)
{
return GetSdk (PlatformFrameworkHelper.GetFramework (targetFrameworkMoniker));
}

public static IAppleSdk GetAppleSdk (ApplePlatform framework)
{
switch (framework) {
case ApplePlatform.iOS:
return IOS;
case ApplePlatform.TVOS:
return TVOS;
return new AppleTVOSSdk (appleSdk.DeveloperRoot, appleSdk.DeveloperRootVersionPlist);
case ApplePlatform.MacCatalyst:
case ApplePlatform.MacOSX:
return MacOS;
return new MacOSXSdk (appleSdk.DeveloperRoot, appleSdk.DeveloperRootVersionPlist);
default:
throw new InvalidOperationException (string.Format (MSBStrings.InvalidFramework, framework));
}
}

public static IAppleSdk GetAppleSdk (string targetFrameworkMoniker)
public static IAppleSdk GetAppleSdk (string targetFrameworkMoniker, XcodeLocator appleSdk)
{
return GetAppleSdk (PlatformFrameworkHelper.GetFramework (targetFrameworkMoniker));
return GetAppleSdk (PlatformFrameworkHelper.GetFramework (targetFrameworkMoniker), appleSdk);
}

}
}
4 changes: 0 additions & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ACTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public class ACTool : XcodeCompilerToolTask, ICancelableTask {
HashSet<string> brandAssetsInAssets = new (); // tvOS
HashSet<string> imageStacksInAssets = new (); // tvOS

protected override string DefaultBinDir {
get { return DeveloperRootBinDir; }
}

protected override string ToolName {
get { return "actool"; }
}
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public class AOTCompile : XamarinParallelTask, ITaskCallback, ICancelableTask {
[Required]
public string OutputDirectory { get; set; } = string.Empty;

[Required]
public string SdkDevPath { get; set; } = string.Empty;

#region Output
[Output]
public ITaskItem []? AssemblyFiles { get; set; }
Expand Down Expand Up @@ -341,7 +338,7 @@ public override bool Execute ()
environment [item.ItemSpec] = item.GetMetadata ("Value");

ForEach (listOfArguments, (arg) => {
ExecuteAsync (AOTCompilerPath, arg.Arguments, environment: environment, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
ExecuteAsync (AOTCompilerPath, arg.Arguments, environment: environment, showErrorIfFailure: false /* we show our own error below */)
.ContinueWith ((v) => {
if (v.Result.ExitCode != 0)
Log.LogError (MSBStrings.E7118 /* Failed to AOT compile {0}, the AOT compiler exited with code {1} */, Path.GetFileName (arg.Input), v.Result.ExitCode);
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/AlTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public abstract class ALToolTaskBase : XamarinTask, ICancelableTask {
[Required]
public string FilePath { get; set; } = string.Empty;

[Required]
public string SdkDevPath { get; set; } = string.Empty;

protected abstract string ALToolAction { get; }

public override bool Execute ()
Expand All @@ -44,7 +41,7 @@ public override bool Execute ()
return false;

cancellationTokenSource = new CancellationTokenSource ();
var rv = ExecuteAsync (Log, executable, args, sdkDevPath: SdkDevPath, cancellationToken: cancellationTokenSource.Token).Result;
var rv = ExecuteAsync (executable, args, cancellationToken: cancellationTokenSource.Token).Result;
LogErrorsFromOutput (rv.StandardOutput?.ToString ());
return !Log.HasLoggedErrors;
}
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/BGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public override bool Execute ()
return false;

cancellationTokenSource = new CancellationTokenSource ();
ExecuteAsync (Log, executable, args, environment: env, cancellationToken: cancellationTokenSource.Token).Wait ();
ExecuteAsync (executable, args, environment: env, cancellationToken: cancellationTokenSource.Token).Wait ();
return !Log.HasLoggedErrors;
}

Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void Sign (SignInfo info)
var environment = new Dictionary<string, string?> () {
{ "CODESIGN_ALLOCATE", GetCodesignAllocate (item) },
};
var rv = ExecuteAsync (fileName, arguments, null, environment, mergeOutput: false).Result;
var rv = ExecuteAsync (fileName, arguments, environment, mergeOutput: false).Result;
var exitCode = rv.ExitCode;
var messages = rv.StandardOutput?.ToString () ?? string.Empty;

Expand Down
Loading
Loading