Skip to content

Fix so that compilation runs in correct order #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2024
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ wasmtime composed.wasm
While you can run wasm-tools manually, you can also generate this automatically. One way to do this is to [create a new project](./samples/calculator/CalculatorComposed/) and add the following:

```xml
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
<PropertyGroup>
<EntrypointComponent>../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/calculatorhost.wasm</EntrypointComponent>
<DependencyComponent>../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/adder.wasm</DependencyComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
<PropertyGroup>
<EntrypointComponent>../CalculatorHost/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/CalculatorHost.wasm</EntrypointComponent>
<DependencyComponent>../Adder/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/adder.wasm</DependencyComponent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<Target Name="EmitWasmOnBuild" AfterTargets="CopyFilesToOutputDirectory" DependsOnTargets="LinkNativeLlvm;"
Condition="'$(RuntimeIdentifier)' == 'wasi-wasm'">
<Message Importance="high" Text="Emit on build $(ProjectName) " />
</Target>
<!--
This links the publish step with the build so that when a user runs `dotnet build` they get a wasm file.
-->
<Target Name="PublishAfterBuild" AfterTargets="Build" DependsOnTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm'" />
</Project>
2 changes: 1 addition & 1 deletion test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<!-- After build, create the composed component so it can be executed in the test -->
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
<PropertyGroup>
<DependencyComponent>../E2EProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/e2eproducer.wasm</DependencyComponent>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void CanComposeImportWithExport()
[Fact]
public void CanBuildAppFromOci()
{
var composed = FindModulePath("../testapps/OciWit", "ociwit.wasm");
var composed = FindModulePath($"../testapps/OciWit/bin/{Config}", "ociwit.wasm");
var stdout = ExecuteCommandComponent(composed);
Assert.StartsWith("Oci is awesome!", stdout);
}
Expand Down Expand Up @@ -89,11 +89,18 @@ private static string FindModulePath(string searchDir, string filename)
}

var matches = Directory.GetFiles(resolvedSearchDir, filename, SearchOption.AllDirectories);
if (matches.Count() != 1)
if (matches.Count() == 1)
{
return Path.GetFullPath(matches.Single());
}
else if (matches.Count() == 2 && matches.Any(x => Path.GetFullPath(x).Contains($"wasi-wasm\\native"))) {
return Path.GetFullPath(matches.First(x => Path.GetFullPath(x).Contains($"wasi-wasm\\native")));
}
else if (matches.Count() == 2 && matches.Any(x => Path.GetFullPath(x).Contains($"wasi-wasm/native"))) {
return Path.GetFullPath(matches.First(x => Path.GetFullPath(x).Contains($"wasi-wasm/native")));
}
else {
throw new Exception($"Failed to get modules path, matched {matches.Count()} entries for directory {resolvedSearchDir} and filename {filename}.");
}

return Path.GetFullPath(matches.Single());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<!-- After build, create the composed component so it can be executed in the test -->
<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
<Target Name="ComposeWasmComponent" AfterTargets="Publish">
<PropertyGroup>
<DependencyComponent>../SimpleProducer/bin/$(Configuration)/$(TargetFramework)/wasi-wasm/native/simpleproducer.wasm</DependencyComponent>
</PropertyGroup>
Expand Down