Skip to content

Commit

Permalink
PInvokeTableGenerator: Find path to WasmAppBuilder.dll at test time
Browse files Browse the repository at this point in the history
.. instead of depending on *one* runtime pack version. This is needed
when we have more than one workload installed.
  • Loading branch information
radical committed Sep 29, 2022
1 parent 1a731fb commit 33dbf98
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,21 @@ public static void Main()
""";

string tasksDir = Path.Combine(s_buildEnv.WorkloadPacksDir,
"Microsoft.NET.Runtime.WebAssembly.Sdk",
s_buildEnv.GetRuntimePackVersion(DefaultTargetFramework),
"tasks");
if (!Directory.Exists(tasksDir))
throw new DirectoryNotFoundException($"Could not find tasks directory {tasksDir}");

string? taskPath = Directory.EnumerateFiles(tasksDir, "WasmAppBuilder.dll", SearchOption.AllDirectories)
.FirstOrDefault();
if (string.IsNullOrEmpty(taskPath))
throw new FileNotFoundException($"Could not find WasmAppBuilder.dll in {tasksDir}");

projectCode = projectCode
.Replace("###WasmPInvokeModule###", AddAssembly("System.Private.CoreLib") + AddAssembly("System.Runtime") + AddAssembly(libraryBuildArgs.ProjectName))
.Replace("###WasmAppBuilder###", Path.Combine(s_buildEnv.WorkloadPacksDir, "Microsoft.NET.Runtime.WebAssembly.Sdk", s_buildEnv.GetRuntimePackVersion(), "tasks", DefaultTargetFramework, "WasmAppBuilder.dll"));
.Replace("###WasmAppBuilder###", taskPath);

buildArgs = buildArgs with { ProjectName = $"icall_enum_{buildArgs.Config}_{id}", ProjectFileContents = projectCode };

Expand Down

0 comments on commit 33dbf98

Please sign in to comment.