-
Notifications
You must be signed in to change notification settings - Fork 194
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
base: main
Are you sure you want to change the base?
Changes from all commits
d6da02a
dbab743
43ca36b
1b1d549
631156d
902e792
60295c5
22bbc58
08ae2d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -502,7 +502,7 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> { | |||||||
let (resolve, world) = resolve_wit_dir(&dir); | ||||||||
for path in c_sharp.iter() { | ||||||||
let world_name = &resolve.worlds[world].name; | ||||||||
let out_dir = out_dir.join(format!("csharp-{}", world_name)); | ||||||||
let out_dir = out_dir.join(format!("csharp-mono-{}", world_name)); | ||||||||
drop(fs::remove_dir_all(&out_dir)); | ||||||||
fs::create_dir_all(&out_dir).unwrap(); | ||||||||
|
||||||||
|
@@ -540,7 +540,7 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> { | |||||||
fs::write(dst, contents).unwrap(); | ||||||||
} | ||||||||
|
||||||||
let mut csproj = wit_bindgen_csharp::CSProject::new_mono( | ||||||||
let csproj = wit_bindgen_csharp::CSProject::new_mono( | ||||||||
out_dir.clone(), | ||||||||
&assembly_name, | ||||||||
world_name, | ||||||||
|
@@ -553,6 +553,7 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> { | |||||||
csproj.generate()?; | ||||||||
|
||||||||
let dotnet_root_env = "DOTNET_ROOT"; | ||||||||
let configuration = "Debug"; | ||||||||
let dotnet_cmd: PathBuf; | ||||||||
match env::var(dotnet_root_env) { | ||||||||
Ok(val) => dotnet_cmd = Path::new(&val).join("dotnet"), | ||||||||
|
@@ -563,10 +564,10 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> { | |||||||
|
||||||||
cmd.current_dir(&out_dir); | ||||||||
|
||||||||
cmd.arg("build") | ||||||||
cmd.arg("publish") | ||||||||
.arg(out_dir.join(format!("{camel}.csproj"))) | ||||||||
.arg("-c") | ||||||||
.arg("Debug") | ||||||||
.arg(configuration) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
.arg("/p:PlatformTarget=AnyCPU") | ||||||||
.arg("--self-contained") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for me After I install workload
Which makes sense for preview6. With preview7 I get
Which means There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nothing about this will work without the workload, I'm testing against daily builds of 9 using https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to add |
||||||||
.arg("-o") | ||||||||
|
@@ -586,75 +587,16 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> { | |||||||
panic!("failed to compile"); | ||||||||
} | ||||||||
|
||||||||
let out_wasm = out_wasm.join("AppBundle").join(assembly_name); | ||||||||
let out_wasm = out_dir | ||||||||
.join("bin") | ||||||||
.join(configuration) | ||||||||
.join("net9.0") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) | ||||||||
})?; | ||||||||
|
||||||||
// Translate the canonical ABI module into a component. | ||||||||
let component_type_filename = out_dir.join(format!("{camel}_component_type.o")); | ||||||||
let component_type = fs::read(&component_type_filename).with_context(|| { | ||||||||
format!( | ||||||||
"failed to read component type file: {}", | ||||||||
component_type_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); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move to Net10 ?
Because we are not going to backport fixes to Net9, right ?
One more below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there won't be a working net10 sdk for a while unfortunately