diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
commit | 8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch) | |
tree | df55b7e75bf43f2bf500845b105afe3ac3a5157e /tools/wasi-headers/src/lib.rs | |
parent | Initial commit. (diff) | |
download | wasi-libc-upstream/0.0_git20221206.8b7148f.tar.xz wasi-libc-upstream/0.0_git20221206.8b7148f.zip |
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/wasi-headers/src/lib.rs')
-rw-r--r-- | tools/wasi-headers/src/lib.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/wasi-headers/src/lib.rs b/tools/wasi-headers/src/lib.rs new file mode 100644 index 0000000..8844c49 --- /dev/null +++ b/tools/wasi-headers/src/lib.rs @@ -0,0 +1,39 @@ +mod c_header; + +use anyhow::Result; +pub use c_header::{to_c, Generated}; +use std::path::{Path, PathBuf}; +use witx::load; + +pub fn generate<P: AsRef<Path>>(inputs: &[P]) -> Result<Generated> { + let doc = load(&inputs)?; + + let inputs_str = &inputs + .iter() + .map(|p| { + p.as_ref() + .file_name() + .unwrap() + .to_str() + .unwrap() + .to_string() + }) + .collect::<Vec<_>>() + .join(", "); + + Ok(to_c(&doc, &inputs_str)) +} + +pub fn snapshot_witx_files() -> Result<Vec<PathBuf>> { + witx::phases::snapshot() +} + +pub fn libc_wasi_api_header() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../libc-bottom-half/headers/public/wasi/api.h") +} + +pub fn libc_wasi_api_source() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../libc-bottom-half/sources/__wasilibc_real.c") +} |