Skip to content
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

Fix the mono runtime test config #958

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Small fixes
lewing committed Aug 30, 2024
commit 902e7924a4a50599aeb2f5f6b67c7660a350b0e4
3 changes: 0 additions & 3 deletions crates/csharp/src/csproj.rs
Original file line number Diff line number Diff line change
@@ -196,9 +196,6 @@ impl CSProjectMonoBuilder {

<ItemGroup>
<_WasiLinkStepArgs Include=\"-Wl,--component-type,{camel}_component_type.wit\" />
<!-- both versions of these seem to fail to find the .o
<_WasiLinkStepArgs Include=\"-Wl,--component-type,&quot;$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '{camel}_component_type.wit').Replace('\\','/'))&quot;\" />
-->
</ItemGroup>

<Target Name=\"_FixRootAssembly\" AfterTargets=\"PrepareForILLink\">
59 changes: 3 additions & 56 deletions tests/runtime/main.rs
Original file line number Diff line number Diff line change
@@ -587,70 +587,17 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> {
panic!("failed to compile");
}

let out_wasm = out_dir.join("bin")
let out_wasm = out_dir
.join("bin")
.join(configuration)
.join("net9.0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is only one of the issues here, build doesn't respect the project name, and the publish doesn't respect the output directory. @maraf we should discuss what options we have here

.join("AppBundle")
.join(assembly_name);
let mut wasm_filename = out_wasm.clone();
wasm_filename.set_extension("wasm");

let module = fs::read(&wasm_filename).with_context(|| {
format!("failed to read wasm file: {}", wasm_filename.display())
})?;

let mut new_module = wasm_encoder::Module::new();

for payload in wasmparser::Parser::new(0).parse_all(&module) {
let payload = payload.unwrap();
match payload {
_ => {
if let Some((id, range)) = payload.as_section() {
new_module.section(&wasm_encoder::RawSection {
id,
data: &module[range],
});
}
}
}
}

for payload in wasmparser::Parser::new(0).parse_all(&component_type) {
let payload = payload.unwrap();
match payload {
wasmparser::Payload::CustomSection(_) => {
if let Some((id, range)) = payload.as_section() {
new_module.section(&wasm_encoder::RawSection {
id,
data: &component_type[range],
});
}
}
_ => {
continue;
}
}
}

let module = new_module.finish();

let component = ComponentEncoder::default()
.module(&module)
.expect("pull custom sections from module")
.validate(true)
.adapter("wasi_snapshot_preview1", &wasi_adapter)
.expect("adapter failed to get loaded")
.realloc_via_memory_grow(true)
.encode()
.expect(&format!(
"module {:?} can be translated to a component",
out_wasm
));
let component_path = out_wasm.with_extension("component.wasm");
println!("COMPONENT WASM File name: {}", component_path.display());
fs::write(&component_path, component).expect("write component to disk");

result.push(component_path);
result.push(wasm_filename);
}
}