Move back to only one WASI submodule (#1434)
* Move back to only one WASI submodule This commit fixes the issue where we have two WASI submodules for build reasons in this repository. The fix was to place the submodule in the `wasi-common` crate, and then anyone using the `wig` crate has to be sure to define a `WASI_ROOT` env var in a build script to be able to parse witx files. With all that in place `wasi-common` becomes the source of truth for the witx files we're parsing, and crates like `wasmtime-wasi` use build-scripts shenanigans to read the same witx files. This should hopefully get us so we're compatible with publishing and still only have one submodule! * rustfmt
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
use proc_macro2::{Ident, Literal, TokenStream, TokenTree};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Given the input tokens to a macro invocation, return the path to the
|
||||
/// witx file to process.
|
||||
pub(crate) fn witx_path_from_args(args: TokenStream) -> (String, String) {
|
||||
pub(crate) fn witx_path_from_args(args: TokenStream) -> PathBuf {
|
||||
let mut strings = Vec::new();
|
||||
|
||||
for arg in args {
|
||||
@@ -15,20 +16,11 @@ pub(crate) fn witx_path_from_args(args: TokenStream) -> (String, String) {
|
||||
}
|
||||
}
|
||||
|
||||
if strings.len() != 2 {
|
||||
panic!("expected two string literals");
|
||||
if strings.len() != 1 {
|
||||
panic!("expected one string literals");
|
||||
}
|
||||
|
||||
let phase = &strings[0];
|
||||
let id = &strings[1];
|
||||
let path = witx_path(phase, id);
|
||||
|
||||
(path, phase.clone())
|
||||
}
|
||||
|
||||
fn witx_path(phase: &str, id: &str) -> String {
|
||||
let root = env!("CARGO_MANIFEST_DIR");
|
||||
format!("{}/WASI/phases/{}/witx/{}.witx", root, phase, id)
|
||||
let root = PathBuf::from(std::env::var("WASI_ROOT").unwrap());
|
||||
return root.join(&strings[0]);
|
||||
}
|
||||
|
||||
// Convert a `Literal` holding a string literal into the `String`.
|
||||
|
||||
Reference in New Issue
Block a user