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
34 changes: 16 additions & 18 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ACTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,24 @@ protected override void AppendCommandLineArguments (IDictionary<string, string?>
if (OptimizePNGs)
args.Add ("--compress-pngs");

if (AppleSdkSettings.XcodeVersion.Major >= 7) {
if (!string.IsNullOrEmpty (outputSpecs)) {
args.Add ("--enable-on-demand-resources");
args.Add (EnableOnDemandResources ? "YES" : "NO");
}
if (!string.IsNullOrEmpty (outputSpecs)) {
args.Add ("--enable-on-demand-resources");
args.Add (EnableOnDemandResources ? "YES" : "NO");
}

if (!string.IsNullOrEmpty (DeviceModel)) {
args.Add ("--filter-for-device-model");
args.Add (DeviceModel);
}
if (!string.IsNullOrEmpty (DeviceModel)) {
args.Add ("--filter-for-device-model");
args.Add (DeviceModel);
}

if (!string.IsNullOrEmpty (DeviceOSVersion)) {
args.Add ("--filter-for-device-os-version");
args.Add (DeviceOSVersion);
}
if (!string.IsNullOrEmpty (DeviceOSVersion)) {
args.Add ("--filter-for-device-os-version");
args.Add (DeviceOSVersion);
}

if (!string.IsNullOrEmpty (outputSpecs)) {
args.Add ("--asset-pack-output-specifications");
args.Add (Path.GetFullPath (outputSpecs));
}
if (!string.IsNullOrEmpty (outputSpecs)) {
args.Add ("--asset-pack-output-specifications");
args.Add (Path.GetFullPath (outputSpecs));
}

if (Platform == ApplePlatform.MacCatalyst) {
Expand Down Expand Up @@ -422,7 +420,7 @@ public override bool Execute ()
catalogs.Add (item);
}

if (AppleSdkSettings.XcodeVersion.Major >= 7 && SdkPlatform != "WatchSimulator") {
if (SdkPlatform != "WatchSimulator") {
var text = File.ReadAllText (assetItem.ItemSpec);

if (string.IsNullOrEmpty (text))
Expand Down
15 changes: 6 additions & 9 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileSceneKitAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@ Task CopySceneKitAssets (string scnassets, string output, string intermediate)
args.Add (Path.GetFullPath (output));
args.Add ($"--sdk-root={SdkRoot}");

if (AppleSdkSettings.XcodeVersion.Major >= 10) {
var platform = PlatformUtils.GetTargetPlatform (SdkPlatform, IsWatchApp);
if (platform is not null)
args.Add ($"--target-platform={platform}");

args.Add ($"--target-version={SdkVersion}");
} else {
args.Add ($"--target-version-{OperatingSystem}={SdkVersion}");
}
var platform = PlatformUtils.GetTargetPlatform (SdkPlatform, IsWatchApp);
if (platform is not null)
args.Add ($"--target-platform={platform}");

args.Add ($"--target-version={SdkVersion}");

args.Add ($"--target-build-dir={Path.GetFullPath (intermediate)}");
args.Add ($"--resources-folder-path={AppBundleName}");

Expand Down
7 changes: 0 additions & 7 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/DSymUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ void ExecuteDSymUtil (ITaskItem item, List<ITaskItem> contentFiles)
args.Add ("dsymutil");
args.Add ("-num-threads");
args.Add ("4");
if (AppleSdkSettings.XcodeVersion < new Version (13, 3)) {
// Apple removed the -z / --minimize option in Xocde 13.3, so now if you use it you get a warning: "ignoring unknown option: -z"
// So just don't pass -z when Xcode >= 13.3
// Ref: https://github.com/llvm/llvm-project/commit/5d07dc897707f877c45cab6c7e4b65dad7d3ff6d
// Ref: https://github.com/dotnet/runtime/issues/66770
args.Add ("-z");
}
args.Add ("-o");
args.Add (dSymDir);

Expand Down
111 changes: 43 additions & 68 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/IBTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ protected bool AutoActivateCustomFonts {
}

protected override bool UseCompilationDirectory {
get { return AppleSdkSettings.XcodeVersion >= new Version (6, 3); }
}

protected bool CanLinkStoryboards {
get { return AppleSdkSettings.XcodeVersion.Major > 7 || (AppleSdkSettings.XcodeVersion.Major == 7 && AppleSdkSettings.XcodeVersion.Minor >= 2); }
get => true;
}

protected override void AppendCommandLineArguments (IDictionary<string, string?> environment, List<string> args, ITaskItem [] items)
Expand All @@ -65,7 +61,7 @@ protected override void AppendCommandLineArguments (IDictionary<string, string?>
args.Add (targetDevice);
}

if (AppleSdkSettings.XcodeVersion.Major >= 6 && AutoActivateCustomFonts)
if (AutoActivateCustomFonts)
args.Add ("--auto-activate-custom-fonts");

if (!string.IsNullOrEmpty (SdkRoot)) {
Expand Down Expand Up @@ -222,12 +218,7 @@ bool CompileInterfaceDefinitions (IEnumerable<ITaskItem> interfaceDefinitions, s
if (EnableOnDemandResources && !string.IsNullOrEmpty (resourceTags))
expected.SetMetadata ("ResourceTags", resourceTags);

if (UseCompilationDirectory) {
// Note: When using --compilation-directory, we need to specify the output path as the parent directory
output = Path.GetDirectoryName (path);
} else {
output = expected.ItemSpec;
}
output = Path.GetDirectoryName (path);

if (InterfaceDefinitionChanged (item, manifest)) {
Directory.CreateDirectory (manifestDir);
Expand All @@ -252,37 +243,32 @@ bool CompileInterfaceDefinitions (IEnumerable<ITaskItem> interfaceDefinitions, s
continue;
}

if (UseCompilationDirectory) {
// Note: When using a compilation-directory, we'll scan dir the baseOutputDir later as
// an optimization to collect all of the compiled output in one fell swoop.
var metadata = expected.CloneCustomMetadata ();
// Note: When using a compilation-directory, we'll scan dir the baseOutputDir later as
// an optimization to collect all of the compiled output in one fell swoop.
var metadata = expected.CloneCustomMetadata ();

foreach (var target in targets) {
var key = name + "~" + target + extension;
foreach (var target in targets) {
var key = name + "~" + target + extension;

// Note: we don't blindly .Add() here because there may already be a mapping for this file if the
// source file is named something like "MyView.xib" and we've already processed "MyView~ipad.xib".
//
// When a situation like this occurs, we don't want to override the metadata.
if (!mapping.ContainsKey (key))
mapping.Add (key, metadata);
}

// Note: we don't use .Add() here because there may already be a mapping for this file if the
// source file is named something like "MyView~ipad.xib" and we've already processed "MyView.xib".
// Note: we don't blindly .Add() here because there may already be a mapping for this file if the
// source file is named something like "MyView.xib" and we've already processed "MyView~ipad.xib".
//
// In this case, we want to override the metadata for "MyView.xib" with the metadata for
// "MyView~ipad.xib".
mapping [path] = metadata;
} else {
compiled.AddRange (GetCompilationOutput (expected));
// When a situation like this occurs, we don't want to override the metadata.
if (!mapping.ContainsKey (key))
mapping.Add (key, metadata);
}

// Note: we don't use .Add() here because there may already be a mapping for this file if the
// source file is named something like "MyView~ipad.xib" and we've already processed "MyView.xib".
//
// In this case, we want to override the metadata for "MyView.xib" with the metadata for
// "MyView~ipad.xib".
mapping [path] = metadata;

manifests.Add (manifest);
}

if (UseCompilationDirectory)
compiled.AddRange (GetCompilationDirectoryOutput (baseOutputDir, mapping));
compiled.AddRange (GetCompilationDirectoryOutput (baseOutputDir, mapping));

return !Log.HasLoggedErrors;
}
Expand Down Expand Up @@ -410,12 +396,6 @@ public override bool Execute ()
if (ShouldExecuteRemotely ())
return ExecuteRemotely ();

if (IsWatchApp && AppleSdkSettings.XcodeVersion < new Version (6, 2)) {
Log.LogError (MSBStrings.E0160, AppleSdkSettings.XcodeVersion);

return !Log.HasLoggedErrors;
}

var ibtoolManifestDir = Path.Combine (IntermediateOutputPath, "ibtool-manifests");
var ibtoolOutputDir = Path.Combine (IntermediateOutputPath, "ibtool");
var outputManifests = new List<ITaskItem> ();
Expand All @@ -436,37 +416,32 @@ public override bool Execute ()
if (!CompileInterfaceDefinitions (interfaceDefinitions, ibtoolManifestDir, ibtoolOutputDir, compiled, outputManifests, out changed))
return false;

if (CanLinkStoryboards) {
var storyboards = new List<ITaskItem> ();
var linked = new List<ITaskItem> ();
var unique = new HashSet<string> ();

for (int i = 0; i < compiled.Count; i++) {
// pretend that non-storyboardc items (e.g. *.nib) are already 'linked'
if (compiled [i].ItemSpec.EndsWith (".storyboardc", StringComparison.Ordinal)) {
var interfaceDefinition = compiled [i].GetMetadata ("InterfaceDefinition");
unique.Add (interfaceDefinition);
storyboards.Add (compiled [i]);
continue;
}

// just pretend any *nib's have already been 'linked'...
compiled [i].RemoveMetadata ("InterfaceDefinition");
linked.Add (compiled [i]);
var storyboards = new List<ITaskItem> ();
var linked = new List<ITaskItem> ();
var unique = new HashSet<string> ();

for (int i = 0; i < compiled.Count; i++) {
// pretend that non-storyboardc items (e.g. *.nib) are already 'linked'
if (compiled [i].ItemSpec.EndsWith (".storyboardc", StringComparison.Ordinal)) {
var interfaceDefinition = compiled [i].GetMetadata ("InterfaceDefinition");
unique.Add (interfaceDefinition);
storyboards.Add (compiled [i]);
continue;
}

// only link the storyboards if there are multiple unique storyboards
if (unique.Count > 1) {
var linkOutputDir = Path.Combine (IntermediateOutputPath, "ibtool-link");
// just pretend any *nib's have already been 'linked'...
compiled [i].RemoveMetadata ("InterfaceDefinition");
linked.Add (compiled [i]);
}

if (!LinkStoryboards (ibtoolManifestDir, linkOutputDir, storyboards, linked, outputManifests, changed))
return false;
// only link the storyboards if there are multiple unique storyboards
if (unique.Count > 1) {
var linkOutputDir = Path.Combine (IntermediateOutputPath, "ibtool-link");

compiled = linked;
}
} else {
for (int i = 0; i < compiled.Count; i++)
compiled [i].RemoveMetadata ("InterfaceDefinition");
if (!LinkStoryboards (ibtoolManifestDir, linkOutputDir, storyboards, linked, outputManifests, changed))
return false;

compiled = linked;
}
}

Expand Down
9 changes: 2 additions & 7 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ScnTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,8 @@ IList<string> GenerateCommandLineCommands (string inputScene, string outputScene
args.Add (outputScene);
args.Add ($"--sdk-root={SdkRoot}");
args.Add ($"--target-build-dir={IntermediateOutputPath}");
if (AppleSdkSettings.XcodeVersion.Major >= 13) {
// I'm not sure which Xcode version these options are available in, but it's at least Xcode 13+
args.Add ($"--target-version={SdkVersion}");
args.Add ($"--target-platform={PlatformUtils.GetTargetPlatform (SdkPlatform, IsWatchApp)}");
} else {
args.Add ($"--target-version-{PlatformFrameworkHelper.GetOperatingSystem (TargetFrameworkMoniker)}={SdkVersion}");
}
args.Add ($"--target-version={SdkVersion}");
args.Add ($"--target-platform={PlatformUtils.GetTargetPlatform (SdkPlatform, IsWatchApp)}");

return args;
}
Expand Down
Loading