Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ src/tests/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-
src/tests/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/knucleotide-input.txt text eol=lf
src/tests/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/knucleotide-input-big.txt text eol=lf
src/mono/browser/runtime/dotnet.d.ts text eol=lf
src/native/corehost/browserhost/loader/dotnet.d.ts text eol=lf
src/native/libs/Common/JavaScript/loader/dotnet.d.ts text eol=lf
1 change: 1 addition & 0 deletions eng/native.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_NET_CORE_APP_CURRENT_VERSION=$(NetCoreAppCurrentVersion)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_BUILD_LIBRARIES_CONFIGURATION=$(LibrariesConfiguration)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_BUILD_RUNTIME_CONFIGURATION=$(RuntimeConfiguration)&quot;" />
<NativeCMakeArg Include="-cmakeargs &quot;-DCMAKE_BUILD_RUNTIME_FLAVOR=$(RuntimeFlavor)&quot;" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'">
<NativeCMakeArg Include="-cmakeargs &quot;-DBUILD_LIBS_NATIVE_BROWSER=1&quot;" />
Expand Down
2 changes: 1 addition & 1 deletion src/native/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./corehost/browserhost/loader/dotnet.d.ts
./libs/Common/JavaScript/loader/dotnet.d.ts
68 changes: 40 additions & 28 deletions src/native/libs/Common/JavaScript/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,40 @@ set(ROLLUP_TS_SOURCES
"${CLR_SRC_NATIVE_DIR}/rollup.config.js"
"${CLR_SRC_NATIVE_DIR}/rollup.config.defines.js"
"${CLR_SRC_NATIVE_DIR}/rollup.config.plugins.js"

"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/libBrowserHost.footer.js"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.Utils.footer.js"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/libSystem.Native.Browser.footer.js"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js"

"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/assets.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/cross-module.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/host.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/index.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/per-module.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/host/types.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/assets.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/bootstrap.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/config.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/cross-module.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/dotnet.d.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/dotnet.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/exit.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/host-builder.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/icu.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/index.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/lib-initializers.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/logging.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/per-module.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/polyfills.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/promise-completion-source.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/run.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/loader/types.ts"
"${CLR_SRC_NATIVE_DIR}/corehost/browserhost/types.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/ems-ambient/index.ts"

"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/cross-module/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/ems-ambient/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/host/assets.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/host/cross-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/host/host.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/host/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/host/per-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/host/types.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/assets.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/bootstrap.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/config.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/cross-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/dotnet.d.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/dotnet.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/exit.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/host-builder.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/icu.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/lib-initializers.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/logging.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/per-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/polyfills.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/promise-completion-source.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/run.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/loader/types.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/per-module/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/consts.d.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/ems-ambient.ts"
Expand All @@ -55,8 +57,9 @@ set(ROLLUP_TS_SOURCES
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/node.d.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/public-api.ts"
"${CLR_SRC_NATIVE_DIR}/libs/Common/JavaScript/types/v8.d.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/diagnostics/cross-module.ts"

"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/diagnostics/console-proxy.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/diagnostics/cross-module.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/diagnostics/exit.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/diagnostics/index.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/diagnostics/per-module.ts"
Expand All @@ -79,6 +82,7 @@ set(ROLLUP_TS_SOURCES
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/runtime-list.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/strings.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Native.Browser/utils/types.ts"

"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cancelable-promise.ts"
"${CLR_SRC_NATIVE_DIR}/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts"
Expand Down Expand Up @@ -108,8 +112,6 @@ set(ROLLUP_OUTPUTS
"${STATIC_LIB_DESTINATION}/dotnet.js"
"${STATIC_LIB_DESTINATION}/dotnet.js.map"
"${STATIC_LIB_DESTINATION}/dotnet.d.ts"
"${STATIC_LIB_DESTINATION}/libBrowserHost.js"
"${STATIC_LIB_DESTINATION}/libBrowserHost.js.map"
"${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js"
"${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js.map"
"${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.Utils.js"
Expand All @@ -122,9 +124,19 @@ set(ROLLUP_OUTPUTS
"${STATIC_LIB_DESTINATION}/libSystem.Runtime.InteropServices.JavaScript.Native.js.map"
)

if(CMAKE_BUILD_RUNTIME_FLAVOR STREQUAL "CoreCLR")
LIST(APPEND ROLLUP_OUTPUTS
"${STATIC_LIB_DESTINATION}/libBrowserHost.js"
"${STATIC_LIB_DESTINATION}/libBrowserHost.js.map"
)
else()
#error TODO Mono
endif()


add_custom_command(
OUTPUT ${ROLLUP_OUTPUTS}
COMMAND npm run rollup:cmake -- "Configuration:${CMAKE_BUILD_TYPE},ProductVersion:${CMAKE_PRODUCT_VERSION},ContinuousIntegrationBuild:${CMAKE_CONTINUOUS_INTEGRATION_BUILD},StaticLibDestination:${STATIC_LIB_DESTINATION}"
COMMAND npm run rollup:cmake -- "Configuration:${CMAKE_BUILD_TYPE},ProductVersion:${CMAKE_PRODUCT_VERSION},ContinuousIntegrationBuild:${CMAKE_CONTINUOUS_INTEGRATION_BUILD},RuntimeFlavor:${CMAKE_BUILD_RUNTIME_FLAVOR},StaticLibDestination:${STATIC_LIB_DESTINATION}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.."
COMMENT "Running 'npm run rollup' to generate JavaScript bundles"
DEPENDS ${ROLLUP_TS_SOURCES}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import type { CharPtr, VfsAsset, VoidPtr, VoidPtrPtr } from "./types";
import { _ems_ } from "../../../libs/Common/JavaScript/ems-ambient";
import type { CharPtr, VfsAsset, VoidPtr, VoidPtrPtr } from "../types";
import { _ems_ } from "../ems-ambient";

import { browserVirtualAppBase, ENVIRONMENT_IS_WEB } from "./per-module";
import { browserVirtualAppBase, ENVIRONMENT_IS_WEB } from "../per-module";

const hasInstantiateStreaming = typeof WebAssembly !== "undefined" && typeof WebAssembly.instantiateStreaming === "function";
const loadedAssemblies: Map<string, { ptr: number, length: number }> = new Map();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export * from "../../../libs/Common/JavaScript/cross-module";
export * from "../cross-module";
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import type { CharPtrPtr, VoidPtr } from "./types";
import { _ems_ } from "../../../libs/Common/JavaScript/ems-ambient";
import { browserVirtualAppBase } from "./per-module";
import type { CharPtrPtr, VoidPtr } from "../types";
import { _ems_ } from "../ems-ambient";
import { browserVirtualAppBase } from "../per-module";

const HOST_PROPERTY_RUNTIME_CONTRACT = "HOST_RUNTIME_CONTRACT";
const HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES = "TRUSTED_PLATFORM_ASSEMBLIES";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import type { InternalExchange, BrowserHostExports, RuntimeAPI, BrowserHostExportsTable, LoaderConfigInternal } from "./types";
import { InternalExchangeIndex } from "./types";
import { _ems_ } from "../../../libs/Common/JavaScript/ems-ambient";
import { _ems_ } from "../ems-ambient";

import GitHash from "consts:gitHash";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export * from "../../../libs/Common/JavaScript/per-module";
export * from "../per-module";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export * from "../../../libs/Common/JavaScript/cross-module";
export * from "../cross-module";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export * from "../../../libs/Common/JavaScript/per-module";
export * from "../per-module";
12 changes: 6 additions & 6 deletions src/native/libs/Common/JavaScript/types/exchange.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import type { check, error, info, warn, debug, fastCheck, normalizeException } from "../../../../corehost/browserhost/loader/logging";
import type { resolveRunMainPromise, rejectRunMainPromise, getRunMainPromise, abortStartup } from "../../../../corehost/browserhost/loader/run";
import type { addOnExitListener, isExited, isRuntimeRunning, quitNow } from "../../../../corehost/browserhost/loader/exit";
import type { check, error, info, warn, debug, fastCheck, normalizeException } from "../loader/logging";
import type { resolveRunMainPromise, rejectRunMainPromise, getRunMainPromise, abortStartup } from "../loader/run";
import type { addOnExitListener, isExited, isRuntimeRunning, quitNow } from "../loader/exit";

import type { initializeCoreCLR } from "../../../../corehost/browserhost/host/host";
import type { instantiateWasm, installVfsFile, registerDllBytes, loadIcuData, registerPdbBytes } from "../../../../corehost/browserhost/host/assets";
import type { createPromiseCompletionSource, getPromiseCompletionSource, isControllablePromise } from "../../../../corehost/browserhost/loader/promise-completion-source";
import type { initializeCoreCLR } from "../host/host";
import type { instantiateWasm, installVfsFile, registerDllBytes, loadIcuData, registerPdbBytes } from "../host/assets";
import type { createPromiseCompletionSource, getPromiseCompletionSource, isControllablePromise } from "../loader/promise-completion-source";

import type { isSharedArrayBuffer, zeroRegion } from "../../../System.Native.Browser/utils/memory";
import type { stringToUTF16, stringToUTF16Ptr, stringToUTF8, stringToUTF8Ptr, utf16ToString } from "../../../System.Native.Browser/utils/strings";
Expand Down
4 changes: 2 additions & 2 deletions src/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"scripts": {
"rollup:stub": "node rollup.stub.js",
"rollup:cmake": "rollup -c --environment ",
"rollup:release": "rollup -c --environment Configuration:Release,ProductVersion:11.0,ContinuousIntegrationBuild:false",
"rollup:debug": "rollup -c --environment Configuration:Debug,ProductVersion:11.0,ContinuousIntegrationBuild:false",
"rollup:release": "rollup -c --environment Configuration:Release,ProductVersion:11.0,ContinuousIntegrationBuild:false,RuntimeFlavor:CoreCLR",
"rollup:debug": "rollup -c --environment Configuration:Debug,ProductVersion:11.0,ContinuousIntegrationBuild:false,RuntimeFlavor:CoreCLR",
"lint": "eslint --no-color --max-warnings=0 \"./**/*.ts\" \"./**/*.js\"",
"format": "eslint --fix \"./**/*.ts\" \"./*.js\""
},
Expand Down
4 changes: 3 additions & 1 deletion src/native/rollup.config.defines.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ if (process.env.ProductVersion === undefined) {
}

export const configuration = process.env.Configuration !== "Release" && process.env.Configuration !== "RELEASE" ? "Debug" : "Release";
export const runtimeFlavor = process.env.RuntimeFlavor || "CoreCLR";
export const productVersion = process.env.ProductVersion;
export const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === "true" ? true : false;
export const staticLibDestination = process.env.StaticLibDestination || `../../artifacts/obj/native/net${productVersion}-browser-${configuration}-wasm/lib`;

console.log(`Rollup configuration: Configuration=${configuration}, ProductVersion=${productVersion}, ContinuousIntegrationBuild=${isContinuousIntegrationBuild}`);
console.log(`Rollup configuration: Configuration=${configuration}, RuntimeFlavor=${runtimeFlavor}, ProductVersion=${productVersion}, ContinuousIntegrationBuild=${isContinuousIntegrationBuild}`);

export const banner = "//! Licensed to the .NET Foundation under one or more agreements.\n//! The .NET Foundation licenses this file to you under the MIT license.\n//! This is generated file, see src/native/rollup.config.js\n\n";
export const banner_dts = banner + "//! This is not considered public API with backward compatibility guarantees. \n";
Expand Down Expand Up @@ -49,6 +50,7 @@ try {
export const envConstants = {
productVersion,
configuration,
runtimeFlavor,
gitHash,
isContinuousIntegrationBuild,
};
Expand Down
7 changes: 4 additions & 3 deletions src/native/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
isDebug, staticLibDestination,
keep_classnames, keep_fnames, reserved,
inlinefastCheck,
runtimeFlavor,
} from "./rollup.config.defines.js";
import { terserPlugin, writeOnChangePlugin, consts, onwarn, alwaysLF, iife2fe, emsAmbient, regexReplace, sourcemapPathTransform } from "./rollup.config.plugins.js";
import { promises as fs } from "fs";
Expand All @@ -25,7 +26,7 @@ const dotnetDTS = {
},
...(isDebug ? [{
format: "es",
file: "./corehost/browserhost/loader/dotnet.d.ts",
file: "./libs/Common/JavaScript/loader/dotnet.d.ts",
banner: banner_dts,
plugins: [alwaysLF(), writeOnChangePlugin()],
}] : [])
Expand All @@ -36,7 +37,7 @@ const dotnetDTS = {
};

const dotnetJS = configure({
input: "./corehost/browserhost/loader/dotnet.ts",
input: "./libs/Common/JavaScript/loader/dotnet.ts",
output: [{
file: staticLibDestination + "/dotnet.js",
intro: "/*! bundlerFriendlyImports */",
Expand Down Expand Up @@ -141,7 +142,7 @@ const libInteropJavaScriptNative = configure({
});

const libBrowserHost = configure({
input: "./corehost/browserhost/host/index.ts",
input: "./libs/Common/JavaScript/host/index.ts",
output: [{
name: "libBrowserHost",
format: "iife",
Expand Down
Loading