diff options
author | Kenneth Pouncey <kjpou@pt.lu> | 2020-04-04 14:37:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-04 14:37:21 +0300 |
commit | eb468076a79982568e3bc66ae236fa1d2949ee1d (patch) | |
tree | 9cec5a97f9a73123b87b3af9c80d1ff2974bfd7d /sdks/wasm/runtime-tests.js | |
parent | b3210bf1e5cddb78c0b78c365e8587ceab774e51 (diff) |
[wasm] Wasm TimeZoneInfo implementation VFS (#17760)
* [wasm][bcl] TimeZoneInfo implementation for WebAssembly to read from WASM VFS `/zoneinfo`.
- Remove `TimeZoneInfo.WebAssembly.cs` file
- Remove source dependencies on `TimeZoneInfo.WebAssembly.cs`.
- Modify TimeZoneInfo for specific WASM functionality
- Default root directory is `zoneinfo`
- Add icall `mono_timezone_get_local_name` for WASM in CreateLocal
- Add icall implementation
- ves_icall_System_TimeZoneInfo_mono_timezone_get_local_name
* [wasm][build] Add `-s FORCE_FILESYSTEM=1` to mono wasm runtime build
- Required so that it includes support for loading pre preload packages
Message when generating the zoneinfo data.
> Remember to build the main file with -s FORCE_FILESYSTEM=1 so that it includes support for loading this file package
* [wasm] zoneinfo data and support files.
- Three files for zoneinfo VFS support.
- `mono-webassembly-zoneinfo-fs-smd.js.metadata` - This is the separate metadata output by emscripten file-packager. Used to parse the zoneinfo data in non browser environments. See `runtime-tests.js`
- `mono-webassembly-zoneinfo-fs.js` - Output by emscripten file-packager that will be referenced by browser environments to load the zoneinfo data into the VFS at `/zoneinfo`
- `zoneinfo.data` - The binary file output by emscripten file-packager. The file contains the actual zoneinfo data loaded into the VFS and parsed by `TimeZoneInfo`.
* [wasm][driver] Add backing support for icall `mono_timezone_get_local_name`
* Add TimeZone info test.
* [wasm][packger] Add `-s FORCE_FILESYSTEM=1`
- Required so that it includes support for loading preload packages
Message when generating the zoneinfo data.
> Remember to build the main file with -s FORCE_FILESYSTEM=1 so that it includes support for loading this file package
* Fix AOT tzd test
* Remove commented code lines for `TimeZoneInfo.WebAssembly.cs` module
* Regenerated zone info without --no-heap-copy as it causes problems. This will create a warning in browser for now.
* Add zoneinfo support files to package
* Fix TimeZoneInfo tests to use the `--enable-fs` packager parameter
* Add back icall implementation after rebase
- ves_icall_System_TimeZoneInfo_mono_timezone_get_local_name
* Add back backing support for icall `mono_timezone_get_local_name` after rebase
* Fix build error
* Add back zoneinfo tests to Makefile after rebase
* Fix packager zoneinfo sample builds.
* Address review comment about volatile not needed
* Address review comment about volatile not needed
* Address review comment about volatile not needed
* Address review comment volatile not needed
Diffstat (limited to 'sdks/wasm/runtime-tests.js')
-rw-r--r-- | sdks/wasm/runtime-tests.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/sdks/wasm/runtime-tests.js b/sdks/wasm/runtime-tests.js index 7f3504a76e4..c42dff199b0 100644 --- a/sdks/wasm/runtime-tests.js +++ b/sdks/wasm/runtime-tests.js @@ -99,6 +99,7 @@ profilers = []; setenv = {}; runtime_args = []; enable_gc = false; +enable_zoneinfo = false; while (true) { if (args [0].startsWith ("--profile=")) { var arg = args [0].substring ("--profile=".length); @@ -120,6 +121,9 @@ while (true) { } else if (args [0] == "--enable-gc") { enable_gc = true; args = args.slice (1); + } else if (args [0] == "--enable-zoneinfo") { + enable_zoneinfo = true; + args = args.slice (1); } else { break; } @@ -154,7 +158,40 @@ var Module = { var f = Module.cwrap ('mono_wasm_enable_on_demand_gc', 'void', []); f (); } - + if (enable_zoneinfo) { + // Load the zoneinfo data into the VFS rooted at /zoneinfo + FS.mkdir("zoneinfo"); + Module['FS_createPath']('/', 'zoneinfo', true, true); + Module['FS_createPath']('/zoneinfo', 'Indian', true, true); + Module['FS_createPath']('/zoneinfo', 'Atlantic', true, true); + Module['FS_createPath']('/zoneinfo', 'US', true, true); + Module['FS_createPath']('/zoneinfo', 'Brazil', true, true); + Module['FS_createPath']('/zoneinfo', 'Pacific', true, true); + Module['FS_createPath']('/zoneinfo', 'Arctic', true, true); + Module['FS_createPath']('/zoneinfo', 'America', true, true); + Module['FS_createPath']('/zoneinfo/America', 'Indiana', true, true); + Module['FS_createPath']('/zoneinfo/America', 'Argentina', true, true); + Module['FS_createPath']('/zoneinfo/America', 'Kentucky', true, true); + Module['FS_createPath']('/zoneinfo/America', 'North_Dakota', true, true); + Module['FS_createPath']('/zoneinfo', 'Australia', true, true); + Module['FS_createPath']('/zoneinfo', 'Etc', true, true); + Module['FS_createPath']('/zoneinfo', 'Asia', true, true); + Module['FS_createPath']('/zoneinfo', 'Antarctica', true, true); + Module['FS_createPath']('/zoneinfo', 'Europe', true, true); + Module['FS_createPath']('/zoneinfo', 'Mexico', true, true); + Module['FS_createPath']('/zoneinfo', 'Africa', true, true); + Module['FS_createPath']('/zoneinfo', 'Chile', true, true); + Module['FS_createPath']('/zoneinfo', 'Canada', true, true); + var zoneInfoData = read ('zoneinfo.data', 'binary'); + var metadata = JSON.parse(read ("mono-webassembly-zoneinfo-fs-smd.js.metadata", 'utf-8')); + var files = metadata.files; + for (var i = 0; i < files.length; ++i) { + var byteArray = zoneInfoData.subarray(files[i].start, files[i].end); + var stream = FS.open(files[i].filename, 'w+'); + FS.write(stream, byteArray, 0, byteArray.length, 0); + FS.close(stream); + } + } MONO.mono_load_runtime_and_bcl ( config.vfs_prefix, config.deploy_prefix, |