diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 494bb01703bf..eb19c68585eb 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -137,6 +137,10 @@ false + + icudt.dat + + true @@ -217,6 +221,9 @@ + + + <_CustomLinkerOptionsFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)custom-linker-options.txt')) @@ -241,6 +248,7 @@ DeploymentTarget=$(_MinimumOSVersion) @(_BundlerEnvironmentVariables -> 'EnvironmentVariable=%(Identity)=%(Value)') @(_XamarinFrameworkAssemblies -> 'FrameworkAssembly=%(Filename)') + GlobalizationDataFile=$(GlobalizationDataFile) Interpreter=$(MtouchInterpreter) IntermediateLinkDir=$(IntermediateLinkDir) InvariantGlobalization=$(InvariantGlobalization) @@ -760,7 +768,7 @@ + Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '%(Filename)%(Extension)' == '$(GlobalizationDataFile)'" /> diff --git a/runtime/runtime.m b/runtime/runtime.m index c7728faebd63..bfd2fa0badd1 100644 --- a/runtime/runtime.m +++ b/runtime/runtime.m @@ -55,6 +55,9 @@ #endif int xamarin_log_level = 0; const char *xamarin_executable_name = NULL; +#if DOTNET +const char *xamarin_icu_dat_file_path = NULL; +#endif #if MONOMAC || TARGET_OS_MACCATALYST NSString * xamarin_custom_bundle_name = @"MonoBundle"; #endif @@ -2391,7 +2394,7 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags; const char *propertyValues[] = { xamarin_get_bundle_path (), pinvokeOverride, - "icudt.dat", + xamarin_icu_dat_file_path, }; static_assert (sizeof (propertyKeys) == sizeof (propertyValues), "The number of keys and values must be the same."); diff --git a/tools/dotnet-linker/LinkerConfiguration.cs b/tools/dotnet-linker/LinkerConfiguration.cs index 14a6524840e7..a5fffa8a4bb7 100644 --- a/tools/dotnet-linker/LinkerConfiguration.cs +++ b/tools/dotnet-linker/LinkerConfiguration.cs @@ -21,6 +21,7 @@ public class LinkerConfiguration { public string CacheDirectory { get; private set; } public Version DeploymentTarget { get; private set; } public HashSet FrameworkAssemblies { get; private set; } = new HashSet (); + public string GlobalizationDataFile { get; private set; } public string IntermediateLinkDir { get; private set; } public bool InvariantGlobalization { get; private set; } public string ItemsDirectory { get; private set; } @@ -229,6 +230,9 @@ public static LinkerConfiguration GetInstance (LinkContext context, bool createI throw new InvalidOperationException ($"Invalid XamarinRuntime '{value}' in {linker_file}"); Application.XamarinRuntime = rv; break; + case "GlobalizationDataFile": + GlobalizationDataFile = value; + break; case "InvariantGlobalization": InvariantGlobalization = string.Equals ("true", value, StringComparison.OrdinalIgnoreCase); break; diff --git a/tools/dotnet-linker/Steps/GenerateMainStep.cs b/tools/dotnet-linker/Steps/GenerateMainStep.cs index d0e7536728a6..5f9630a55a00 100644 --- a/tools/dotnet-linker/Steps/GenerateMainStep.cs +++ b/tools/dotnet-linker/Steps/GenerateMainStep.cs @@ -29,10 +29,15 @@ protected override void TryEndProcess () var contents = new StringBuilder (); contents.AppendLine ("#include "); + contents.AppendLine (); + contents.AppendLine ("extern \"C\" const char *xamarin_icu_dat_file_path;"); + contents.AppendLine (); contents.AppendLine ("static void xamarin_initialize_dotnet ()"); contents.AppendLine ("{"); if (Configuration.InvariantGlobalization) { contents.AppendLine ("\tsetenv (\"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT\", \"1\", 1);"); + } else { + contents.AppendLine ($"\txamarin_icu_dat_file_path = \"{Configuration.GlobalizationDataFile}\";"); } contents.AppendLine ("}"); contents.AppendLine ();