-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wasm] Fix up conditions to trigger relink, and require
wasm-tools
…
…workload (#89754) - Trigger relinking (`WasmBuildNative=true`) if: - `WasmNativeStrip=false` - `WasmEnableSIMD=false` - `WasmEnableExceptionHandling=false` - The above are in addition to the existing conditions - Also, trigger "workload required" when: - `WasmNativeStrip=false` - `WasmEnableExceptionHandling=true` - `InvariantGlobalization=true` - `InvariantTimeZone=true` - The above are in addition to the existing conditions - Rationalize `WasmNativeDebugSymbols`, and `WasmNativeStrip` - `WasmNativeDebugSymbols` will cause symbols to be included (essentially `-g`) - `WasmNativeStrip` will cause these to be stripped with `wasm-opt --strip-dwarf ...` Fixes #85778 .
- Loading branch information
Showing
11 changed files
with
315 additions
and
130 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
89 changes: 89 additions & 0 deletions
89
src/mono/wasm/Wasm.Build.Tests/Blazor/WorkloadRequiredTests.cs
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,89 @@ | ||
// 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 System.Collections.Generic; | ||
using System.IO; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
#nullable enable | ||
|
||
namespace Wasm.Build.Tests.Blazor; | ||
|
||
public class WorkloadRequiredTests : BlazorWasmTestBase | ||
{ | ||
/* Keep in sync with settings in wasm.proj, and WasmApp.Native.targets . | ||
* The `triggerValue` here is opposite of the default used when building the runtime pack | ||
* (see wasm.proj), and thus requiring a native build | ||
*/ | ||
public static (string propertyName, bool triggerValue)[] PropertiesWithTriggerValues = new[] | ||
{ | ||
("RunAOTCompilation", true), | ||
("WasmEnableLegacyJsInterop", false), | ||
("WasmEnableSIMD", false), | ||
("WasmEnableExceptionHandling", false), | ||
("InvariantTimezone", true), | ||
("InvariantGlobalization", true), | ||
("WasmNativeStrip", false) | ||
}; | ||
|
||
public WorkloadRequiredTests(ITestOutputHelper output, SharedBuildPerTestClassFixture buildContext) | ||
: base(output, buildContext) | ||
{ | ||
} | ||
|
||
public static TheoryData<string, string, bool> SettingDifferentFromValuesInRuntimePack(bool forPublish) | ||
{ | ||
TheoryData<string, string, bool> data = new(); | ||
|
||
string[] configs = new[] { "Debug", "Release" }; | ||
foreach (var defaultPair in PropertiesWithTriggerValues) | ||
{ | ||
foreach (string config in configs) | ||
{ | ||
data.Add(config, $"<{defaultPair.propertyName}>{defaultPair.triggerValue}</{defaultPair.propertyName}>", true); | ||
data.Add(config, $"<{defaultPair.propertyName}>{!defaultPair.triggerValue}</{defaultPair.propertyName}>", false); | ||
} | ||
} | ||
|
||
return data; | ||
} | ||
|
||
[Theory, TestCategory("no-workload")] | ||
[MemberData(nameof(SettingDifferentFromValuesInRuntimePack), parameters: false)] | ||
public void WorkloadRequiredForBuild(string config, string extraProperties, bool workloadNeeded) | ||
=> CheckWorkloadRequired(config, extraProperties, workloadNeeded, publish: false); | ||
|
||
[Theory, TestCategory("no-workload")] | ||
[MemberData(nameof(SettingDifferentFromValuesInRuntimePack), parameters: false)] | ||
public void WorkloadRequiredForPublish(string config, string extraProperties, bool workloadNeeded) | ||
=> CheckWorkloadRequired(config, extraProperties, workloadNeeded, publish: true); | ||
|
||
private void CheckWorkloadRequired(string config, string extraProperties, bool workloadNeeded, bool publish) | ||
{ | ||
string id = $"props_req_workload_{(publish ? "publish" : "build")}_{GetRandomId()}"; | ||
string projectFile = CreateWasmTemplateProject(id, "blazorwasm"); | ||
AddItemsPropertiesToProject(projectFile, extraProperties, | ||
atTheEnd: @"<Target Name=""StopBuildBeforeCompile"" BeforeTargets=""Compile""> | ||
<Error Text=""Stopping the build"" /> | ||
</Target>"); | ||
|
||
CommandResult result; | ||
if (publish) | ||
(result, _) = BlazorPublish(new BlazorBuildOptions(id, config, ExpectSuccess: false)); | ||
else | ||
(result, _) = BlazorBuild(new BlazorBuildOptions(id, config, ExpectSuccess: false)); | ||
|
||
if (workloadNeeded) | ||
{ | ||
Assert.Contains("following workloads must be installed: wasm-tools", result.Output); | ||
Assert.DoesNotContain("error : Stopping the build", result.Output); | ||
} | ||
else | ||
{ | ||
Assert.DoesNotContain("following workloads must be installed: wasm-tools", result.Output); | ||
Assert.Contains("error : Stopping the build", result.Output); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.