diff --git a/eng/Subsets.props b/eng/Subsets.props index 5f592075c54e3f..e640315cd389d3 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -109,7 +109,6 @@ clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools clr.native+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools - mono.emsdk+clr.native+clr.corelib+clr.tools+clr.packages+clr.crossarchtools clr.iltools+clr.packages @@ -365,7 +364,7 @@ The cross tools are used as part of the build process with the downloaded build tools, so we need to build them for the host architecture and build them as unsanitized binaries. --> - <_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '') and '$(TargetsWasm)' != 'true'">true + <_BuildAnyCrossArch Condition="('$(CrossBuild)' == 'true' or '$(BuildArchitecture)' != '$(TargetArchitecture)' or '$(HostOS)' != '$(TargetOS)' or '$(EnableNativeSanitizers)' != '') and '$(TargetArchitecture)' != 'wasm'">true <_BuildCrossComponents Condition="$(_subset.Contains('+clr.crossarchtools+'))">true <_BuildCrossComponents Condition="'$(ClrRuntimeBuildSubsets)' != '' and ('$(PrimaryRuntimeFlavor)' == 'CoreCLR' or '$(TargetsMobile)' == 'true')">true <_CrossBitwidthBuild Condition="'$(BuildArchitecture)' == 'x64' and ('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'arm')">true diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 42286b14088848..f782005ed54140 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -23,6 +23,7 @@ $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'sharedFramework')) + $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'corehost')) $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'ilc-published')) $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'ilc')) $([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'aotsdk')) @@ -214,7 +215,20 @@ $(LibrariesNativeArtifactsPath)*.dex; $(LibrariesNativeArtifactsPath)*.jar;" IsNative="true" /> - + + + - + + + + + <_RuntimeVariant /> + <_RuntimeVariant Condition="'$(WasmEnableThreads)' == 'true'">-threads + + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != '' and '$(TargetsWasm)' == 'true'">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native + <_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != '' and '$(TargetsWasm)' == 'true'">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) + + + + + + + + + + diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 2bc06d83bc8495..02d85086ab70f9 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -78,7 +78,8 @@ else() set(GEN_PINVOKE 0) # WASM-TODO should we start using System.Native.Browser and System.Runtime.InteropServices.JavaScript.Native also for Mono ? set(BUILD_LIBS_NATIVE_BROWSER 1) - add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost browserhost) + set(STATIC_LIB_DESTINATION ${CMAKE_BINARY_DIR}/libs-native) + add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost corehost) add_dependencies(runtime browserhost) endif() endif() diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 7f497cd6f3a00b..504ffc0c881e4b 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -265,6 +265,8 @@ endif(CLR_CMAKE_TARGET_WIN32) # add the install targets if(NOT CLR_CMAKE_HOST_ARCH_WASM) install_clr(TARGETS coreclr DESTINATIONS . sharedFramework COMPONENT runtime) +else() + install_clr(TARGETS coreclr_static DESTINATIONS . sharedFramework COMPONENT runtime) endif(NOT CLR_CMAKE_HOST_ARCH_WASM) if(CLR_CMAKE_HOST_MACCATALYST OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_ARCH_WASM) diff --git a/src/coreclr/gcinfo/CMakeLists.txt b/src/coreclr/gcinfo/CMakeLists.txt index b809dac02f086a..a652648f32a689 100644 --- a/src/coreclr/gcinfo/CMakeLists.txt +++ b/src/coreclr/gcinfo/CMakeLists.txt @@ -92,4 +92,5 @@ endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX) if (CLR_CMAKE_TARGET_ARCH_WASM) create_gcinfo_lib(TARGET gcinfo_unix_wasm OS browser ARCH wasm) + install_clr(TARGETS gcinfo_unix_wasm DESTINATIONS sharedFramework COMPONENT runtime) endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index f41afefcd30fc0..cec25ae3312fcb 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -53,7 +53,7 @@ else() target_link_libraries(corerun PRIVATE coreclr_static System.Native-Static - System.Native.TimeZoneData) + System.Native.TimeZoneData.Invariant) # linker options for NodeJs, link in JavaScript helper, access to local filesystem if (CLR_CMAKE_TARGET_BROWSER) target_compile_options(corerun PRIVATE @@ -63,9 +63,9 @@ else() target_link_libraries(corerun PRIVATE System.Native.Browser-Static) set(JS_SYSTEM_NATIVE_BROWSER - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js") + "${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js") set(JS_SYSTEM_BROWSER_UTILS - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js") + "${STATIC_LIB_DESTINATION}/libSystem.Browser.Utils.js") set(JS_CORE_RUN_PRE "${CMAKE_CURRENT_SOURCE_DIR}/wasm/libCorerun.pre.js") set_target_properties(corerun PROPERTIES diff --git a/src/coreclr/minipal/Unix/CMakeLists.txt b/src/coreclr/minipal/Unix/CMakeLists.txt index baa9c41161813a..31528782153f54 100644 --- a/src/coreclr/minipal/Unix/CMakeLists.txt +++ b/src/coreclr/minipal/Unix/CMakeLists.txt @@ -14,3 +14,7 @@ add_library(coreclrminipal ) target_link_libraries(coreclrminipal PRIVATE minipal) + +if (CLR_CMAKE_TARGET_ARCH_WASM) + install_clr(TARGETS coreclrminipal DESTINATIONS sharedFramework COMPONENT runtime) +endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/nativeresources/CMakeLists.txt b/src/coreclr/nativeresources/CMakeLists.txt index 7dba113d91ea3b..7d9dc018f5d374 100644 --- a/src/coreclr/nativeresources/CMakeLists.txt +++ b/src/coreclr/nativeresources/CMakeLists.txt @@ -11,3 +11,7 @@ add_library_clr(nativeresourcestring ) install_clr (TARGETS nativeresourcestring DESTINATIONS lib) + +if (CLR_CMAKE_TARGET_ARCH_WASM) + install_clr(TARGETS nativeresourcestring DESTINATIONS sharedFramework COMPONENT runtime) +endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index ac17e9a6c885e9..ac22c0d1924263 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -361,3 +361,7 @@ endif(FEATURE_EVENT_TRACE) # Install the static PAL library for VS install_clr (TARGETS coreclrpal DESTINATIONS lib) + +if (CLR_CMAKE_TARGET_ARCH_WASM) + install_clr(TARGETS coreclrpal DESTINATIONS sharedFramework COMPONENT runtime) +endif (CLR_CMAKE_TARGET_ARCH_WASM) diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index f0bef340c0d06e..d70f30b12ec4f2 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -4,20 +4,16 @@ <_BuildNativeTargetOS>$(TargetOS) <_BuildNativeTargetOS Condition="'$(TargetsLinuxBionic)' == 'true'">linux-bionic true - - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != '' and '$(TargetsBrowser)' == 'true'">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native - <_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != ''">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) - - + - + @@ -54,8 +50,6 @@ <_CoreClrBuildArg Condition="'$(BuildSubdirectory)' != ''" Include="-subdir $(BuildSubdirectory)" /> <_CoreClrBuildArg Include="-cmakeargs "-DCLR_DOTNET_HOST_PATH=$(DOTNET_HOST_PATH)"" /> <_CoreClrBuildArg Condition="'$(HasCdacBuildTool)' == 'true'" Include="-cmakeargs "-DCDAC_BUILD_TOOL_BINARY_PATH=$(RuntimeBinDir)cdac-build-tool\cdac-build-tool.dll"" /> - <_CoreClrBuildArg Condition="'$(_IcuDir)' != ''" Include="-cmakeargs "-DCMAKE_ICU_DIR=$(_IcuDir)"" /> - <_CoreClrBuildArg Condition="'$(_TzdDir)' != ''" Include="-cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)"" /> <_CoreClrBuildArg Condition="'$(FeatureXplatEventSource)' == 'false'" Include="-cmakeargs "-DFEATURE_EVENTSOURCE_XPLAT=0"" /> @@ -112,7 +106,7 @@ <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh - <_CoreClrBuildCommand>"$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)" @(_CoreClrBuildArg, ' ') + <_CoreClrBuildCommand>"$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)" @(_CoreClrBuildArg, ' ') @(NativeCMakeArg, ' ') diff --git a/src/libraries/externals.csproj b/src/libraries/externals.csproj index e207c88bf99da1..d689529b137efa 100644 --- a/src/libraries/externals.csproj +++ b/src/libraries/externals.csproj @@ -24,7 +24,7 @@ Version="$(MicrosoftDiaSymReaderNativeVersion)" /> - + <_HostSymbols Include="$(DotNetHostBinDir)$(LibPrefix)hostfxr$(LibSuffix)$(SymbolsSuffix)" /> diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index 375d17c3cb9257..b0a8a79d6fc6e2 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -2,14 +2,45 @@ # The .NET Foundation licenses this file to you under the MIT license. project(browserhost) -set(DOTNET_PROJECT_NAME "browserhost") +set(DOTNET_PROJECT_NAME "BrowserHost-Static") + +# the host library -configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) -target_include_directories(hostmisc_interface INTERFACE ${GENERATED_INCLUDE_DIR}/corehost) +include(configure.cmake) -set(SOURCES +set(BROWSERHOST_STATIC_SOURCES + ./config.h ./browserhost.cpp - native.rc + ../native.rc +) + +add_compile_definitions(FEATURE_APPHOST) +add_definitions(-DFEATURE_APPHOST=1) +add_definitions(-DFEATURE_STATIC_HOST=1) + +add_library(BrowserHost-Static + STATIC + ${BROWSERHOST_STATIC_SOURCES} +) +set_target_properties(BrowserHost-Static PROPERTIES OUTPUT_NAME BrowserHost CLEAN_DIRECT_OUTPUT 1) + +target_compile_options(BrowserHost-Static PRIVATE + -fwasm-exceptions + -msimd128 + ) +target_link_libraries(BrowserHost-Static PRIVATE + hostmisc +) + +install(TARGETS BrowserHost-Static DESTINATION corehost COMPONENT runtime) +install(TARGETS BrowserHost-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS BrowserHost-Static DESTINATION sharedFramework COMPONENT runtime) + +# the executable +set(DOTNET_PROJECT_NAME "browserhost") + +set(BROWSERHOST_SOURCES + empty.c ) set(HEADERS ) @@ -18,19 +49,13 @@ add_compile_definitions(FEATURE_APPHOST) add_definitions(-DFEATURE_APPHOST=1) add_definitions(-DFEATURE_STATIC_HOST=1) -add_executable(browserhost ${SOURCES}) +add_executable(browserhost ${BROWSERHOST_SOURCES}) set_target_properties(browserhost PROPERTIES OUTPUT_NAME dotnet.native) set(CMAKE_EXECUTABLE_SUFFIX ".js") -add_dependencies(browserhost System.Native.Browser-Rollup) -add_dependencies(browserhost System.Native.Browser-Static) -add_dependencies(browserhost System.Runtime.InteropServices.JavaScript.Native-Static) - -install(TARGETS browserhost DESTINATION corehost COMPONENT runtime) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dotnet.native.wasm DESTINATION corehost COMPONENT runtime) - -include(configure.cmake) LIST(APPEND NATIVE_LIBS + hostmisc + clrinterpreter coreclr_static System.Native.Browser-Static System.Runtime.InteropServices.JavaScript.Native-Static @@ -44,21 +69,14 @@ LIST(APPEND NATIVE_LIBS System.Native.TimeZoneData ) -# WASM-TODO set(RUNTIMEINFO_LIB runtimeinfo) - -target_compile_options(browserhost PRIVATE - -fwasm-exceptions - -msimd128 - ) - set(JS_SYSTEM_NATIVE_BROWSER - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js") + "${STATIC_LIB_DESTINATION}/libSystem.Native.Browser.js") set(JS_SYSTEM_BROWSER_UTILS - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js") + "${STATIC_LIB_DESTINATION}/libSystem.Browser.Utils.js") set(JS_SYSTEM_RUNTIME_INTEROPSERVICES_JAVASCRIPT_NATIVE - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js") + "${STATIC_LIB_DESTINATION}/libSystem.Runtime.InteropServices.JavaScript.Native.js") set(JS_BROWSER_HOST - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js") + "${STATIC_LIB_DESTINATION}/libBrowserHost.js") set(JS_SYSTEM_NATIVE_BROWSER_EXPOST "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/System.Native.Browser/libSystem.Native.Browser.extpost.js") @@ -67,6 +85,11 @@ set_target_properties(browserhost PROPERTIES LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_SYSTEM_RUNTIME_INTEROPSERVICES_JAVASCRIPT_NATIVE} --js-library ${JS_BROWSER_HOST} --extern-post-js ${JS_SYSTEM_NATIVE_BROWSER_EXPOST}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +target_compile_options(browserhost PRIVATE + -fwasm-exceptions + -msimd128 + ) + if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) target_link_options(browserhost PRIVATE # -sVERBOSE @@ -97,16 +120,18 @@ target_link_options(browserhost PRIVATE -Wno-unused-command-line-argument -Wl,-error-limit=0) -target_link_libraries( - browserhost - PRIVATE - hostmisc - clrinterpreter +target_link_libraries(browserhost PUBLIC + BrowserHost-Static +) +target_link_libraries(browserhost PRIVATE ${NATIVE_LIBS} - - ${START_WHOLE_ARCHIVE} + ${START_WHOLE_ARCHIVE} ${RUNTIMEINFO_LIB} ${END_WHOLE_ARCHIVE} ) +install(TARGETS browserhost DESTINATION corehost COMPONENT runtime) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dotnet.native.wasm DESTINATION corehost COMPONENT runtime) +install(FILES ${CLR_SRC_NATIVE_DIR}/package.json DESTINATION corehost COMPONENT runtime) + add_subdirectory(sample) diff --git a/src/native/corehost/browserhost/ReadMe.md b/src/native/corehost/browserhost/ReadMe.md index 966f5693ebd485..c84b888122e964 100644 --- a/src/native/corehost/browserhost/ReadMe.md +++ b/src/native/corehost/browserhost/ReadMe.md @@ -16,14 +16,15 @@ It's **JavaScript ES6 module** Implements native part of the CoreCLR host and exposes it as an internal JavaScript interface to the loader. It is **Emscripten application** statically linked from libraries. -- `host/index.ts` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` -- `libBrowserHost.footer.js` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` - `libSystem.Native.Browser.js` linked -> `dotnet.native.js` - `libSystem.Browser.Utils.js` linked -> `dotnet.native.js` - `libSystem.Runtime.InteropServices.JavaScript.Native.js` linked -> `dotnet.native.js` -- `browserhost.cpp` compiled + linked -> `dotnet.native.wasm` - `libSystem.Native.Browser.a` linked -> `dotnet.native.wasm` - `libSystem.Runtime.InteropServices.JavaScript.Native.a` linked -> `dotnet.native.wasm` +- `host/index.ts` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` +- `host/libBrowserHost.footer.js` -> compiled -> `libBrowserHost.js` linked -> `dotnet.native.js` +- `host/browserhost.cpp` compiled -> `libBrowserHost.a` linked -> `dotnet.native.wasm` +- `empty.c` compiled + linked -> `dotnet.native.wasm` ## Build TypeScript is compiled by `src/native/rollup.config.js` diff --git a/src/native/corehost/browserhost/config.h.in b/src/native/corehost/browserhost/config.h.in index 0c2e459443b136..6fe9ebd246667e 100644 --- a/src/native/corehost/browserhost/config.h.in +++ b/src/native/corehost/browserhost/config.h.in @@ -4,7 +4,4 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#cmakedefine01 HAVE_GETAUXVAL -#cmakedefine01 HAVE_DIRENT_D_TYPE - #endif // __CONFIG_H__ diff --git a/src/native/corehost/browserhost/configure.cmake b/src/native/corehost/browserhost/configure.cmake index 61c98113949945..b460849b004677 100644 --- a/src/native/corehost/browserhost/configure.cmake +++ b/src/native/corehost/browserhost/configure.cmake @@ -1,5 +1,3 @@ -check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL) -check_struct_has_member ("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in diff --git a/src/native/corehost/browserhost/native.rc b/src/native/corehost/browserhost/empty.c similarity index 59% rename from src/native/corehost/browserhost/native.rc rename to src/native/corehost/browserhost/empty.c index 0a49d6b55d9591..b5fa34dbe43d18 100644 --- a/src/native/corehost/browserhost/native.rc +++ b/src/native/corehost/browserhost/empty.c @@ -1,7 +1,4 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#define FX_VER_FILEDESCRIPTION_STR "CoreCLR test host" - -#include -#include +#include "stdio.h" diff --git a/src/native/corehost/browserhost/sample/CMakeLists.txt b/src/native/corehost/browserhost/sample/CMakeLists.txt index 3a385623fde844..6699740c7dcda2 100644 --- a/src/native/corehost/browserhost/sample/CMakeLists.txt +++ b/src/native/corehost/browserhost/sample/CMakeLists.txt @@ -3,15 +3,16 @@ # this is just a incomplete sample app deployment # WASM-TODO: implement proper in-tree project via MSBuild and WASM SDK + set(SAMPLE_ASSETS index.html main.mjs dotnet.boot.js - ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js - ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js.map - ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.d.ts - ${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js - ${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js.map + ${STATIC_LIB_DESTINATION}/dotnet.js + ${STATIC_LIB_DESTINATION}/dotnet.js.map + ${STATIC_LIB_DESTINATION}/dotnet.d.ts + ${STATIC_LIB_DESTINATION}/dotnet.runtime.js + ${STATIC_LIB_DESTINATION}/dotnet.runtime.js.map # Bring your own DLLs and update the dotnet.boot.js to match # HelloWorld.dll diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index ae69aeaf6cf635..a07a2a3603bee1 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -34,6 +34,7 @@ if /i [%1] == [x86] (set __BuildArch=x86&&shift&goto Arg_Loop) if /i [%1] == [x64] (set __BuildArch=x64&&shift&goto Arg_Loop) if /i [%1] == [amd64] (set __BuildArch=x64&&shift&goto Arg_Loop) if /i [%1] == [arm64] (set __BuildArch=arm64&&shift&goto Arg_Loop) +if /i [%1] == [wasm] (set __BuildArch=wasm&&shift&goto Arg_Loop) if /i [%1] == [portable] (set __PortableBuild=1&&shift&goto Arg_Loop) if /i [%1] == [targetrid] (set __TargetRid=%2&&shift&&shift&goto Arg_Loop) @@ -48,6 +49,8 @@ if /i [%1] == [msbuild] (set __Ninja=0) if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [-fsanitize] ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLR_CMAKE_ENABLE_SANITIZERS=%2"&&shift&&shift&goto Arg_Loop) +if /i [%1] == [-os] ( set __TargetOS=%2&&shift&&shift&goto Arg_Loop) +if /i [%1] == [-cmakeargs] ( set __ExtraCmakeParams=%__ExtraCmakeParams% %2&&shift&&shift&goto Arg_Loop) shift goto :Arg_Loop @@ -93,6 +96,7 @@ if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" if /i "%__BuildArch%" == "x64" (set cm_BaseRid=win7) if /i "%__BuildArch%" == "x86" (set cm_BaseRid=win7) if /i "%__BuildArch%" == "arm64" (set cm_BaseRid=win10) +if /i "%__BuildArch%" == "wasm" (set cm_BaseRid=browser) :: Form the base RID to be used if we are doing a portable build if /i "%__PortableBuild%" == "1" (set cm_BaseRid=win) set cm_BaseRid=%cm_BaseRid%-%__BuildArch% @@ -105,6 +109,7 @@ for /f "delims=-" %%i in ("%__TargetRid%") do set __HostFallbackOS=%%i if "%__HostFallbackOS%" == "win" (set __HostFallbackOS=win10) set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" :: Regenerate the native build files diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index bb5f6a7d53ebe6..23fff553c69459 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -5,6 +5,7 @@ package's targets into the build. --> + true @@ -44,8 +45,8 @@ - @@ -87,8 +88,8 @@ Use IgnoreStandardErrorWarningFormat because Arcade sets WarnAsError and we want to avoid upgrading compiler warnings to errors in release branches. --> - - + + @@ -147,7 +148,7 @@ $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'build.cmd')) - $(Configuration) $(TargetArchitecture) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) targetrid $(TargetRid) + $(Configuration) $(TargetArchitecture) -os $(TargetOS) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) targetrid $(TargetRid) $(BuildArgs) configureonly $(BuildArgs) portable $(BuildArgs) incremental-native-build @@ -163,8 +164,8 @@ IgnoreStandardErrorWarningFormat because Arcade sets WarnAsError and we want to avoid upgrading compiler warnings to errors in release branches. --> - - + + #include #include #include +#endif // !TARGET_WASM static const Entry s_compressionNative[] = { +#if !defined(TARGET_WASM) DllImportEntry(BrotliDecoderCreateInstance) DllImportEntry(BrotliDecoderDecompress) DllImportEntry(BrotliDecoderDecompressStream) @@ -24,6 +28,7 @@ static const Entry s_compressionNative[] = DllImportEntry(BrotliEncoderHasMoreOutput) DllImportEntry(BrotliEncoderMaxCompressedSize) DllImportEntry(BrotliEncoderSetParameter) +#endif // !TARGET_WASM DllImportEntry(CompressionNative_Crc32) DllImportEntry(CompressionNative_Deflate) DllImportEntry(CompressionNative_DeflateEnd) diff --git a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake index 03b40533e2109d..e0b65fdc0956ba 100644 --- a/src/native/libs/System.IO.Compression.Native/extra_libs.cmake +++ b/src/native/libs/System.IO.Compression.Native/extra_libs.cmake @@ -20,7 +20,7 @@ macro(append_extra_compression_libs NativeLibsExtra) endif () list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES}) - if (CLR_CMAKE_USE_SYSTEM_BROTLI) + if (CLR_CMAKE_USE_SYSTEM_BROTLI AND NOT CLR_CMAKE_TARGET_ARCH_WASM) find_library(BROTLIDEC brotlidec REQUIRED) find_library(BROTLIENC brotlienc REQUIRED) diff --git a/src/native/libs/System.Native.Browser/CMakeLists.txt b/src/native/libs/System.Native.Browser/CMakeLists.txt index dab7e46af63a8b..22725542b36f14 100644 --- a/src/native/libs/System.Native.Browser/CMakeLists.txt +++ b/src/native/libs/System.Native.Browser/CMakeLists.txt @@ -12,87 +12,7 @@ add_library(System.Native.Browser-Static ) set_target_properties(System.Native.Browser-Static PROPERTIES OUTPUT_NAME System.Native.Browser CLEAN_DIRECT_OUTPUT 1) install(TARGETS System.Native.Browser-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS System.Native.Browser-Static DESTINATION sharedFramework COMPONENT runtime) - -file(GLOB_RECURSE ROLLUP_TS_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../Common/JavaScript/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../Common/JavaScript/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/*.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/*.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../../package.json" - "${CMAKE_CURRENT_SOURCE_DIR}/../../tsconfig.json" - "${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules/.npm-stamp" -) - -set(ROLLUP_OUTPUTS - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.d.ts" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js" - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Browser.Utils.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/dotnet.runtime.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/dotnet.runtime.js.map" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js" - "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js.map" -) - -set(ROLLUP_STAMP - "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/.rollup.stamp" -) - -if(NOT PRODUCT_VERSION_JS) - # WASM-TODO get dotnet ProductVersion from MSBuild - set(PRODUCT_VERSION_JS "10.0.0-dev") -endif() -if(NOT CI_BUILD_JS) - # WASM-TODO get ContinuousIntegrationBuild from MSBuild - set(CI_BUILD_JS "false") -endif() - -add_custom_command( - OUTPUT ${ROLLUP_STAMP} - BYPRODUCTS ${ROLLUP_OUTPUTS} - COMMAND npm run rollup:cmake -- "Configuration:${CMAKE_BUILD_TYPE},ProductVersion:${PRODUCT_VERSION_JS},ContinuousIntegrationBuild:${CI_BUILD_JS}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.." - COMMENT "Running 'npm run rollup' to generate JavaScript bundles" - DEPENDS ${ROLLUP_TS_SOURCES} - VERBATIM -) - -# WASM-TODO fixme: make this incremental -add_custom_target(System.Native.Browser-Rollup - DEPENDS ${ROLLUP_STAMP} -) - +add_subdirectory(../Common/JavaScript common-js) add_dependencies(System.Native.Browser-Static System.Native.Browser-Rollup) - -set(NPM_INSTALL_OUTPUTS - "${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules/.package-lock.json" -) - -set(NPM_INSTALL_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/../../package.json" -) - -add_dependencies(System.Native.Browser-Rollup System.Native.Browser-NpmInstall) - -add_custom_command( - OUTPUT ${NPM_INSTALL_OUTPUTS} - COMMAND npm ci - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.." - COMMENT "Running 'npm ci' to install npm packages" - DEPENDS ${NPM_INSTALL_SOURCES} - VERBATIM -) - -add_custom_target(System.Native.Browser-NpmInstall - DEPENDS ${NPM_INSTALL_OUTPUTS} -) diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index 35b483e841a95c..9d6f97151df386 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -163,8 +163,10 @@ if (CLR_CMAKE_TARGET_ARCH_WASM AND DEFINED CMAKE_TZD_DIR) target_compile_definitions(System.Native.TimeZoneData PRIVATE TZ_DATA_ENABLED) target_include_directories(System.Native.TimeZoneData PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/inc") install(TARGETS System.Native.TimeZoneData DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) + install(TARGETS System.Native.TimeZoneData DESTINATION sharedFramework COMPONENT runtime) # Also add a stub to support InvariantTimezone. add_library(System.Native.TimeZoneData.Invariant STATIC pal_datetime_time_zone_data.c) install(TARGETS System.Native.TimeZoneData.Invariant DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) + install(TARGETS System.Native.TimeZoneData.Invariant DESTINATION sharedFramework COMPONENT runtime) endif () diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt index 4af087e8dd2b10..271ef54b649cb8 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/CMakeLists.txt @@ -10,5 +10,8 @@ add_library(System.Runtime.InteropServices.JavaScript.Native-Static STATIC ${BROWSER_INTEROP_SOURCES} ) +add_dependencies(System.Runtime.InteropServices.JavaScript.Native-Static System.Native.Browser-Rollup) + set_target_properties(System.Runtime.InteropServices.JavaScript.Native-Static PROPERTIES OUTPUT_NAME System.Runtime.InteropServices.JavaScript.Native CLEAN_DIRECT_OUTPUT 1) install(TARGETS System.Runtime.InteropServices.JavaScript.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) +install(TARGETS System.Runtime.InteropServices.JavaScript.Native-Static DESTINATION sharedFramework COMPONENT runtime) diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index 97924a6e27ec7d..4b586b6d3e9d13 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -1,4 +1,6 @@ + + $(ArtifactsObjDir)_version.h @@ -11,29 +13,16 @@ <_BuildNativeArgs Condition="'$(EnableNativeSanitizers)' != ''">$(_BuildNativeArgs) -fsanitize=$(EnableNativeSanitizers) <_BuildNativeArgs Condition="'$(OfficialBuildId)' != ''">$(_BuildNativeArgs) /p:OfficialBuildId="$(OfficialBuildId)" - <_RuntimeVariant /> - <_RuntimeVariant Condition="'$(WasmEnableThreads)' == 'true'">-threads - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native - <_TzdDir Condition="'$(PkgSystem_Runtime_TimeZoneData)' != ''">$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data')) - <_CMakeArgs Condition="'$(CMakeArgs)' != ''"> -cmakeargs "$(CMakeArgs)" <_CMakeArgs Condition="'$(WasmEnableThreads)' == 'true'">$(_CMakeArgs) -cmakeargs "-DCMAKE_USE_PTHREADS=1" - <_CMakeArgs Condition="'$(_IcuDir)' != ''">$(_CMakeArgs) -cmakeargs "-DCMAKE_ICU_DIR=$(_IcuDir)" - <_CMakeArgs Condition="'$(_TzdDir)' != ''">$(_CMakeArgs) -cmakeargs "-DCMAKE_TZD_DIR=$(_TzdDir)" - <_CMakeArgs Condition="'$(TargetsBrowser)' == 'true' and '$(RuntimeFlavor)' == 'CoreCLR'">$(_CMakeArgs) -cmakeargs "-DBUILD_LIBS_NATIVE_BROWSER=1" - <_BuildNativeArgs>$(_BuildNativeArgs)$(_CMakeArgs) + <_BuildNativeArgs>$(_BuildNativeArgs)$(_CMakeArgs) @(NativeCMakeArg, ' ') - - - - -