From 3f6d43c75649a85e47fd23d6d48c8d5a87257d7b Mon Sep 17 00:00:00 2001
From: Meri Khamoyan <96171496+mkhamoyan@users.noreply.github.com>
Date: Wed, 28 Jun 2023 12:25:24 +0400
Subject: [PATCH] [iOS] HybridGlobalization set flag in SDK (#18498)
Add HybridGlobalization flag in SDK and load icudt_hybrid.dat file when
HybridGlobalization is on.
Contributes to https://github.com/dotnet/runtime/issues/80689
---
dotnet/targets/Xamarin.Shared.Sdk.targets | 5 ++++-
tests/common/DotNet.cs | 1 +
tools/dotnet-linker/LinkerConfiguration.cs | 4 ++++
tools/dotnet-linker/Steps/GenerateMainStep.cs | 2 ++
4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets
index b7440a1942b0..475d8fae4124 100644
--- a/dotnet/targets/Xamarin.Shared.Sdk.targets
+++ b/dotnet/targets/Xamarin.Shared.Sdk.targets
@@ -126,6 +126,7 @@
false
false
false
+ false
false
true
false
@@ -143,7 +144,8 @@
- <_GlobalizationDataFile Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '$(_GlobalizationDataFile)' == ''">icudt.dat
+ <_GlobalizationDataFile Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '$(HybridGlobalization)' != 'true' And '$(_GlobalizationDataFile)' == ''">icudt.dat
+ <_GlobalizationDataFile Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '$(HybridGlobalization)' == 'true' And '$(_GlobalizationDataFile)' == ''">icudt_hybrid.dat
@@ -494,6 +496,7 @@
Interpreter=$(MtouchInterpreter)
IntermediateLinkDir=$(IntermediateLinkDir)
InvariantGlobalization=$(InvariantGlobalization)
+ HybridGlobalization=$(HybridGlobalization)
ItemsDirectory=$(_LinkerItemsDirectory)
IsAppExtension=$(IsAppExtension)
IsSimulatorBuild=$(_SdkIsSimulator)
diff --git a/tests/common/DotNet.cs b/tests/common/DotNet.cs
index c641c3892174..5f1a7698ad5c 100644
--- a/tests/common/DotNet.cs
+++ b/tests/common/DotNet.cs
@@ -218,6 +218,7 @@ public static void CompareApps (string old_app, string new_app)
var filename = Path.GetFileName (v);
switch (filename) {
case "icudt.dat":
+ case "icudt_hybrid.dat":
return false; // ICU data file only present on .NET
case "runtime-options.plist":
return false; // the .NET runtime will deal with selecting the http handler, no need for us to do anything
diff --git a/tools/dotnet-linker/LinkerConfiguration.cs b/tools/dotnet-linker/LinkerConfiguration.cs
index 3ce2760d5487..ecad293a4666 100644
--- a/tools/dotnet-linker/LinkerConfiguration.cs
+++ b/tools/dotnet-linker/LinkerConfiguration.cs
@@ -29,6 +29,7 @@ public class LinkerConfiguration {
public string GlobalizationDataFile { get; private set; } = string.Empty;
public string IntermediateLinkDir { get; private set; } = string.Empty;
public bool InvariantGlobalization { get; private set; }
+ public bool HybridGlobalization { get; private set; }
public string ItemsDirectory { get; private set; } = string.Empty;
public bool IsSimulatorBuild { get; private set; }
public string PartialStaticRegistrarLibrary { get; set; } = string.Empty;
@@ -316,6 +317,9 @@ public static LinkerConfiguration GetInstance (LinkContext context)
case "InvariantGlobalization":
InvariantGlobalization = string.Equals ("true", value, StringComparison.OrdinalIgnoreCase);
break;
+ case "HybridGlobalization":
+ HybridGlobalization = string.Equals ("true", value, StringComparison.OrdinalIgnoreCase);
+ break;
case "XamarinNativeLibraryDirectory":
XamarinNativeLibraryDirectory = value;
break;
diff --git a/tools/dotnet-linker/Steps/GenerateMainStep.cs b/tools/dotnet-linker/Steps/GenerateMainStep.cs
index b866b96094e4..e7f26d7dc639 100644
--- a/tools/dotnet-linker/Steps/GenerateMainStep.cs
+++ b/tools/dotnet-linker/Steps/GenerateMainStep.cs
@@ -38,6 +38,8 @@ protected override void TryEndProcess ()
if (Configuration.InvariantGlobalization) {
contents.AppendLine ("\tsetenv (\"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT\", \"1\", 1);");
} else {
+ if (Configuration.HybridGlobalization)
+ contents.AppendLine ("\tsetenv (\"DOTNET_SYSTEM_GLOBALIZATION_HYBRID\", \"1\", 1);");
contents.AppendLine ($"\txamarin_icu_dat_file_name = \"{Configuration.GlobalizationDataFile}\";");
}
if (Configuration.Application.PackageManagedDebugSymbols && Configuration.Application.UseInterpreter)