Support versioning in CLI (#67)

This commit is contained in:
vms
2021-03-12 20:04:47 +03:00
committed by GitHub
parent b0f2738c94
commit 5effdcba72
58 changed files with 993 additions and 217 deletions

View File

@ -14,8 +14,9 @@
* limitations under the License.
*/
use super::custom::WITCustom;
use super::custom::ITCustomSection;
use super::errors::WITParserError;
use crate::Result;
use walrus::ModuleConfig;
use wasmer_wit::{
@ -27,11 +28,7 @@ use wasmer_wit::ToBytes;
use std::path::PathBuf;
/// Embed provided WIT to a Wasm file by path.
pub fn embed_text_wit(
in_wasm_path: PathBuf,
out_wasm_path: PathBuf,
wit: &str,
) -> Result<(), WITParserError> {
pub fn embed_text_wit(in_wasm_path: PathBuf, out_wasm_path: PathBuf, wit: &str) -> Result<()> {
let module = ModuleConfig::new()
.parse_file(&in_wasm_path)
.map_err(WITParserError::CorruptedWasmFile)?;
@ -53,7 +50,7 @@ pub fn embed_wit(mut wasm_module: walrus::Module, interfaces: &Interfaces<'_>) -
// TODO: think about possible errors here
interfaces.to_bytes(&mut bytes).unwrap();
let custom = WITCustom(bytes);
let custom = ITCustomSection(bytes);
wasm_module.customs.add(custom);
wasm_module