MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / prepare

Method prepare

crates/test/src/go.rs:40–60  ·  view source on GitHub ↗
(&self, runner: &mut Runner)

Source from the content-addressed store, hash-verified

38 }
39
40 fn prepare(&self, runner: &mut Runner) -> Result<()> {
41 let cwd = env::current_dir()?;
42 let dir = cwd.join(&runner.opts.artifacts).join("go");
43 let bindings_dir = cwd.join("wit_component");
44
45 super::write_if_different(&dir.join("test.go"), "package main\n\nfunc main() {}")?;
46 super::write_if_different(&dir.join("go.mod"), "module test\n\ngo 1.25")?;
47
48 replace_bindings_go_mod(runner, &bindings_dir)?;
49
50 println!("Testing if `go build` works...");
51 runner.run_command(
52 Command::new("go")
53 .current_dir(&dir)
54 .env("GOOS", "wasip1")
55 .env("GOARCH", "wasm")
56 .arg("build")
57 .arg("-buildmode=c-shared")
58 .arg("-ldflags=-checklinkname=0"),
59 )
60 }
61
62 fn compile(&self, runner: &Runner, compile: &Compile<'_>) -> Result<()> {
63 let output = compile.output.with_extension("core.wasm");

Callers

nothing calls this directly

Calls 5

write_if_differentFunction · 0.85
replace_bindings_go_modFunction · 0.85
newFunction · 0.85
joinMethod · 0.80
run_commandMethod · 0.80

Tested by

no test coverage detected