forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ICU integration and asset loading overhaul (dotnet#37971)
This PR overhauls runtime startup/asset loading and adds support for ICU integration. The mono-config.js format is reworked and simplified, with new functionality added: Individual assets can be loaded from one or more remote sources with configurable fallback behavior In addition to the existing support for loading assemblies, you can now pre-load arbitrary files into the native heap or into emscripten's virtual file system. VFS support previously only existed in runtime-test.js but now is available to any consumer of dotnet.js. Assets can have a virtual path set so that their application-facing path does not necessarily have to match their path on the server. One or more ICU data archives can be added to the assets list and will be automatically loaded and used to enable ICU-based globalization support. Many configuration knobs that previously required API calls can now be set declaratively in the configuration file (environment variables, etc.) WasmAppBuilder is updated to add ICUDataFiles and RemoteSources parameters that can be used to add the associated information to the config file declaratively from a msbuild project. Various adjustments are made to existing tests and test cases so that they will pass with the addition of ICU integration. Co-authored-by: EgorBo <[email protected]> Co-authored-by: Alexander Köplinger <[email protected]> Co-authored-by: Larry Ewing <[email protected]>
- Loading branch information
1 parent
32df157
commit 5c99007
Showing
38 changed files
with
837 additions
and
304 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
16 changes: 16 additions & 0 deletions
16
src/libraries/Common/src/Interop/Interop.TimeZoneDisplayNameType.cs
This file contains 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,16 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Globalization | ||
{ | ||
// needs to be kept in sync with TimeZoneDisplayNameType in System.Globalization.Native | ||
internal enum TimeZoneDisplayNameType | ||
{ | ||
Generic = 0, | ||
Standard = 1, | ||
DaylightSavings = 2, | ||
} | ||
} | ||
} |
This file contains 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 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
83 changes: 83 additions & 0 deletions
83
src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_static.c
This file contains 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,83 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include "pal_icushim_internal.h" | ||
#include "pal_icushim.h" | ||
#include <unicode/putil.h> | ||
#include <unicode/uversion.h> | ||
#include <unicode/localpointer.h> | ||
#include <unicode/utrace.h> | ||
|
||
static void log_icu_error(const char* name, UErrorCode status) | ||
{ | ||
const char * statusText = u_errorName(status); | ||
fprintf(stderr, "ICU call %s failed with error #%d '%s'.\n", name, status, statusText); | ||
} | ||
|
||
static void U_CALLCONV icu_trace_data(const void* context, int32_t fnNumber, int32_t level, const char* fmt, va_list args) | ||
{ | ||
char buf[1000]; | ||
utrace_vformat(buf, sizeof(buf), 0, fmt, args); | ||
printf("[ICUDT] %s: %s\n", utrace_functionName(fnNumber), buf); | ||
} | ||
|
||
#ifdef __EMSCRIPTEN__ | ||
#include <emscripten.h> | ||
|
||
EMSCRIPTEN_KEEPALIVE int32_t mono_wasm_load_icu_data(void * pData); | ||
|
||
EMSCRIPTEN_KEEPALIVE int32_t mono_wasm_load_icu_data(void * pData) | ||
{ | ||
UErrorCode status = 0; | ||
udata_setCommonData(pData, &status); | ||
|
||
if (U_FAILURE(status)) { | ||
log_icu_error("udata_setCommonData", status); | ||
return 0; | ||
} else { | ||
//// Uncomment to enable ICU tracing, | ||
//// see https://github.com/unicode-org/icu/blob/master/docs/userguide/icu_data/tracing.md | ||
// utrace_setFunctions(0, 0, 0, icu_trace_data); | ||
// utrace_setLevel(UTRACE_VERBOSE); | ||
return 1; | ||
} | ||
} | ||
#endif | ||
|
||
int32_t GlobalizationNative_LoadICU(void) | ||
{ | ||
const char* icudir = getenv("DOTNET_ICU_DIR"); | ||
if (icudir) | ||
u_setDataDirectory(icudir); | ||
else | ||
; // default ICU search path behavior will be used, see http://userguide.icu-project.org/icudata | ||
|
||
UErrorCode status = 0; | ||
UVersionInfo version; | ||
// Request the CLDR version to perform basic ICU initialization and find out | ||
// whether it worked. | ||
ulocdata_getCLDRVersion(version, &status); | ||
|
||
if (U_FAILURE(status)) { | ||
log_icu_error("ulocdata_getCLDRVersion", status); | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char* version, const char* suffix) | ||
{ | ||
// no-op for static | ||
} | ||
|
||
int32_t GlobalizationNative_GetICUVersion(void) | ||
{ | ||
UVersionInfo versionInfo; | ||
u_getVersion(versionInfo); | ||
|
||
return (versionInfo[0] << 24) + (versionInfo[1] << 16) + (versionInfo[2] << 8) + versionInfo[3]; | ||
} |
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.