Skip to content
Merged
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
4 changes: 4 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1619,4 +1619,8 @@
<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="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>
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, sdkDevPath: GetSdkDevPath (), 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 (Log, executable, args, sdkDevPath: GetSdkDevPath (), cancellationToken: cancellationTokenSource.Token).Result;
LogErrorsFromOutput (rv.Output.MergedOutput);
return !Log.HasLoggedErrors;
}
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileNativeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public class CompileNativeCode : XamarinTask, ICancelableTask, ITaskCallback {
[Required]
public string MinimumOSVersion { get; set; } = "";

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

[Required]
public string SdkRoot { get; set; } = "";

Expand Down Expand Up @@ -142,7 +139,7 @@ public override bool Execute ()
arguments.Add ("-c");
arguments.Add (src);

processes [i] = ExecuteAsync ("xcrun", arguments, sdkDevPath: SdkDevPath);
processes [i] = ExecuteAsync ("xcrun", arguments, sdkDevPath: GetSdkDevPath ());
}

System.Threading.Tasks.Task.WaitAll (processes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public class CompileSceneKitAssets : XamarinTask, ICancelableTask, IHasProjectDi
[Required]
public ITaskItem [] SceneKitAssets { get; set; } = Array.Empty<ITaskItem> ();

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

[Required]
public string SdkPlatform { get; set; } = "";

Expand Down Expand Up @@ -87,7 +84,7 @@ Task CopySceneKitAssets (string scnassets, string output, string intermediate)

var executable = GetExecutable (args, ToolName, CopySceneKitAssetsPath);

return ExecuteAsync (executable, args, sdkDevPath: SdkDevPath, environment: environment, showErrorIfFailure: true);
return ExecuteAsync (executable, args, sdkDevPath: GetSdkDevPath (), environment: environment, showErrorIfFailure: true);
}

static bool TryGetScnAssetsPath (string file, out string scnassets)
Expand Down
7 changes: 1 addition & 6 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CoreMLCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public class CoreMLCompiler : XamarinTask, ICancelableTask, IHasProjectDir, IHas
[Required]
public string ResourcePrefix { get; set; } = "";

string sdkDevPath = "";
public string SdkDevPath {
get { return string.IsNullOrEmpty (sdkDevPath) ? "/" : sdkDevPath; }
set { sdkDevPath = value; }
}
#endregion

#region Outputs
Expand All @@ -60,7 +55,7 @@ int Compile (ITaskItem item, string outputDir, string log, string partialPlist)
args.Add (partialPlist);

var executable = GetExecutable (args, ToolName, CoreMlcPath);
var rv = ExecuteAsync (executable, args, sdkDevPath).Result;
var rv = ExecuteAsync (executable, args, GetSdkDevPath ()).Result;
var exitCode = rv.ExitCode;
var output = rv.Output.StandardOutput;
File.WriteAllText (log, output);
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/DSymUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class DSymUtil : XamarinTask, ITaskCallback {
[Required]
public ITaskItem [] Executable { get; set; } = Array.Empty<ITaskItem> ();

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

#endregion

#region Outputs
Expand Down Expand Up @@ -65,7 +62,7 @@ void ExecuteDSymUtil (ITaskItem item, List<ITaskItem> contentFiles)
args.Add (dSymDir);

args.Add (Path.GetFullPath (item.ItemSpec));
ExecuteAsync ("xcrun", args, sdkDevPath: SdkDevPath).Wait ();
ExecuteAsync ("xcrun", args, sdkDevPath: GetSdkDevPath ()).Wait ();

var contentsDir = Path.Combine (dSymDir, "Contents");
if (Directory.Exists (contentsDir))
Expand Down
7 changes: 4 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/DetectSdkLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public string SdkRoot {
} = "";

[Output]
public string SdkDevPath {
get; set;
} = "";
public new string SdkDevPath {
get => base.SdkDevPath;
set => base.SdkDevPath = value;
}

[Output]
public string SdkPlatform {
Expand Down
7 changes: 2 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/GetMlaunchArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public class GetMlaunchArguments : XamarinTask, ICancelableTask {

public string AppManifestPath { get; set; } = string.Empty;

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

public ITaskItem [] AdditionalArguments { get; set; } = Array.Empty<ITaskItem> ();
public string DeviceName { get; set; } = string.Empty;
public ITaskItem [] EnvironmentVariables { get; set; } = Array.Empty<ITaskItem> ();
Expand Down Expand Up @@ -112,7 +109,7 @@ public IPhoneDeviceType DeviceType {
var tmpfile = Path.GetTempFileName ();
try {
var output = new StringBuilder ();
var result = ExecuteAsync (MlaunchPath, new string [] { "--listsim", tmpfile }, SdkDevPath).Result;
var result = ExecuteAsync (MlaunchPath, new string [] { "--listsim", tmpfile }, GetSdkDevPath ()).Result;
if (result.ExitCode != 0)
return string.Empty;
simulator_list = File.ReadAllText (tmpfile);
Expand All @@ -130,7 +127,7 @@ public IPhoneDeviceType DeviceType {
var tmpfile = Path.GetTempFileName ();
try {
var output = new StringBuilder ();
var result = ExecuteAsync (MlaunchPath, new string [] { $"--listdev:{tmpfile}", "--output-format:xml", "--use-amdevice:false" }, SdkDevPath).Result;
var result = ExecuteAsync (MlaunchPath, new string [] { $"--listdev:{tmpfile}", "--output-format:xml", "--use-amdevice:false" }, GetSdkDevPath ()).Result;
if (result.ExitCode != 0)
return string.Empty;
device_list = File.ReadAllText (tmpfile);
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/InstallNameTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public class InstallNameTool : XamarinTask, ITaskCallback {
[Required]
public ITaskItem [] DynamicLibrary { get; set; } = [];

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

// This isn't consumed from the targets files, but it's needed for VSX to create corresponding
// files on Windows.
[Output]
Expand Down Expand Up @@ -50,7 +47,7 @@ public override bool Execute ()
arguments.Add (input.GetMetadata ("DynamicLibraryId"));
arguments.Add (temporaryTarget);

processes [i] = ExecuteAsync ("xcrun", arguments, sdkDevPath: SdkDevPath).ContinueWith ((v) => {
processes [i] = ExecuteAsync ("xcrun", arguments, sdkDevPath: GetSdkDevPath ()).ContinueWith ((v) => {
if (v.IsFaulted)
throw v.Exception;
if (v.Status == TaskStatus.RanToCompletion) {
Expand Down
7 changes: 2 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class LinkNativeCode : XamarinTask, ITaskCallback {
// A path to entitlements to be embedded into the executable
public string EntitlementsInExecutable { get; set; } = string.Empty;

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

[Required]
public bool SdkIsSimulator { get; set; }

Expand Down Expand Up @@ -213,7 +210,7 @@ bool ExecuteUnsafe ()
arguments.Add (flag.ItemSpec);
}

var rv = ExecuteAsync ("xcrun", arguments, sdkDevPath: SdkDevPath, showErrorIfFailure: false).Result;
var rv = ExecuteAsync ("xcrun", arguments, sdkDevPath: GetSdkDevPath (), showErrorIfFailure: false).Result;
if (rv.ExitCode != 0) {
var stderr = rv.Output.MergedOutput;
#if NET
Expand Down Expand Up @@ -284,7 +281,7 @@ string ConvertEntitlementsToDerEntitlements (string entitlements)
"-o", derEntitlements,
"--raw",
};
ExecuteAsync ("xcrun", arguments, sdkDevPath: SdkDevPath).Wait ();
ExecuteAsync ("xcrun", arguments, sdkDevPath: GetSdkDevPath ()).Wait ();
return derEntitlements;
}

Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/MergeAppBundles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public partial class MergeAppBundles : XamarinTask {
[Required]
public string OutputAppBundle { get; set; } = "";

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

#endregion

enum FileType {
Expand Down Expand Up @@ -441,7 +438,7 @@ void MergeMachOFiles (string output, IList<Entry> input)
arguments.Add ("-output");
arguments.Add (output);
arguments.AddRange (sourceFiles);
ExecuteAsync ("lipo", arguments, sdkDevPath: SdkDevPath).Wait ();
ExecuteAsync ("lipo", arguments, sdkDevPath: GetSdkDevPath ()).Wait ();
}

FileType GetFileType (string path)
Expand Down
3 changes: 0 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/Metal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public class Metal : XamarinTask, IHasProjectDir, IHasResourcePrefix {
[Required]
public string ResourcePrefix { get; set; } = string.Empty;

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

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

Expand Down
3 changes: 0 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/MetalLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public class MetalLib : XamarinTask, ITaskCallback {
[Required]
public string OutputLibrary { get; set; } = string.Empty;

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

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

Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/OptimizeImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public class OptimizeImage : XamarinParallelTask, ICancelableTask {

public string PngCrushPath { get; set; } = string.Empty;

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

#endregion

static List<string> GenerateCommandLineCommands (string inputImage, string outputImage)
Expand Down Expand Up @@ -92,7 +89,7 @@ public override bool Execute ()
ForEach (listOfArguments, (arg) => {
var args = arg.Arguments;
var executable = GetExecutable (args, "pngcrush", PngCrushPath);
ExecuteAsync (Log, executable, args, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */, cancellationToken: cancellationTokenSource.Token)
ExecuteAsync (Log, executable, args, sdkDevPath: GetSdkDevPath (), showErrorIfFailure: false /* we show our own error below */, cancellationToken: cancellationTokenSource.Token)
.ContinueWith ((v) => {
Execution execution = v.Result;
if (execution.ExitCode != 0)
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ScnTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public class ScnTool : XamarinParallelTask, IHasProjectDir, IHasResourcePrefix {
[Required]
public string SdkVersion { get; set; } = string.Empty;

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

#endregion

#region Outputs
Expand Down Expand Up @@ -91,7 +88,7 @@ public override bool Execute ()
}

ForEach (listOfArguments, (arg) => {
ExecuteAsync ("xcrun", arg.Arguments, sdkDevPath: SdkDevPath).Wait ();
ExecuteAsync ("xcrun", arg.Arguments, sdkDevPath: GetSdkDevPath ()).Wait ();
});

BundleResources = bundleResources.ToArray ();
Expand Down
14 changes: 13 additions & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ public abstract class XamarinTask : Task, IHasSessionId, ICustomLogger {

public string TargetFrameworkMoniker { get; set; } = string.Empty;

public string SdkDevPath { get; set; } = string.Empty;

public string GetSdkDevPath ()
{
if (string.IsNullOrEmpty (SdkDevPath)) {
Log.LogError (MSBStrings.E7169, /* The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose. */ GetType ().Name, "SdkDevPath");
return "";
}

return SdkDevPath;
}

void VerifyTargetFrameworkMoniker ()
{
if (!string.IsNullOrEmpty (TargetFrameworkMoniker))
return;
Log.LogError ($"The task {GetType ().Name} requires TargetFrameworkMoniker to be set.");
Log.LogError (MSBStrings.E7169, /* The task '{0}' requires the property '{1}' to be set. Please file an issue at https://github.com/dotnet/macios/issues/new/choose. */ GetType ().Name, "TargetFrameworkMoniker");
}

public string Product {
Expand Down
5 changes: 1 addition & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeBuildTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
namespace Xamarin.MacDev.Tasks {
public abstract class XcodeBuildTask : XamarinTask {

// Task input parameters
public string SdkDevPath { get; set; } = string.Empty;

public string WorkingDirectory { get; set; } = string.Empty;

public string OutputPath { get; set; } = string.Empty;
Expand All @@ -25,7 +22,7 @@ public override bool Execute ()
}
args.AddRange (GenerateCommandLineCommands ());

ExecuteAsync ("xcrun", args, sdkDevPath: SdkDevPath, workingDirectory: WorkingDirectory).Wait ();
ExecuteAsync ("xcrun", args, sdkDevPath: GetSdkDevPath (), workingDirectory: WorkingDirectory).Wait ();
return !Log.HasLoggedErrors;
}

Expand Down
14 changes: 2 additions & 12 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ public abstract class XcodeCompilerToolTask : XamarinTask, IHasProjectDir, IHasR
[Required]
public string SdkPlatform { get; set; } = string.Empty;

string? sdkDevPath;
public string SdkDevPath {
#if NET
get { return string.IsNullOrEmpty (sdkDevPath) ? "/" : sdkDevPath; }
#else
get { return (sdkDevPath is null || string.IsNullOrEmpty (sdkDevPath)) ? "/" : sdkDevPath; }
#endif
set { sdkDevPath = value; }
}

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

Expand Down Expand Up @@ -102,7 +92,7 @@ protected abstract string DefaultBinDir {
}

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

protected abstract string ToolName { get; }
Expand Down Expand Up @@ -219,7 +209,7 @@ protected int Compile (ITaskItem [] items, string output, ITaskItem manifest)
if (Log.HasLoggedErrors)
return 1;

var rv = ExecuteAsync (tool, args, sdkDevPath, environment: environment).Result;
var rv = ExecuteAsync (tool, args, SdkDevPath, environment: environment).Result;
var exitCode = rv.ExitCode;
var messages = rv.Output.StandardOutput;
File.WriteAllText (manifest.ItemSpec, messages);
Expand Down
9 changes: 3 additions & 6 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public abstract class XcodeToolTaskBase : XamarinTask, IHasProjectDir, IHasResou
[Required]
public string ResourcePrefix { get; set; } = string.Empty;

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

public string ToolExe {
get { return toolExe ?? ToolName; }
set { toolExe = value; }
Expand All @@ -51,15 +48,15 @@ protected abstract string DefaultBinDir {
}

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

protected string DevicePlatformBinDir {
get { return Path.Combine (SdkDevPath, "Platforms", "iPhoneOS.platform", "Developer", "usr", "bin"); }
get { return Path.Combine (GetSdkDevPath (), "Platforms", "iPhoneOS.platform", "Developer", "usr", "bin"); }
}

protected string SimulatorPlatformBinDir {
get { return Path.Combine (SdkDevPath, "Platforms", "iPhoneSimulator.platform", "Developer", "usr", "bin"); }
get { return Path.Combine (GetSdkDevPath (), "Platforms", "iPhoneSimulator.platform", "Developer", "usr", "bin"); }
}

protected abstract string ToolName { get; }
Expand Down
Loading
Loading