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

Method generate_bindings_prepare

crates/test/src/cpp.rs:78–105  ·  view source on GitHub ↗
(
        &self,
        _runner: &Runner,
        bindgen: &crate::Bindgen,
        dir: &std::path::Path,
    )

Source from the content-addressed store, hash-verified

76 }
77
78 fn generate_bindings_prepare(
79 &self,
80 _runner: &Runner,
81 bindgen: &crate::Bindgen,
82 dir: &std::path::Path,
83 ) -> anyhow::Result<()> {
84 let mut export_header_dir = bindgen.wit_path.clone();
85 export_header_dir.pop();
86 export_header_dir.push("cpp");
87
88 // copy resource implementation in header files to target dir
89 if export_header_dir.is_dir() {
90 if !dir.exists() {
91 std::fs::create_dir_all(dir).context("failed to create bindings dir")?;
92 }
93 for entry in export_header_dir
94 .read_dir()
95 .context("failed to read test header directory")?
96 {
97 let entry = entry.context("failed to read test header directory entry")?;
98 let path = entry.path();
99 let mut dest = PathBuf::from(dir);
100 dest.push(path.file_name().unwrap());
101 std::fs::copy(path, dest).context("failed to copy header file")?;
102 }
103 }
104 Ok(())
105 }
106
107 fn compile(&self, runner: &Runner, compile: &crate::Compile) -> anyhow::Result<()> {
108 let compiler = clangpp(runner);

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected