-
Notifications
You must be signed in to change notification settings - Fork 576
[mmp] Add support for linking only the platform (Xamarin.Mac.dll) assembly on the full profile #1990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[mmp] Add support for linking only the platform (Xamarin.Mac.dll) assembly on the full profile #1990
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
be22e09
[mmp] Add support for linking only the platform (Xamarin.Mac.dll) ass…
spouliot 4a1e170
Add XM SDK + LinkSkip test
chamons 895079b
[macos] Add platform linking support to msbuild
chamons f9c9829
[macos] Add full SDK test
chamons acdbe74
[macios] Diable classic from using linkplatform
chamons 450f8f5
Merge branch 'master' into mmp-link-platform
chamons 5b8d400
Fix build
chamons 0001773
Merge branch 'master' into mmp-link-platform
chamons fb17f3f
Merge branch 'master' into mmp-link-platform
spouliot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using NUnit.Framework; | ||
| using System.Reflection; | ||
|
|
||
| namespace Xamarin.MMP.Tests | ||
| { | ||
| public partial class MMPTests | ||
| { | ||
| int GetNumberOfTypesInLibrary (string path) | ||
| { | ||
| string output = TI.RunAndAssert ("/Library/Frameworks/Mono.framework/Versions/Current/Commands/monop", new StringBuilder ("-r:" + path), "GetNumberOfTypesInLibrary"); | ||
| string[] splitBuildOutput = output.Split (new string[] { Environment.NewLine }, StringSplitOptions.None); | ||
| string outputLine = splitBuildOutput.First (x => x.StartsWith ("Total:")); | ||
| string numberSize = outputLine.Split (':')[1]; | ||
| string number = numberSize.Split (' ')[1]; | ||
| return int.Parse (number); | ||
| } | ||
|
|
||
| string GetAppName (bool modern) => modern ? "UnifiedExample.app" : "XM45Example.app"; | ||
| string GetOutputBundlePath (string tmpDir, string name, bool modern) => Path.Combine (tmpDir, "bin/Debug/" + GetAppName (modern) + "/Contents/MonoBundle", name + ".dll"); | ||
|
|
||
| string GetFrameworkName (bool modern) => modern ? "Xamarin.Mac" : "4.5"; | ||
| string GetBaseAssemblyPath (string name, bool modern) => Path.Combine (TI.FindRootDirectory (), "Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/" + GetFrameworkName (modern) + "/", name + ".dll"); | ||
|
|
||
| const string PlatformProjectConfig = "<LinkMode>Platform</LinkMode>"; | ||
|
|
||
| [Test] | ||
| public void ModernLinkingSDK_WithAllNonProductSkipped_BuildsWithSameNumberOfTypes () | ||
| { | ||
| RunMMPTest (tmpDir => { | ||
| string[] dependencies = { "mscorlib", "System.Core", "System" }; | ||
| string config = "<LinkMode>SdkOnly</LinkMode><MonoBundlingExtraArgs>--linkskip=" + dependencies.Aggregate ((arg1, arg2) => arg1 + " --linkskip=" + arg2) + "</MonoBundlingExtraArgs>"; | ||
| TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { CSProjConfig = config }; | ||
| TI.TestUnifiedExecutable (test); | ||
| foreach (string dep in dependencies) { | ||
| int typesInBaseLib = GetNumberOfTypesInLibrary (GetBaseAssemblyPath (dep, true)); | ||
| int typesInOutput = GetNumberOfTypesInLibrary (GetOutputBundlePath (tmpDir, dep, true)); | ||
| Assert.AreEqual (typesInBaseLib, typesInOutput, $"We linked a linkskip - {dep} with config ({typesInBaseLib} vs {typesInOutput}:\n {config}"); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| [Test] | ||
| public void FullLinkingSdk_BuildsWithFewerPlatformTypesOnly () | ||
| { | ||
| RunMMPTest (tmpDir => { | ||
| string[] nonPlatformDependencies = { "mscorlib", "System.Core", "System" }; | ||
| TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) { CSProjConfig = PlatformProjectConfig, XM45 = true }; | ||
| TI.TestUnifiedExecutable (test); | ||
| foreach (string dep in nonPlatformDependencies) { | ||
| int typesInBaseLib = GetNumberOfTypesInLibrary (GetBaseAssemblyPath (dep, false)); | ||
| int typesInOutput = GetNumberOfTypesInLibrary (GetOutputBundlePath (tmpDir, dep, false)); | ||
| Assert.AreEqual (typesInBaseLib, typesInOutput, $"We linked a linkskip - {dep} with config ({typesInBaseLib} vs {typesInOutput}):\n {PlatformProjectConfig}"); | ||
| } | ||
|
|
||
| int typesInBasePlatform = GetNumberOfTypesInLibrary (GetBaseAssemblyPath ("Xamarin.Mac", false)); | ||
| int typesInOutputPlatform = GetNumberOfTypesInLibrary (GetOutputBundlePath (tmpDir, "Xamarin.Mac", false)); | ||
| Assert.AreNotEqual (typesInBasePlatform, typesInOutputPlatform, $"We linked a linkskip - Xamarin.Mac with config ({typesInBasePlatform} vs {typesInOutputPlatform}):\n {PlatformProjectConfig}"); | ||
|
|
||
| }); | ||
| } | ||
|
|
||
| [Test] | ||
| public void PlatformSDKOnClassic_ShouldNotBeSupported () | ||
| { | ||
| RunMMPTest (tmpDir => { | ||
| TI.TestClassicExecutable (tmpDir, csprojConfig: "<MonoBundlingExtraArgs>--linkplatform</MonoBundlingExtraArgs>\n", includeMonoRuntime:true, shouldFail: true); | ||
| }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about XamMac.dll? Do we want to support Classic? We might want to disallow it, just to minimize the test matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad point. Let me add an error...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rolfbjarne done in acdbe74