Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WASM] Converting runtime JS to TS #55871

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d319055
Converted JS to TS and made build work
Daniel-Genkin Jul 16, 2021
f53ea70
cleanup
Daniel-Genkin Jul 17, 2021
f4515f5
split up glueForTSC
Daniel-Genkin Jul 17, 2021
797ece8
cleanup of markdown and formatting
Daniel-Genkin Jul 17, 2021
7ea904d
added tsc step to linux build
Jul 17, 2021
536962e
+ renamed build folder to bin
Daniel-Genkin Jul 19, 2021
d9ef3b4
Updated ci ubuntu image version
Daniel-Genkin Jul 19, 2021
48e1ec2
Merge branch 'wasm_ts' of https://github.com/Daniel-Genkin/runtime in…
Daniel-Genkin Jul 19, 2021
63631d1
replaced most `this` with the corresponding namespace to help tsc tra…
Daniel-Genkin Jul 19, 2021
dc7523e
addressed PR comments
Daniel-Genkin Jul 20, 2021
b9c909f
replaced hardcoded numbers with enums + fixed tsc exit code 1 error
Daniel-Genkin Jul 20, 2021
6bdfd80
Added a TON of types to binding-suppoprt.ts + Fixed windows build on CI
Daniel-Genkin Jul 20, 2021
5d329ab
Added a TON of types to library-mono.ts
Daniel-Genkin Jul 21, 2021
500962e
More types
Daniel-Genkin Jul 21, 2021
1a0bead
A bit more types + fix for windows ci build failure
Daniel-Genkin Jul 21, 2021
0d35bb1
Added more types
Daniel-Genkin Jul 22, 2021
a57bd53
Added more types
Daniel-Genkin Jul 22, 2021
3306d9b
Merge branch 'main' of https://github.com/dotnet/runtime into wasm_ts
Daniel-Genkin Jul 23, 2021
e93c8f5
Addressed PR comments
Daniel-Genkin Jul 26, 2021
359856e
Added typescript to windows build (Thanks Radek)
Daniel-Genkin Jul 26, 2021
b2debaf
Merge branch 'main' of https://github.com/dotnet/runtime into wasm_ts
Daniel-Genkin Jul 29, 2021
380cfa2
Slightly better type for function
Daniel-Genkin Jul 29, 2021
00898d9
Merge branch 'main' of https://github.com/dotnet/runtime into wasm_ts
Daniel-Genkin Jul 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/workflow/building/libraries/webassembly-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ On Linux and macOS:
export EMSDK_PATH=<FULL_PATH_TO_SDK_INSTALL>/emsdk
```

## Installing TypeScript

To build the repo you will need to have the TypeScript `tsc` compiler installed globally. The easiest way to do this is to run `npm i -g typescript`. Learn more [here](https://www.typescriptlang.org/id/download).

Also note that `NPM` and `NodeJS` come bundled with `EMSDK` so if you do not want to install these tools you can just add add the ones in `src/mono/wasm/emsdk` to your PATH.

## Building everything

At this time no other build dependencies are necessary to start building for WebAssembly.
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
targetRid: browser-wasm
platform: Browser_wasm
container:
image: ubuntu-18.04-webassembly-20210531091624-f5c7a43
image: ubuntu-18.04-webassembly-20210719180238-880fd01
registry: mcr
jobParameters:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@
<PlatformManifestFileEntry Include="icudt_EFIGS.dat" IsNative="true" />
<PlatformManifestFileEntry Include="icudt_optimal.dat" IsNative="true" />
<PlatformManifestFileEntry Include="icudt_optimal_no_CJK.dat" IsNative="true" />
<PlatformManifestFileEntry Include="binding_support.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet_support.js" IsNative="true" />
<PlatformManifestFileEntry Include="library_mono.js" IsNative="true" />
<PlatformManifestFileEntry Include="binding-support.js" IsNative="true" />
<PlatformManifestFileEntry Include="dotnet-support.js" IsNative="true" />
<PlatformManifestFileEntry Include="library-mono.js" IsNative="true" />
radical marked this conversation as resolved.
Show resolved Hide resolved
<PlatformManifestFileEntry Include="pal_random.js" IsNative="true" />
<PlatformManifestFileEntry Include="corebindings.c" IsNative="true" />
<PlatformManifestFileEntry Include="driver.c" IsNative="true" />
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
!Makefile
.stamp-wasm-install-and-select*
emsdk
runtime/build
9 changes: 6 additions & 3 deletions src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ $(NATIVE_BIN_DIR)/include/wasm:
$(BUILDS_OBJ_DIR):
mkdir -p $$@

$(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o runtime/library_mono.js runtime/binding_support.js runtime/dotnet_support.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(2) $(EMCC_DEFAULT_RSP) | $(NATIVE_BIN_DIR)
$(EMCC) @$(EMCC_DEFAULT_RSP) $(1) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o $(2) -o $(NATIVE_BIN_DIR)/dotnet.js $(3)
$(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o runtime/bin/library-mono.js runtime/bin/binding-support.js runtime/bin/dotnet-support.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(2) $(EMCC_DEFAULT_RSP) | $(NATIVE_BIN_DIR)
$(EMCC) @$(EMCC_DEFAULT_RSP) $(1) --js-library runtime/bin/library-mono.js --js-library runtime/bin/binding-support.js --js-library runtime/bin/dotnet-support.js --js-library $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o $(2) -o $(NATIVE_BIN_DIR)/dotnet.js $(3)

$(BUILDS_OBJ_DIR)/pinvoke-table.h: $(PINVOKE_TABLE) | $(BUILDS_OBJ_DIR)
if cmp -s $(PINVOKE_TABLE) $$@ ; then : ; else cp $(PINVOKE_TABLE) $$@ ; fi
Expand Down Expand Up @@ -141,7 +141,7 @@ clean:
icu-files: $(wildcard $(ICU_LIBDIR)/*.dat) $(ICU_LIBDIR)/libicuuc.a $(ICU_LIBDIR)/libicui18n.a | $(NATIVE_BIN_DIR)
cp $^ $(NATIVE_BIN_DIR)

source-files: runtime/driver.c runtime/pinvoke.c runtime/corebindings.c runtime/binding_support.js runtime/dotnet_support.js runtime/library_mono.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js | $(NATIVE_BIN_DIR)/src
source-files: runtime/driver.c runtime/pinvoke.c runtime/corebindings.c runtime/bin/binding-support.js runtime/bin/dotnet-support.js runtime/bin/library-mono.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js | $(NATIVE_BIN_DIR)/src
cp $^ $(NATIVE_BIN_DIR)/src

header-files: runtime/pinvoke.h | $(NATIVE_BIN_DIR)/include/wasm
Expand Down Expand Up @@ -203,3 +203,6 @@ build-dbg-proxy:
$(DOTNET) build $(TOP)/src/mono/wasm/debugger/BrowserDebugHost $(MSBUILD_ARGS)
build-dbg-testsuite:
$(DOTNET) build $(TOP)/src/mono/wasm/debugger/DebuggerTestSuite $(MSBUILD_ARGS)

build-js-from-ts:
tsc -p $(TOP)/src/mono/wasm/runtime/
2 changes: 1 addition & 1 deletion src/mono/wasm/debugger/DebuggerTestSuite/ArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public async Task InvalidArrayId() => await CheckInspectLocalsAtBreakpointSite(

// Trying to access object as an array
if (!DotnetObjectId.TryParse(c_obj_id, out var id) || id.Scheme != "object")
Assert.True(false, "Unexpected object id format. Maybe this test is out of sync with the object id format in library_mono.js?");
Assert.True(false, "Unexpected object id format. Maybe this test is out of sync with the object id format in library-mono.ts?");

if (!int.TryParse(id.Value, out var idNum))
Assert.True(false, "Expected a numeric value part of the object id: {c_obj_id}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ internal async Task<JToken> GetProperties(string id, JToken fn_args = null, bool
return null;

var locals = frame_props.Value["result"];
// FIXME: Should be done when generating the list in library_mono.js, but not sure yet
// FIXME: Should be done when generating the list in library-mono.ts, but not sure yet
// whether to remove it, and how to do it correctly.
if (locals is JArray)
{
Expand Down
Loading