mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
Upgraded everything to use webc v5
This commit is contained in:
589
Cargo.lock
generated
589
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ wasmer-middlewares = { version = "=3.2.0-alpha.1", path = "../middlewares", opti
|
||||
wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", features = ["host-fs", "host-vnet"], optional = true }
|
||||
wasmer-types = { version = "=3.2.0-alpha.1", path = "../types" }
|
||||
wasmer-vfs = { version = "=3.2.0-alpha.1", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] }
|
||||
webc = { version = "4.0.0", optional = true }
|
||||
webc = { version = "5.0.0-rc.5", optional = true }
|
||||
enumset = "1.0.2"
|
||||
cfg-if = "1.0"
|
||||
lazy_static = "1.4"
|
||||
|
||||
@@ -72,7 +72,7 @@ toml = "0.5.9"
|
||||
url = "2.3.1"
|
||||
libc = { version = "^0.2", default-features = false }
|
||||
nuke-dir = { version = "0.1.0", optional = true }
|
||||
webc = { version = "4.0.0", optional = true }
|
||||
webc = { version = "5.0.0-rc.5", optional = true }
|
||||
isatty = "0.1.9"
|
||||
dialoguer = "0.10.2"
|
||||
tldextract = "0.6.0"
|
||||
|
||||
@@ -15,9 +15,10 @@ use std::process::Stdio;
|
||||
use tar::Archive;
|
||||
use wasmer::*;
|
||||
use wasmer_object::{emit_serialized, get_object_for_target};
|
||||
use wasmer_types::compilation::symbols::ModuleMetadataSymbolRegistry;
|
||||
use wasmer_types::ModuleInfo;
|
||||
use webc::{ParseOptions, WebCMmap};
|
||||
use wasmer_types::{
|
||||
compilation::symbols::ModuleMetadataSymbolRegistry, ModuleInfo, SymbolRegistry,
|
||||
};
|
||||
use webc::v1::{ParseOptions, WebCMmap};
|
||||
|
||||
const LINK_SYSTEM_LIBRARIES_WINDOWS: &[&str] = &["userenv", "Ws2_32", "advapi32", "bcrypt"];
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ impl CreateObj {
|
||||
println!("Target: {}", target.triple());
|
||||
|
||||
let atoms = if let Ok(pirita) =
|
||||
webc::WebCMmap::parse(input_path.clone(), &webc::ParseOptions::default())
|
||||
webc::v1::WebCMmap::parse(input_path.clone(), &webc::v1::ParseOptions::default())
|
||||
{
|
||||
crate::commands::create_exe::compile_pirita_into_directory(
|
||||
&pirita,
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::path::PathBuf;
|
||||
use wasmer_compiler::Artifact;
|
||||
use wasmer_types::compilation::symbols::ModuleMetadataSymbolRegistry;
|
||||
use wasmer_types::{CpuFeature, MetadataHeader, Triple};
|
||||
use webc::WebC;
|
||||
use webc::v1::WebC;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
/// The options for the `wasmer gen-c-header` subcommand
|
||||
@@ -57,7 +57,7 @@ impl GenCHeader {
|
||||
None => crate::commands::PrefixMapCompilation::hash_for_bytes(&file),
|
||||
};
|
||||
|
||||
if let Ok(pirita) = WebC::parse(&file, &webc::ParseOptions::default()) {
|
||||
if let Ok(pirita) = WebC::parse(&file, &webc::v1::ParseOptions::default()) {
|
||||
let atoms = pirita
|
||||
.manifest
|
||||
.atoms
|
||||
|
||||
@@ -690,7 +690,7 @@ pub fn get_all_available_registries(wasmer_dir: &Path) -> Result<Vec<String>, St
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct RemoteWebcInfo {
|
||||
pub checksum: String,
|
||||
pub manifest: webc::Manifest,
|
||||
pub manifest: webc::metadata::Manifest,
|
||||
}
|
||||
|
||||
pub fn install_webc_package(
|
||||
@@ -772,9 +772,9 @@ fn get_all_installed_webc_packages_inner(wasmer_dir: &Path) -> Vec<RemoteWebcInf
|
||||
read_dir
|
||||
.filter_map(|r| Some(r.ok()?.path()))
|
||||
.filter_map(|path| {
|
||||
webc::WebCMmap::parse(
|
||||
webc::v1::WebCMmap::parse(
|
||||
path,
|
||||
&webc::ParseOptions {
|
||||
&webc::v1::ParseOptions {
|
||||
parse_atoms: false,
|
||||
parse_volumes: false,
|
||||
..Default::default()
|
||||
@@ -812,11 +812,11 @@ pub fn get_checksum_hash(bytes: &[u8]) -> String {
|
||||
/// Returns the checksum of the .webc file, so that we can check whether the
|
||||
/// file is already installed before downloading it
|
||||
pub fn get_remote_webc_checksum(url: &Url) -> Result<String, anyhow::Error> {
|
||||
let request_max_bytes = webc::WebC::get_signature_offset_start() + 4 + 1024 + 8 + 8;
|
||||
let request_max_bytes = webc::v1::WebC::get_signature_offset_start() + 4 + 1024 + 8 + 8;
|
||||
let data = get_webc_bytes(url, Some(0..request_max_bytes), None)
|
||||
.with_context(|| anyhow::anyhow!("note: use --registry to change the registry URL"))?
|
||||
.unwrap();
|
||||
let checksum = webc::WebC::get_checksum_bytes(&data)
|
||||
let checksum = webc::v1::WebC::get_checksum_bytes(&data)
|
||||
.map_err(|e| anyhow::anyhow!("{e}"))?
|
||||
.to_vec();
|
||||
Ok(get_checksum_hash(&checksum))
|
||||
@@ -826,20 +826,20 @@ pub fn get_remote_webc_checksum(url: &Url) -> Result<String, anyhow::Error> {
|
||||
/// so we can see if the package has already been installed
|
||||
pub fn get_remote_webc_manifest(url: &Url) -> Result<RemoteWebcInfo, anyhow::Error> {
|
||||
// Request up unti manifest size / manifest len
|
||||
let request_max_bytes = webc::WebC::get_signature_offset_start() + 4 + 1024 + 8 + 8;
|
||||
let request_max_bytes = webc::v1::WebC::get_signature_offset_start() + 4 + 1024 + 8 + 8;
|
||||
let data = get_webc_bytes(url, Some(0..request_max_bytes), None)?.unwrap();
|
||||
let checksum = webc::WebC::get_checksum_bytes(&data)
|
||||
let checksum = webc::v1::WebC::get_checksum_bytes(&data)
|
||||
.map_err(|e| anyhow::anyhow!("{e}"))
|
||||
.context("WebC::get_checksum_bytes failed")?
|
||||
.to_vec();
|
||||
let hex_string = get_checksum_hash(&checksum);
|
||||
|
||||
let (manifest_start, manifest_len) = webc::WebC::get_manifest_offset_size(&data)
|
||||
let (manifest_start, manifest_len) = webc::v1::WebC::get_manifest_offset_size(&data)
|
||||
.map_err(|e| anyhow::anyhow!("{e}"))
|
||||
.context("WebC::get_manifest_offset_size failed")?;
|
||||
let data_with_manifest =
|
||||
get_webc_bytes(url, Some(0..manifest_start + manifest_len), None)?.unwrap();
|
||||
let manifest = webc::WebC::get_manifest(&data_with_manifest)
|
||||
let manifest = webc::v1::WebC::get_manifest(&data_with_manifest)
|
||||
.map_err(|e| anyhow::anyhow!("{e}"))
|
||||
.context("WebC::get_manifest failed")?;
|
||||
Ok(RemoteWebcInfo {
|
||||
|
||||
@@ -12,7 +12,7 @@ thiserror = "1"
|
||||
tracing = { version = "0.1" }
|
||||
typetag = { version = "0.1", optional = true }
|
||||
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
|
||||
webc = { version = "4.0.0", optional = true }
|
||||
webc = { version = "5.0.0-rc.5", optional = true }
|
||||
slab = { version = "0.4" }
|
||||
derivative = "2.2.0"
|
||||
anyhow = { version = "1.0.66", optional = true }
|
||||
|
||||
@@ -13,19 +13,22 @@ use crate::mem_fs::FileSystem as MemFileSystem;
|
||||
use crate::{
|
||||
FileOpener, FileSystem, FsError, Metadata, OpenOptions, OpenOptionsConfig, ReadDir, VirtualFile,
|
||||
};
|
||||
use webc::{FsEntry, FsEntryType, OwnedFsEntryFile};
|
||||
use webc::{
|
||||
metadata::IndexMap,
|
||||
v1::{FsEntry, FsEntryType, OwnedFsEntryFile},
|
||||
};
|
||||
|
||||
/// Custom file system wrapper to map requested file paths
|
||||
#[derive(Debug)]
|
||||
pub struct StaticFileSystem {
|
||||
pub package: String,
|
||||
pub volumes: Arc<webc::IndexMap<String, webc::Volume<'static>>>,
|
||||
pub volumes: Arc<IndexMap<String, webc::v1::Volume<'static>>>,
|
||||
pub memory: Arc<MemFileSystem>,
|
||||
}
|
||||
|
||||
impl StaticFileSystem {
|
||||
pub fn init(bytes: &'static [u8], package: &str) -> Option<Self> {
|
||||
let volumes = Arc::new(webc::WebC::parse_volumes_from_fileblock(bytes).ok()?);
|
||||
let volumes = Arc::new(webc::v1::WebC::parse_volumes_from_fileblock(bytes).ok()?);
|
||||
let fs = Self {
|
||||
package: package.to_string(),
|
||||
volumes: volumes.clone(),
|
||||
@@ -90,7 +93,7 @@ impl FileOpener for StaticFileSystem {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WebCFile {
|
||||
pub volumes: Arc<webc::IndexMap<String, webc::Volume<'static>>>,
|
||||
pub volumes: Arc<IndexMap<String, webc::v1::Volume<'static>>>,
|
||||
pub package: String,
|
||||
pub volume: String,
|
||||
pub path: PathBuf,
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite};
|
||||
use webc::{FsEntry, FsEntryType, OwnedFsEntryFile, WebC};
|
||||
use webc::v1::{FsEntry, FsEntryType, OwnedFsEntryFile, WebC};
|
||||
|
||||
/// Custom file system wrapper to map requested file paths
|
||||
#[derive(Debug)]
|
||||
@@ -23,7 +23,7 @@ where
|
||||
pub webc: Arc<T>,
|
||||
pub memory: Arc<MemFileSystem>,
|
||||
top_level_dirs: Vec<String>,
|
||||
volumes: Vec<webc::Volume<'static>>,
|
||||
volumes: Vec<webc::v1::Volume<'static>>,
|
||||
}
|
||||
|
||||
impl<T> WebcFileSystem<T>
|
||||
|
||||
@@ -29,7 +29,7 @@ bincode = { version = "1.3" }
|
||||
chrono = { version = "^0.4", default-features = false, features = [ "wasmbind", "std", "clock" ], optional = true }
|
||||
derivative = { version = "^2" }
|
||||
bytes = "1"
|
||||
webc = { version = "4.0.0", default-features = false, features = ["std"] }
|
||||
webc = { version = "5.0.0-rc.5", default-features = false }
|
||||
serde_cbor = { version = "0.11.2", optional = true }
|
||||
anyhow = { version = "1.0.66" }
|
||||
lazy_static = "1.4"
|
||||
@@ -59,6 +59,10 @@ wai-bindgen-wasmer = { path = "../wai-bindgen-wasmer", version = "0.2.3", featur
|
||||
heapless = "0.7.16"
|
||||
once_cell = "1.17.0"
|
||||
pin-project = "1.0.12"
|
||||
# Used by the WCGI runner
|
||||
hyper = { version = "0.14", features = ["server", "stream"], optional = true }
|
||||
wcgi = { version = "0.1.1", optional = true }
|
||||
wcgi-host = { version = "0.1.0", optional = true }
|
||||
|
||||
[dependencies.reqwest]
|
||||
version = "0.11"
|
||||
@@ -94,6 +98,7 @@ time = ["tokio/time"]
|
||||
|
||||
webc_runner = ["serde_cbor", "wasmer/compiler"]
|
||||
webc_runner_rt_emscripten = ["wasmer-emscripten"]
|
||||
wcgi_runner = ["hyper", "wcgi", "wcgi-host"]
|
||||
webc_runner_rt_wasi = []
|
||||
|
||||
sys = ["wasmer/sys", "wasmer-wasi-types/sys", "webc/mmap", "wasmer-vm", "time"]
|
||||
@@ -123,3 +128,4 @@ enable-serde = [
|
||||
"wasmer-vfs/enable-serde",
|
||||
"wasmer-wasi-types/enable-serde",
|
||||
]
|
||||
|
||||
|
||||
10
lib/wasi/src/runners/container.rs
Normal file
10
lib/wasi/src/runners/container.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use webc::{v1::WebCOwned, v2::read::OwnedReader};
|
||||
|
||||
pub struct WebcContainer {
|
||||
inner: Container,
|
||||
}
|
||||
|
||||
enum Container {
|
||||
V1(WebCOwned),
|
||||
V2(OwnedReader),
|
||||
}
|
||||
@@ -11,7 +11,7 @@ use wasmer_emscripten::{
|
||||
generate_emscripten_env, is_emscripten_module, run_emscripten_instance, EmEnv,
|
||||
EmscriptenGlobals,
|
||||
};
|
||||
use webc::{Command, WebCMmap};
|
||||
use webc::{metadata::Command, v1::WebCMmap};
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EmscriptenRunner {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
use std::error::Error as StdError;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use webc::*;
|
||||
|
||||
use webc::v1::{Command, WebC, WebCMmap};
|
||||
|
||||
pub mod emscripten;
|
||||
pub mod wasi;
|
||||
@@ -16,7 +17,7 @@ pub struct WapmContainer {
|
||||
}
|
||||
|
||||
impl core::ops::Deref for WapmContainer {
|
||||
type Target = webc::WebC<'static>;
|
||||
type Target = WebC<'static>;
|
||||
fn deref<'a>(&'a self) -> &WebC<'static> {
|
||||
&self.webc.webc
|
||||
}
|
||||
@@ -26,11 +27,11 @@ impl core::ops::Deref for WapmContainer {
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum WebcParseError {
|
||||
/// Parse error
|
||||
Parse(webc::Error),
|
||||
Parse(webc::v1::Error),
|
||||
}
|
||||
|
||||
impl From<webc::Error> for WebcParseError {
|
||||
fn from(e: webc::Error) -> Self {
|
||||
impl From<webc::v1::Error> for WebcParseError {
|
||||
fn from(e: webc::v1::Error) -> Self {
|
||||
WebcParseError::Parse(e)
|
||||
}
|
||||
}
|
||||
@@ -39,7 +40,7 @@ impl WapmContainer {
|
||||
/// Parses a .webc container file. Since .webc files
|
||||
/// can be very large, only file paths are allowed.
|
||||
pub fn new(path: PathBuf) -> std::result::Result<Self, WebcParseError> {
|
||||
let webc = webc::WebCMmap::parse(path, &webc::ParseOptions::default())?;
|
||||
let webc = webc::v1::WebCMmap::parse(path, &webc::v1::ParseOptions::default())?;
|
||||
Ok(Self {
|
||||
webc: Arc::new(webc),
|
||||
})
|
||||
@@ -107,7 +108,7 @@ impl Bindings for WitBindings {
|
||||
container: &WapmContainer,
|
||||
value: &serde_cbor::Value,
|
||||
) -> Result<Self, String> {
|
||||
let value: webc::BindingsExtended =
|
||||
let value: webc::metadata::BindingsExtended =
|
||||
serde_cbor::from_slice(&serde_cbor::to_vec(value).unwrap())
|
||||
.map_err(|e| format!("could not parse WitBindings annotations: {e}"))?;
|
||||
|
||||
@@ -161,7 +162,7 @@ pub trait Runner {
|
||||
Some(s) => s,
|
||||
None => {
|
||||
let path = format!("{}", container.webc.path.display());
|
||||
return Err(Box::new(webc::Error(format!(
|
||||
return Err(Box::new(webc::v1::Error(format!(
|
||||
"Cannot run {path:?}: not executable (no entrypoint in manifest)"
|
||||
))));
|
||||
}
|
||||
@@ -190,13 +191,13 @@ pub trait Runner {
|
||||
match self.can_run_command(cmd, command_to_exec) {
|
||||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
return Err(Box::new(webc::Error(format!(
|
||||
return Err(Box::new(webc::v1::Error(format!(
|
||||
"Cannot run command {cmd:?} with runner {:?}",
|
||||
command_to_exec.runner
|
||||
))));
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(Box::new(webc::Error(format!(
|
||||
return Err(Box::new(webc::v1::Error(format!(
|
||||
"Cannot run command {cmd:?} with runner {:?}: {e}",
|
||||
command_to_exec.runner
|
||||
))));
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::error::Error as StdError;
|
||||
use std::sync::Arc;
|
||||
use wasmer::{Module, Store};
|
||||
use wasmer_vfs::webc_fs::WebcFileSystem;
|
||||
use webc::{Command, WebCMmap};
|
||||
use webc::{metadata::Command, v1::WebCMmap};
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct WasiRunner {
|
||||
|
||||
@@ -9,7 +9,10 @@ use wasmer_vfs::FileSystem;
|
||||
use tracing::*;
|
||||
#[allow(unused_imports)]
|
||||
use tracing::{error, warn};
|
||||
use webc::{Annotation, UrlOrManifest, WebC};
|
||||
use webc::{
|
||||
metadata::{Annotation, UrlOrManifest},
|
||||
v1::WebC,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
bin_factory::{BinaryPackage, BinaryPackageCommand},
|
||||
@@ -125,8 +128,8 @@ fn wapm_extract_version(data: &WapmWebQuery) -> Option<PiritaVersionedDownload>
|
||||
}
|
||||
|
||||
pub fn parse_static_webc(data: Vec<u8>) -> Result<BinaryPackage, anyhow::Error> {
|
||||
let options = webc::ParseOptions::default();
|
||||
match webc::WebCOwned::parse(data, &options) {
|
||||
let options = webc::v1::ParseOptions::default();
|
||||
match webc::v1::WebCOwned::parse(data, &options) {
|
||||
Ok(webc) => unsafe {
|
||||
let webc = Arc::new(webc);
|
||||
return parse_webc(webc.as_webc_ref(), webc.clone())
|
||||
@@ -164,14 +167,14 @@ async fn download_webc(
|
||||
};
|
||||
|
||||
// build the parse options
|
||||
let options = webc::ParseOptions::default();
|
||||
let options = webc::v1::ParseOptions::default();
|
||||
|
||||
// fast path
|
||||
let path = compute_path(cache_dir, name);
|
||||
|
||||
#[cfg(feature = "sys")]
|
||||
if path.exists() {
|
||||
match webc::WebCMmap::parse(path.clone(), &options) {
|
||||
match webc::v1::WebCMmap::parse(path.clone(), &options) {
|
||||
Ok(webc) => unsafe {
|
||||
let webc = Arc::new(webc);
|
||||
return parse_webc(webc.as_webc_ref(), webc.clone()).with_context(|| {
|
||||
@@ -230,7 +233,7 @@ async fn download_webc(
|
||||
);
|
||||
}
|
||||
|
||||
match webc::WebCMmap::parse(path.clone(), &options) {
|
||||
match webc::v1::WebCMmap::parse(path.clone(), &options) {
|
||||
Ok(webc) => unsafe {
|
||||
let webc = Arc::new(webc);
|
||||
return parse_webc(webc.as_webc_ref(), webc.clone())
|
||||
@@ -242,7 +245,7 @@ async fn download_webc(
|
||||
}
|
||||
}
|
||||
|
||||
let webc_raw = webc::WebCOwned::parse(data, &options)
|
||||
let webc_raw = webc::v1::WebCOwned::parse(data, &options)
|
||||
.with_context(|| format!("Failed to parse downloaded from '{pirita_download_url}'"))?;
|
||||
let webc = Arc::new(webc_raw);
|
||||
// FIXME: add SAFETY comment
|
||||
@@ -275,7 +278,7 @@ async fn download_package(
|
||||
}
|
||||
|
||||
// TODO: should return Result<_, anyhow::Error>
|
||||
unsafe fn parse_webc<'a, T>(webc: webc::WebC<'a>, ownership: Arc<T>) -> Option<BinaryPackage>
|
||||
unsafe fn parse_webc<'a, T>(webc: webc::v1::WebC<'a>, ownership: Arc<T>) -> Option<BinaryPackage>
|
||||
where
|
||||
T: std::fmt::Debug + Send + Sync + 'static,
|
||||
T: Deref<Target = WebC<'static>>,
|
||||
|
||||
@@ -27,7 +27,7 @@ wasmer-vfs = { version = "3.2.0-alpha.1", path = "../vfs", default-features = fa
|
||||
wasmer-wasi = { version = "3.2.0-alpha.1", path = "../wasi", default-features = false, features = ["sys-default"] }
|
||||
wcgi = { version = "0.1.1" }
|
||||
wcgi-host = { version = "0.1.0" }
|
||||
webc = { version = "5.0.0-rc.1", default-features = false }
|
||||
webc = { version = "5.0.0-rc.5", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = { version = "1", features = ["backtrace"] }
|
||||
|
||||
Reference in New Issue
Block a user