Skip to content
Merged
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: 2 additions & 0 deletions eng/testing/tests.browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@
</ItemGroup>

<WriteLinesToFile File="$(WasmMainHtmlPath)" Lines="&lt;html&gt;&lt;body&gt;&lt;script type='module' src='$(WasmMainJSFileName)'&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;" Overwrite="True" Condition="!Exists('$(WasmMainHtmlPath)')"/>

<ForceMSBuildGC />
</Target>

<Target Name="_PrepareForAOTOnHelix">
Expand Down
2 changes: 2 additions & 0 deletions eng/testing/tests.wasi.targets
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
TargetPath="%(WasmFilesToIncludeFromPublishDir.Identity)"
Condition="'%(WasmFilesToIncludeFromPublishDir.Identity)' != ''" />
</ItemGroup>

<ForceMSBuildGC />
</Target>

<Target Name="_PrepareForAOTOnHelix">
Expand Down
4 changes: 3 additions & 1 deletion eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@

<UsingTask Condition="'$(BuildAOTTestsOnHelix)' == 'true'"
TaskName="Microsoft.WebAssembly.Build.Tasks.GenerateAOTProps"
AssemblyFile="$(WasmBuildTasksAssemblyPath)" />
AssemblyFile="$(WasmBuildTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.ForceMSBuildGC" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />

<Target Name="_BundleAOTTestWasmAppForHelix" DependsOnTargets="$(_BundleAOTTestWasmAppForHelixDependsOn)">
<PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/mono/browser/browser.proj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.Build.NoTargets">

<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.RunWithEmSdkEnv" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.RunWithEmSdkEnv" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<PropertyGroup>
<!-- FIXME: clean up the duplication with libraries Directory.Build.props -->
Expand Down Expand Up @@ -49,7 +49,7 @@
<PackageReference Include="System.Runtime.TimeZoneData" PrivateAssets="all" Version="$(SystemRuntimeTimeZoneDataVersion)" GeneratePathProperty="true" />
</ItemGroup>

<UsingTask TaskName="ManagedToNativeGenerator" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="ManagedToNativeGenerator" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<Target Name="GenerateManagedToNative" DependsOnTargets="CheckEnv;ResolveLibrariesFromLocalBuild">
<PropertyGroup>
<WasmPInvokeTablePath>$(WasmObjDir)\pinvoke-table.h</WasmPInvokeTablePath>
Expand Down Expand Up @@ -81,7 +81,7 @@
</ManagedToNativeGenerator>
</Target>

<UsingTask TaskName="EmitBundleSourceFiles" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="EmitBundleSourceFiles" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<Target Name="GenerateTimezonesArchive" Returns="@(_WasmArchivedTimezones)" Condition="'$(InvariantTimezone)' != 'true'">
<PropertyGroup>
<_WasmTimezonesPath>$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data'))</_WasmTimezonesPath>
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/build/BrowserWasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<Import Project="$(WasmCommonTargetsPath)WasmApp.Common.targets" />

<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.WasmAppBuilder" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.WasmAppBuilder" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<PropertyGroup>
<PrepareForWasmBuildNativeDependsOn>
Expand Down
6 changes: 3 additions & 3 deletions src/mono/browser/build/WasmApp.InTree.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<!-- This depends on the root Directory.Build.targets imported this file -->
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
<UsingTask TaskName="ILStrip" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="RuntimeConfigParserTask" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="ILStrip" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="RuntimeConfigParserTask" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<!-- TODO: this breaks runtime tests on Helix due to the file not being there for some reason. Once this is fixed we can remove the UpdateRuntimePack target here -->
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(TargetingpacksTargetsImported)' != 'true' and '$(ImportTargetingPacksTargetsInWasmAppTargets)' == 'true'"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ Copyright (c) .NET Foundation. All rights reserved.
<DisableBuildCompression Condition="'$(WasmBuildingForNestedPublish)' == 'true'">true</DisableBuildCompression>
</PropertyGroup>

<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.GenerateWasmBootJson" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ComputeWasmBuildAssets" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ConvertDllsToWebCil" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.GenerateWasmBootJson" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ComputeWasmBuildAssets" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ConvertDllsToWebCil" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" TaskFactory="TaskHostFactory" />

<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<UsingTask TaskName="GenerateRunScript" AssemblyFile="$(InstallerTasksAssemblyPath)"/>
<UsingTask TaskName="GenerateRunScript" AssemblyFile="$(InstallerTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<PropertyGroup>
<RunScriptOutputName Condition="'$(TargetOS)' != 'windows'">RunTests.sh</RunScriptOutputName>
Expand Down
12 changes: 6 additions & 6 deletions src/mono/wasm/build/WasmApp.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@
- @(EmccExportedFunction) - Extra function for emcc flag EXPORTED_FUNCTIONS
-->

<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.WasmLoadAssembliesAndReferences" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.ManagedToNativeGenerator" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.EmccCompile" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.WasmCalculateInitialHeapSize" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="MonoTargetsTasks.MarshalingPInvokeScanner" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="EmitBundleObjectFiles" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.WasmLoadAssembliesAndReferences" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.ManagedToNativeGenerator" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.EmccCompile" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="Microsoft.WebAssembly.Build.Tasks.WasmCalculateInitialHeapSize" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="MonoTargetsTasks.MarshalingPInvokeScanner" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="EmitBundleObjectFiles" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<PropertyGroup>
<PrepareInputsForWasmBuildDependsOn>
Expand Down
6 changes: 3 additions & 3 deletions src/mono/wasm/build/WasmApp.LocalBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<Project>
<Import Project="$(_WasmTargetsDir)$(_TargetsBaseName).targets" />

<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
<UsingTask TaskName="ILStrip" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="RuntimeConfigParserTask" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="ILStrip" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
<UsingTask TaskName="RuntimeConfigParserTask" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<PropertyGroup>
<PublishTrimmed Condition="'$(PublishTrimmed)' == ''">true</PublishTrimmed>
Expand Down
12 changes: 10 additions & 2 deletions src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,16 @@ private bool ExecuteInternal()
{
int allowedParallelism = DisableParallelAot ? 1 : Math.Min(_assembliesToCompile.Count, Environment.ProcessorCount);
IBuildEngine9? be9 = BuildEngine as IBuildEngine9;
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
try
{
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
}
catch(NotImplementedException)
{
// RequestCores is not implemented in TaskHostFactory
be9 = null;
}

/*
From: https://github.com/dotnet/runtime/issues/46146#issuecomment-754021690
Expand Down
12 changes: 10 additions & 2 deletions src/tasks/MonoTargetsTasks/EmitBundleTask/EmitBundleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,16 @@ public override bool Execute()
// Generate source file(s) containing each resource's byte data and size
int allowedParallelism = Math.Max(Math.Min(bundledResources.Count, Environment.ProcessorCount), 1);
IBuildEngine9? be9 = BuildEngine as IBuildEngine9;
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
try
{
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
}
catch(NotImplementedException)
{
// RequestCores is not implemented in TaskHostFactory
be9 = null;
}

try
{
Expand Down
13 changes: 11 additions & 2 deletions src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,17 @@ public override bool Execute()

int allowedParallelism = DisableParallelStripping ? 1 : Math.Min(Assemblies.Length, Environment.ProcessorCount);
IBuildEngine9? be9 = BuildEngine as IBuildEngine9;
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
try
{
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
}
catch(NotImplementedException)
{
// RequestCores is not implemented in TaskHostFactory
be9 = null;
}

try
{
ParallelLoopResult result = Parallel.ForEach(Assemblies,
Expand Down
12 changes: 10 additions & 2 deletions src/tasks/WasmAppBuilder/EmccCompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ private bool ExecuteActual()

int allowedParallelism = DisableParallelCompile ? 1 : Math.Min(SourceFiles.Length, Environment.ProcessorCount);
IBuildEngine9? be9 = BuildEngine as IBuildEngine9;
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
try
{
if (be9 is not null)
allowedParallelism = be9.RequestCores(allowedParallelism);
}
catch(NotImplementedException)
{
// RequestCores is not implemented in TaskHostFactory
be9 = null;
}

/*
From: https://github.com/dotnet/runtime/issues/46146#issuecomment-754021690
Expand Down
19 changes: 19 additions & 0 deletions src/tasks/WasmAppBuilder/ForceMSBuildGC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.WebAssembly.Build.Tasks
{
public class ForceMSBuildGC : Task
{
public override bool Execute()
{
GC.Collect();
GC.WaitForPendingFinalizers();
return true;
}
}
}
2 changes: 1 addition & 1 deletion src/tests/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
</Target>

<UsingTask TaskName="AppleAppBuilderTask" AssemblyFile="$(AppleAppBuilderTasksAssemblyPath)" />
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" TaskFactory="TaskHostFactory" />

<Target Name="BuildMonoiOSApp">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Copyright (c) .NET Foundation. All rights reserved.
if the output semaphore file is out of date with respect to the inputs.
============================================================
-->
<UsingTask TaskName="ILLink" AssemblyFile="$(ILLinkTasksAssembly)" Condition="'$(ILLinkTasksAssembly)' != ''" />
<UsingTask TaskName="ILLink" AssemblyFile="$(ILLinkTasksAssembly)" Condition="'$(ILLinkTasksAssembly)' != ''" TaskFactory="TaskHostFactory" />
<Target Name="_RunILLink"
DependsOnTargets="_ComputeManagedAssemblyToLink;PrepareForILLink"
Inputs="$(MSBuildAllProjects);@(ManagedAssemblyToLink);@(TrimmerRootDescriptor);@(ReferencePath)"
Expand Down Expand Up @@ -312,7 +312,7 @@ Copyright (c) .NET Foundation. All rights reserved.
Compute the set of inputs to ILLink.
============================================================
-->
<UsingTask TaskName="ComputeManagedAssemblies" AssemblyFile="$(ILLinkTasksAssembly)" Condition="'$(ILLinkTasksAssembly)' != ''" />
<UsingTask TaskName="ComputeManagedAssemblies" AssemblyFile="$(ILLinkTasksAssembly)" Condition="'$(ILLinkTasksAssembly)' != ''" TaskFactory="TaskHostFactory" />
<Target Name="_ComputeManagedAssemblyToLink" DependsOnTargets="_ComputeAssembliesToPostprocessOnPublish">

<!-- NB: There should not be non-managed assemblies in this list, but we still give the ILLink a chance to
Expand Down
Loading