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
10 changes: 5 additions & 5 deletions msbuild/Xamarin.Mac.Tasks.Core/Tasks/MmpTaskBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ protected override string ToolName {
public string I18n { get; set; }
public string ExtraArguments { get; set; }

public string AotScope { get; set; }
public bool HybridAotOption { get; set; }
public string AotMode { get; set; }
public bool HybridAOT { get; set; }
public string ExplicitAotAssemblies { get; set; }

public ITaskItem [] ExplicitReferences { get; set; }
Expand Down Expand Up @@ -176,9 +176,9 @@ protected override string GenerateCommandLineCommands ()
break;
}

if (!string.IsNullOrEmpty (AotScope) && AotScope != "None") {
var aot = $"--aot:{AotScope.ToLower ()}";
if (HybridAotOption)
if (!string.IsNullOrEmpty (AotMode) && AotMode != "None") {
var aot = $"--aot:{AotMode.ToLower ()}";
if (HybridAOT)
aot += "|hybrid";

if (!string.IsNullOrEmpty (ExplicitAotAssemblies))
Expand Down
4 changes: 2 additions & 2 deletions msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ Copyright (C) 2014 Xamarin. All rights reserved.
SdkVersion="$(MacOSXSdkVersion)"
IsAppExtension="$(IsAppExtension)"
EnableSGenConc="$(EnableSGenConc)"
AotScope="$(AotScope)"
HybridAotOption="$(HybridAotOption)"
AotMode="$(AOTMode)"
HybridAOT="$(HybridAOT)"
ExplicitAotAssemblies="$(ExplicitAotAssemblies)">
<Output TaskParameter="NativeLibraries" ItemName="_NativeLibrary" />
</Mmp>
Expand Down
53 changes: 38 additions & 15 deletions tests/mmptest/src/AOTTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,70 @@ void ValidateAOTStatus (string tmpDir, Func<FileInfo, bool> shouldAOT, string bu
}
}

const string AOTTestBaseConfig = "<MonoBundlingExtraArgs>--aot=core,-Xamarin.Mac.dll</MonoBundlingExtraArgs>";
const string AOTTestHybridConfig = "<MonoBundlingExtraArgs>--aot=all|hybrid</MonoBundlingExtraArgs>";
enum TestType { Base, Hybrid }

string GetTestConfig (TestType type, bool useProjectTags)
{
if (useProjectTags) {
switch (type) {
case TestType.Base:
return "<AOTMode>Core</AOTMode>";
case TestType.Hybrid:
return "<AOTMode>All</AOTMode><HybridAOT>true</HybridAOT>";
}
} else {
switch (type) {
case TestType.Base:
return "<MonoBundlingExtraArgs>--aot=core</MonoBundlingExtraArgs>";
case TestType.Hybrid:
return "<MonoBundlingExtraArgs>--aot=all|hybrid</MonoBundlingExtraArgs>";
}
}
throw new NotImplementedException ();
}

DirectoryInfo GetOutputDirInfo (string tmpDir) => new DirectoryInfo (Path.Combine (tmpDir, GetOutputBundlePath (tmpDir)));
string GetOutputAppPath (string tmpDir) => Path.Combine (tmpDir, "bin/Debug/UnifiedExample.app/Contents/MacOS/UnifiedExample");
string GetOutputBundlePath (string tmpDir) => Path.Combine (tmpDir, "bin/Debug/UnifiedExample.app/Contents/MonoBundle");

bool IsFileManagedCode (FileInfo file) => file.Extension.ToLowerInvariant () == ".exe" || file.Extension.ToLowerInvariant () == ".dll";
bool ShouldBaseFilesBeAOT (FileInfo file) => file.Name == "System.dll" || file.Name == "mscorlib.dll";
bool ShouldBaseFilesBeAOT (FileInfo file) => file.Name == "Xamarin.Mac.dll" || file.Name == "System.dll" || file.Name == "mscorlib.dll";

// AOT unit tests can be found in tools/mmp/tests
[Test]
public void AOT_SmokeTest () {
[TestCase (false)]
[TestCase (true)]
public void AOT_SmokeTest (bool useProjectTags) {
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
CSProjConfig = AOTTestBaseConfig
CSProjConfig = GetTestConfig (TestType.Base, useProjectTags)
};
string buildResults = TI.TestUnifiedExecutable (test).BuildOutput;

ValidateAOTStatus (tmpDir, f => ShouldBaseFilesBeAOT (f), buildResults);
});
}

[Test]
public void AOT_32Bit_SmokeTest ()
[TestCase (false)]
[TestCase (true)]
public void AOT_32Bit_SmokeTest (bool useProjectTags)
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
CSProjConfig = "<XamMacArch>i386</XamMacArch>" + AOTTestBaseConfig
CSProjConfig = "<XamMacArch>i386</XamMacArch>" + GetTestConfig (TestType.Base, useProjectTags)
};
string buildResults = TI.TestUnifiedExecutable (test).BuildOutput;

ValidateAOTStatus (tmpDir, f => ShouldBaseFilesBeAOT (f), buildResults);
});
}

[Test]
public void HybridAOT_WithManualStrippingOfAllLibs_SmokeTest ()
[TestCase (false)]
[TestCase (true)]
public void HybridAOT_WithManualStrippingOfAllLibs_SmokeTest (bool useProjectTags)
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
CSProjConfig = AOTTestHybridConfig
CSProjConfig = GetTestConfig (TestType.Hybrid, useProjectTags)
};
string buildResults = TI.TestUnifiedExecutable (test).BuildOutput;

Expand All @@ -78,12 +100,13 @@ public void HybridAOT_WithManualStrippingOfAllLibs_SmokeTest ()
});
}

[Test]
public void HybridAOT_WithManualStrippingOfJustMainExe ()
[TestCase (false)]
[TestCase (true)]
public void HybridAOT_WithManualStrippingOfJustMainExe (bool useProjectTags)
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
CSProjConfig = AOTTestHybridConfig
CSProjConfig = GetTestConfig (TestType.Hybrid, useProjectTags)
};
string buildResults = TI.TestUnifiedExecutable (test).BuildOutput;

Expand Down