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.
[wasm] updated samples for ES6 and CJS (dotnet#62292)
* samples for ES6 and CJS * hack for in-tree linking * binlog for samples
- Loading branch information
1 parent
6a9bfee
commit 64649da
Showing
36 changed files
with
315 additions
and
94 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
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,11 @@ | ||
TOP=../../../../.. | ||
|
||
include ../wasm.mk | ||
|
||
ifneq ($(AOT),) | ||
override MSBUILD_ARGS+=/p:RunAOTCompilation=true | ||
endif | ||
|
||
PROJECT_NAME=Wasm.Browser.ES6.Sample.csproj | ||
|
||
run: run-browser |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import createDotnetRuntime from './dotnet.js' | ||
|
||
const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime((api) => ({ | ||
disableDotnet6Compatibility: true, | ||
configSrc: "./mono-config.json", | ||
onAbort: () => { | ||
wasm_exit(1); | ||
}, | ||
})); | ||
|
||
function wasm_exit(exit_code) { | ||
/* Set result in a tests_done element, to be read by xharness in runonly CI test */ | ||
const tests_done_elem = document.createElement("label"); | ||
tests_done_elem.id = "tests_done"; | ||
tests_done_elem.innerHTML = exit_code.toString(); | ||
document.body.appendChild(tests_done_elem); | ||
|
||
console.log(`WASM EXIT ${exit_code}`); | ||
} | ||
|
||
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.ES6.Sample] Sample.Test:TestMeaning"); | ||
const ret = testMeaning(); | ||
document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`; | ||
try { | ||
const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime(); | ||
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.ES6.Sample] Sample.Test:TestMeaning"); | ||
const ret = testMeaning(); | ||
document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`; | ||
console.debug(`ret: ${ret}`); | ||
|
||
console.debug(`ret: ${ret}`); | ||
let exit_code = ret == 42 ? 0 : 1; | ||
wasm_exit(exit_code); | ||
let exit_code = await MONO.mono_run_main("Wasm.Browser.ES6.Sample.dll", []); | ||
wasm_exit(exit_code); | ||
} catch (err) { | ||
console.log(`WASM ERROR ${err}`); | ||
wasm_exit(2); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/mono/sample/wasm/browser-legacy/Wasm.Browser.LegacySample.csproj
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
4 changes: 2 additions & 2 deletions
4
...e/wasm/browser/Wasm.Browser.Sample.csproj → ...sm/browser/Wasm.Browser.CJS.Sample.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
function wasm_exit(exit_code) { | ||
/* Set result in a tests_done element, to be read by xharness in runonly CI test */ | ||
const tests_done_elem = document.createElement("label"); | ||
tests_done_elem.id = "tests_done"; | ||
tests_done_elem.innerHTML = exit_code.toString(); | ||
document.body.appendChild(tests_done_elem); | ||
|
||
"use strict"; | ||
console.log(`WASM EXIT ${exit_code}`); | ||
} | ||
|
||
createDotnetRuntime(({ MONO, BINDING, Module }) => ({ | ||
disableDotnet6Compatibility: true, | ||
configSrc: "./mono-config.json", | ||
onDotnetReady: () => { | ||
try { | ||
App.init({ MONO, BINDING, Module }); | ||
} catch (error) { | ||
set_exit_code(1, error); | ||
throw (error); | ||
} | ||
}, | ||
onAbort: (error) => { | ||
set_exit_code(1, error); | ||
}, | ||
})); | ||
async function loadRuntime() { | ||
globalThis.exports = {}; | ||
await import("./dotnet.js"); | ||
return globalThis.exports.createDotnetRuntime; | ||
} | ||
|
||
async function main() { | ||
try { | ||
const createDotnetRuntime = await loadRuntime(); | ||
const { MONO, BINDING, Module, RuntimeBuildInfo } = await createDotnetRuntime(() => ({ | ||
disableDotnet6Compatibility: true, | ||
configSrc: "./mono-config.json", | ||
})); | ||
|
||
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.CJS.Sample] Sample.Test:TestMeaning"); | ||
const ret = testMeaning(); | ||
document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`; | ||
|
||
console.debug(`ret: ${ret}`); | ||
let exit_code = ret == 42 ? 0 : 1; | ||
wasm_exit(exit_code); | ||
} catch (err) { | ||
console.log(`WASM ERROR ${err}`); | ||
wasm_exit(2) | ||
} | ||
} | ||
|
||
main(); |
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 @@ | ||
TOP=../../../../.. | ||
|
||
include ../wasm.mk | ||
|
||
ifneq ($(AOT),) | ||
override MSBUILD_ARGS+=/p:RunAOTCompilation=true | ||
endif | ||
|
||
ifneq ($(V),) | ||
DOTNET_MONO_LOG_LEVEL=--setenv=MONO_LOG_LEVEL=debug | ||
endif | ||
|
||
PROJECT_NAME=Wasm.Console.CJS.Sample.csproj | ||
CONSOLE_DLL=Wasm.Console.CJS.Sample.dll | ||
|
||
run: run-console |
Oops, something went wrong.