Skip to content
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

[dotnet] Make it possible to specify the registrar using a 'Registrar' property in MSBuild. #15483

Merged
merged 5 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
Platform=$(_PlatformName)
PlatformAssembly=$(_PlatformAssemblyName).dll
RelativeAppBundlePath=$(_RelativeAppBundlePath)
Registrar=$(_BundlerRegistrar)
Registrar=$(Registrar)
RequirePInvokeWrappers=$(_RequirePInvokeWrappers)
RuntimeConfigurationFile=$(_RuntimeConfigurationFile)
SdkDevPath=$(_SdkDevPath)
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
ExtraArgs="$(_BundlerArguments)"
NativeReferences="@(_FrameworkNativeReference);@(_FileNativeReference)"
References="@(ReferencePath);@(_BundlerReferencePath)"
Registrar="$(Registrar)"
ResponseFilePath="$(IntermediateOutputPath)response-file.rsp"
SdkRoot="$(_SdkDevPath)"
IntermediateOutputPath="$(IntermediateOutputPath)mmp-cache"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public abstract class BundlerToolTaskBase : XamarinToolTask {
[Required]
public ITaskItem [] References { get; set; }

public string Registrar { get; set; }

[Required]
public string ResponseFilePath { get; set; }

Expand Down Expand Up @@ -84,6 +86,9 @@ protected CommandLineArgumentBuilder GenerateCommandLineArguments ()
{
var args = new CommandLineArgumentBuilder ();

if (!string.IsNullOrEmpty (Registrar))
args.AddLine ($"--registrar:" + Registrar);

if (bool.TryParse (ArchiveSymbols?.Trim (), out var msym))
args.AddLine ($"--msym={(msym ? "yes" : "no")}");

Expand Down
3 changes: 2 additions & 1 deletion msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
NoSymbolStrip="$(NoSymbolStrip)"
NoDSymUtil="$(NoDSymUtil)"
PackageDebugSymbols="$(PackageDebugSymbols)"
Registrar="$(Registrar)"
Therzok marked this conversation as resolved.
Show resolved Hide resolved
Verbosity="$(_BundlerVerbosity)"
>
<Output TaskParameter="Aot" ItemName="_AotArguments" />
Expand All @@ -1806,7 +1807,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<Output TaskParameter="NoDSymUtil" PropertyName="NoDSymUtil"/>
<Output TaskParameter="Optimize" PropertyName="_BundlerOptimize"/>
<Output TaskParameter="PackageDebugSymbols" PropertyName="PackageDebugSymbols" />
<Output TaskParameter="Registrar" PropertyName="_BundlerRegistrar" />
<Output TaskParameter="Registrar" PropertyName="Registrar" />
<Output TaskParameter="RequirePInvokeWrappers" PropertyName="_RequirePInvokeWrappers" />
<Output TaskParameter="Verbosity" PropertyName="_BundlerVerbosity" />
<Output TaskParameter="XmlDefinitions" ItemName="_BundlerXmlDefinitions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
Profiling="$(MtouchProfiling)"
ProjectDir="$(MtouchProjectDirectory)"
References="@(ReferencePath);@(_BundlerReferencePath)"
Registrar="$(Registrar)"
ResponseFilePath="$(DeviceSpecificIntermediateOutputPath)response-file.rsp"
SdkRoot="$(_SdkDevPath)"
SdkIsSimulator="$(_SdkIsSimulator)"
Expand Down
17 changes: 17 additions & 0 deletions tests/ComputeRegistrarConstant.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Target Name="ComputeRegistrarConstant" BeforeTargets="BeforeBuild">
<PropertyGroup Condition="'$(_PlatformName)' == 'iOS' Or $(TargetFramework.EndsWith('-ios')) Or '$(_PlatformName)' == 'tvOS' Or $(TargetFramework.EndsWith('-tvos'))">
<IsDynamicRegistrar Condition="'$(ComputedPlatform)' == 'iPhoneSimulator' And '$(Registrar)' == ''">true</IsDynamicRegistrar>
<IsDynamicRegistrar Condition="'$(Registrar)' == 'dynamic'">true</IsDynamicRegistrar>
</PropertyGroup>

<PropertyGroup Condition="'$(_PlatformName)' == 'macOS' Or $(TargetFramework.EndsWith('-macos')) Or '$(_PlatformName)' == 'MacCatalyst' Or $(TargetFramework.EndsWith('-maccatalyst'))">
<IsDynamicRegistrar Condition="'$(Configuration)' == 'Debug'">true</IsDynamicRegistrar>
Therzok marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<PropertyGroup Condition="'$(HasDynamicRegistrar)' == 'true'">
rolfbjarne marked this conversation as resolved.
Show resolved Hide resolved
<IsDynamicRegistrar>$(DefineConstants);DYNAMIC_REGISTRAR</IsDynamicRegistrar>
Therzok marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
</Target>
</Project>
1 change: 1 addition & 0 deletions tests/common/shared-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" Condition="'$(ExcludeTouchUnitReference)' != 'true'" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)/../ComputeRegistrarConstant.targets" />
<Import Project="$(MSBuildThisFileDirectory)/../nunit.framework.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst</TargetFramework>
<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DYNAMIC_REGISTRAR</DefineConstants>
</PropertyGroup>

<!-- Imports of the form '../shared.csproj' will be inlined by xharness -->
Expand Down
1 change: 0 additions & 1 deletion tests/monotouch-test/dotnet/macOS/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-macos</TargetFramework>
<DefineConstants>$(DefineConstants);XAMMAC_TESTS</DefineConstants>
<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DYNAMIC_REGISTRAR</DefineConstants>
</PropertyGroup>

<!-- Imports of the form '../shared.csproj' will be inlined by xharness -->
Expand Down
1 change: 0 additions & 1 deletion tests/monotouch-test/dotnet/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@
<DefineConstants Condition="'$(ComputedPlatform)' == 'iPhone'">$(DefineConstants);AOT</DefineConstants>
<DefineConstants Condition="'$(RuntimeIdentifier)' == 'iossimulator-arm64'">$(DefineConstants);AOT</DefineConstants>
<DefineConstants Condition="'$(RuntimeIdentifier)' == 'tvossimulator-arm64'">$(DefineConstants);AOT</DefineConstants>
<DefineConstants Condition="'$(ComputedPlatform)' == 'iPhoneSimulator'">$(DefineConstants);DYNAMIC_REGISTRAR</DefineConstants>
</PropertyGroup>
</Target>
</Project>
1 change: 0 additions & 1 deletion tests/monotouch-test/dotnet/tvOS/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-tvos</TargetFramework>
<DefineConstants Condition="'$(Platform)' == 'iPhoneSimulator'">$(DefineConstants);DYNAMIC_REGISTRAR</DefineConstants>
</PropertyGroup>

<!-- Imports of the form '../shared.csproj' will be processed by xharness -->
Expand Down
5 changes: 3 additions & 2 deletions tests/monotouch-test/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\iPhoneSimulator\$(Configuration)-unified</OutputPath>
<DefineConstants>DEBUG;DYNAMIC_REGISTRAR;$(DefineConstants)</DefineConstants>
<DefineConstants>DEBUG;$(DefineConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<MtouchDebug>True</MtouchDebug>
Expand All @@ -40,7 +40,7 @@
<DebugType>none</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\iPhoneSimulator\$(Configuration)-unified</OutputPath>
<DefineConstants>MONOTOUCH;DYNAMIC_REGISTRAR;$(DefineConstants)</DefineConstants>
<DefineConstants>MONOTOUCH;$(DefineConstants)</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<MtouchLink>None</MtouchLink>
Expand Down Expand Up @@ -226,6 +226,7 @@
<Compile Include="SceneKit\SCNVector3Test.cs" />
<Compile Include="SceneKit\SCNVector4Test.cs" />
</ItemGroup>
<Import Project="$(RootTestsDirectory)\ComputeRegistrarConstant.targets" />
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions tests/xammac_tests/xammac_tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\x86\Debug</OutputPath>
<DefineConstants>DEBUG;MONOMAC;XAMMAC_TESTS;DYNAMIC_REGISTRAR</DefineConstants>
<DefineConstants>DEBUG;MONOMAC;XAMMAC_TESTS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
Expand All @@ -44,7 +44,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\arm64\Debug</OutputPath>
<DefineConstants>DEBUG;MONOMAC;XAMMAC_TESTS;DYNAMIC_REGISTRAR</DefineConstants>
<DefineConstants>DEBUG;MONOMAC;XAMMAC_TESTS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
Expand Down Expand Up @@ -288,6 +288,7 @@
<Link>Base.lproj\Localizable.strings</Link>
</BundleResource>
</ItemGroup>
<Import Project="$(RootTestsDirectory)\ComputeRegistrarConstant.targets" />
<Import Project="$(RootTestsDirectory)\nunit.framework.targets" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions tests/xharness/Jenkins/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ class TestData
public IEnumerable<IDevice> Candidates;
public string XamMacArch;
public string RuntimeIdentifier;
public string Registrar;
}
}
23 changes: 13 additions & 10 deletions tests/xharness/Jenkins/TestVariationsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ IEnumerable<TestData> GetTestData (RunTestTask test)
if (test.TestProject.IsDotNetProject)
ignore = true;
if (supports_dynamic_registrar_on_device)
yield return new TestData { Variation = "Debug (dynamic registrar)", MTouchExtraArgs = "--registrar:dynamic", Debug = true, Profiling = false, Ignored = ignore };
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, Defines = "OPTIMIZEALL", Ignored = ignore };
yield return new TestData { Variation = "Debug (dynamic registrar)", Registrar = "dynamic", Debug = true, Profiling = false, Ignored = ignore };
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--optimize:all", Registrar = "static", Debug = false, Profiling = false, Defines = "OPTIMIZEALL", Ignored = ignore };
if (supports_debug) {
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = true, Profiling = false, Defines = "OPTIMIZEALL", Ignored = ignore };
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--optimize:all", Registrar = "static", Debug = true, Profiling = false, Defines = "OPTIMIZEALL", Ignored = ignore };
yield return new TestData { Variation = "Debug: SGenConc", MTouchExtraArgs = "", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, EnableSGenConc = true, Ignored = ignore };
}
if (supports_interpreter) {
Expand Down Expand Up @@ -120,9 +120,9 @@ IEnumerable<TestData> GetTestData (RunTestTask test)
case "monotouch-test":
// The default is to run monotouch-test with the dynamic registrar (in the simulator), so that's already covered
yield return new TestData { Variation = "Debug (LinkSdk)", Debug = true, Profiling = false, LinkMode = test.TestProject.IsDotNetProject ? "SdkOnly" : "LinkSdk", Ignored = ignore };
yield return new TestData { Variation = "Debug (static registrar)", MTouchExtraArgs = "--registrar:static", Debug = true, Profiling = false, Undefines = "DYNAMIC_REGISTRAR", Ignored = ignore };
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Undefines = "DYNAMIC_REGISTRAR", Ignored = ignore };
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all,-remove-uithread-checks", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Undefines = "DYNAMIC_REGISTRAR", Ignored = ignore ?? !jenkins.TestSelection.IsEnabled (TestLabel.All) };
yield return new TestData { Variation = "Debug (static registrar)", Registrar = "static", Debug = true, Profiling = false, Ignored = ignore };
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--optimize:all", Registrar = "static", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = ignore };
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--optimize:all,-remove-uithread-checks", Registrar = "static", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = ignore ?? !jenkins.TestSelection.IsEnabled (TestLabel.All) };

if (test.TestProject.IsDotNetProject && mac_supports_arm64)
yield return new TestData { Variation = "Debug (ARM64)", Debug = true, Profiling = false, Ignored = !mac_supports_arm64 ? true : ignore, RuntimeIdentifier = arm64_sim_runtime_identifier, };
Expand All @@ -148,8 +148,8 @@ IEnumerable<TestData> GetTestData (RunTestTask test)
if (test.TestProject.IsDotNetProject) {
yield return new TestData { Variation = "Debug (ARM64)", Debug = true, Profiling = false, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac) || !mac_supports_arm64, RuntimeIdentifier = arm64_runtime_identifier, };
if (test.Platform != TestPlatform.MacCatalyst) {
yield return new TestData { Variation = "Debug (static registrar)", MonoBundlingExtraArgs = "--registrar:static", Debug = true, Undefines = "DYNAMIC_REGISTRAR", Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac), };
yield return new TestData { Variation = "Debug (static registrar, ARM64)", MonoBundlingExtraArgs = "--registrar:static", Debug = true, Undefines = "DYNAMIC_REGISTRAR", Profiling = false, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac) || !mac_supports_arm64, RuntimeIdentifier = arm64_runtime_identifier, };
yield return new TestData { Variation = "Debug (static registrar)", Registrar = "static", Debug = true, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac), };
yield return new TestData { Variation = "Debug (static registrar, ARM64)", Registrar = "static", Debug = true, Profiling = false, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac) || !mac_supports_arm64, RuntimeIdentifier = arm64_runtime_identifier, };
}
if (test.Platform == TestPlatform.MacCatalyst)
yield return new TestData { Variation = "Release (ARM64, LLVM)", Debug = false, UseLlvm = true, Ignored = !jenkins.TestSelection.IsEnabled (TestLabel.Monotouch) || !jenkins.TestSelection.IsEnabled (PlatformLabel.MacCatalyst) || !mac_supports_arm64, RuntimeIdentifier = arm64_runtime_identifier };
Expand All @@ -158,11 +158,11 @@ IEnumerable<TestData> GetTestData (RunTestTask test)
case "xammac tests":
switch (test.ProjectConfiguration) {
case "Release":
yield return new TestData { Variation = "Release (all optimizations)", MonoBundlingExtraArgs = "--registrar:static --optimize:all", Debug = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Undefines = "DYNAMIC_REGISTRAR" };
yield return new TestData { Variation = "Release (all optimizations)", MonoBundlingExtraArgs = "--optimize:all", Registrar = "static", Debug = false, LinkMode = "Full", Defines = "OPTIMIZEALL" };
yield return new TestData { Variation = "Release (ARM64)", XamMacArch = "ARM64", Debug = false, Ignored = !mac_supports_arm64 || !jenkins.TestSelection.IsEnabled (TestLabel.Xammac) || !jenkins.TestSelection.IsEnabled (PlatformLabel.Mac) };
break;
case "Debug":
yield return new TestData { Variation = "Debug (all optimizations)", MonoBundlingExtraArgs = "--registrar:static --optimize:all,-remove-uithread-checks", Debug = true, LinkMode = "Full", Defines = "OPTIMIZEALL", Undefines = "DYNAMIC_REGISTRAR", Ignored = !(jenkins.TestSelection.IsEnabled (TestLabel.All) && jenkins.TestSelection.IsEnabled (PlatformLabel.Mac)) };
yield return new TestData { Variation = "Debug (all optimizations)", MonoBundlingExtraArgs = "--optimize:all,-remove-uithread-checks", Registrar = "static", Debug = true, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = !(jenkins.TestSelection.IsEnabled (TestLabel.All) && jenkins.TestSelection.IsEnabled (PlatformLabel.Mac)) };
yield return new TestData { Variation = "Debug (ARM64)", XamMacArch = "ARM64", Debug = true, Ignored = !mac_supports_arm64 || !jenkins.TestSelection.IsEnabled (TestLabel.Xammac) ||!jenkins.TestSelection.IsEnabled (PlatformLabel.Mac) };
break;
}
Expand Down Expand Up @@ -203,6 +203,7 @@ public IEnumerable<T> CreateTestVariations<T> (IEnumerable<T> tests, Func<MSBuil
var xammac_arch = test_data.XamMacArch;
var runtime_identifer = test_data.RuntimeIdentifier;
var use_llvm = test_data.UseLlvm;
var registrar = test_data.Registrar;

if (task.TestProject.IsDotNetProject)
variation += " [dotnet]";
Expand Down Expand Up @@ -264,6 +265,8 @@ public IEnumerable<T> CreateTestVariations<T> (IEnumerable<T> tests, Func<MSBuil
clone.Xml.SetNode ("XamMacArch", xammac_arch, task.ProjectPlatform, configuration);
if (!string.IsNullOrEmpty (runtime_identifer))
clone.Xml.SetTopLevelPropertyGroupValue ("RuntimeIdentifier", runtime_identifer);
if (!string.IsNullOrEmpty (registrar))
clone.Xml.SetTopLevelPropertyGroupValue ("Registrar", registrar);
clone.Xml.Save (clone.Path);
});

Expand Down