mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-06 04:38:25 +00:00
feat: Rename wasmer-engine-native to wasmer-engine-dylib.
This commit is contained in:
@@ -43,11 +43,9 @@ impl Compile {
|
||||
target_triple: &Triple,
|
||||
) -> Result<&'static str> {
|
||||
Ok(match engine_type {
|
||||
#[cfg(feature = "shared-object")]
|
||||
EngineType::SharedObject => {
|
||||
wasmer_engine_shared_object::SharedObjectArtifact::get_default_extension(
|
||||
target_triple,
|
||||
)
|
||||
#[cfg(feature = "dylib")]
|
||||
EngineType::Dylib => {
|
||||
wasmer_engine_dylib::DylibArtifact::get_default_extension(target_triple)
|
||||
}
|
||||
#[cfg(feature = "universal")]
|
||||
EngineType::Universal => {
|
||||
@@ -57,11 +55,7 @@ impl Compile {
|
||||
EngineType::ObjectFile => {
|
||||
wasmer_engine_object_file::ObjectFileArtifact::get_default_extension(target_triple)
|
||||
}
|
||||
#[cfg(not(all(
|
||||
feature = "shared-object",
|
||||
feature = "universal",
|
||||
feature = "object-file"
|
||||
)))]
|
||||
#[cfg(not(all(feature = "dylib", feature = "universal", feature = "object-file")))]
|
||||
_ => bail!("selected engine type is not compiled in"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -205,10 +205,10 @@ impl Run {
|
||||
|
||||
fn get_module(&self) -> Result<Module> {
|
||||
let contents = std::fs::read(self.path.clone())?;
|
||||
#[cfg(feature = "shared-object")]
|
||||
#[cfg(feature = "dylib")]
|
||||
{
|
||||
if wasmer_engine_shared_object::SharedObjectArtifact::is_deserializable(&contents) {
|
||||
let engine = wasmer_engine_shared_object::SharedObject::headless().engine();
|
||||
if wasmer_engine_dylib::DylibArtifact::is_deserializable(&contents) {
|
||||
let engine = wasmer_engine_dylib::Dylib::headless().engine();
|
||||
let store = Store::new(&engine);
|
||||
let module = unsafe { Module::deserialize_from_file(&store, &self.path)? };
|
||||
return Ok(module);
|
||||
@@ -296,18 +296,15 @@ impl Run {
|
||||
cache_dir_root.push(compiler_type.to_string());
|
||||
let mut cache = FileSystemCache::new(cache_dir_root)?;
|
||||
|
||||
// Important: Shared object files need to have a `.dll`
|
||||
// extension on Windows, otherwise they will not load, so we
|
||||
// just add an extension always to make it easier to recognize
|
||||
// as well.
|
||||
// Important: Dylib files need to have a `.dll` extension on
|
||||
// Windows, otherwise they will not load, so we just add an
|
||||
// extension always to make it easier to recognize as well.
|
||||
#[allow(unreachable_patterns)]
|
||||
let extension = match *engine_type {
|
||||
#[cfg(feature = "shared-object")]
|
||||
EngineType::SharedObject => {
|
||||
wasmer_engine_shared_object::SharedObjectArtifact::get_default_extension(
|
||||
&Triple::host(),
|
||||
)
|
||||
.to_string()
|
||||
#[cfg(feature = "dylib")]
|
||||
EngineType::Dylib => {
|
||||
wasmer_engine_dylib::DylibArtifact::get_default_extension(&Triple::host())
|
||||
.to_string()
|
||||
}
|
||||
#[cfg(feature = "universal")]
|
||||
EngineType::Universal => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#[derive(Debug, Clap, Clone)]
|
||||
/// LLVM backend flags.
|
||||
pub struct LLVMCLIOptions {
|
||||
@@ -15,7 +14,6 @@ pub struct LLVMCLIOptions {
|
||||
obj_file: Option<PathBuf>,
|
||||
}
|
||||
|
||||
|
||||
impl LLVMCallbacks for LLVMCLIOptions {
|
||||
fn preopt_ir_callback(&mut self, module: &InkwellModule) {
|
||||
if let Some(filename) = &self.pre_opt_ir {
|
||||
|
||||
@@ -20,15 +20,15 @@ pub struct StoreOptions {
|
||||
compiler: CompilerOptions,
|
||||
|
||||
/// Use the Universal Engine.
|
||||
#[clap(long, conflicts_with_all = &["shared-object", "object-file"])]
|
||||
#[clap(long, conflicts_with_all = &["dylib", "object-file"])]
|
||||
universal: bool,
|
||||
|
||||
/// Use the Shared Object Engine.
|
||||
/// Use the Dylib Engine.
|
||||
#[clap(long, conflicts_with_all = &["universal", "object-file"])]
|
||||
shared_object: bool,
|
||||
dylib: bool,
|
||||
|
||||
/// Use the ObjectFile Engine.
|
||||
#[clap(long, conflicts_with_all = &["universal", "shared-object"])]
|
||||
#[clap(long, conflicts_with_all = &["universal", "dylib"])]
|
||||
object_file: bool,
|
||||
}
|
||||
|
||||
@@ -143,9 +143,9 @@ impl CompilerOptions {
|
||||
.target(target)
|
||||
.engine(),
|
||||
),
|
||||
#[cfg(feature = "shared-object")]
|
||||
EngineType::SharedObject => Box::new(
|
||||
wasmer_engine_shared_object::SharedObject::new(compiler_config)
|
||||
#[cfg(feature = "dylib")]
|
||||
EngineType::Dylib => Box::new(
|
||||
wasmer_engine_dylib::Dylib::new(compiler_config)
|
||||
.target(target)
|
||||
.features(features)
|
||||
.engine(),
|
||||
@@ -157,11 +157,7 @@ impl CompilerOptions {
|
||||
.features(features)
|
||||
.engine(),
|
||||
),
|
||||
#[cfg(not(all(
|
||||
feature = "universal",
|
||||
feature = "shared-object",
|
||||
feature = "object-file"
|
||||
)))]
|
||||
#[cfg(not(all(feature = "universal", feature = "dylib", feature = "object-file")))]
|
||||
engine => bail!(
|
||||
"The `{}` engine is not included in this binary.",
|
||||
engine.to_string()
|
||||
@@ -366,8 +362,8 @@ impl FromStr for CompilerType {
|
||||
pub enum EngineType {
|
||||
/// Universal Engine
|
||||
Universal,
|
||||
/// Shared Object Engine
|
||||
SharedObject,
|
||||
/// Dylib Engine
|
||||
Dylib,
|
||||
/// Object File Engine
|
||||
ObjectFile,
|
||||
}
|
||||
@@ -376,7 +372,7 @@ impl ToString for EngineType {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
Self::Universal => "universal".to_string(),
|
||||
Self::SharedObject => "shared_object".to_string(),
|
||||
Self::Dylib => "dylib".to_string(),
|
||||
Self::ObjectFile => "objectfile".to_string(),
|
||||
}
|
||||
}
|
||||
@@ -420,16 +416,16 @@ impl StoreOptions {
|
||||
fn get_engine(&self) -> Result<EngineType> {
|
||||
if self.universal {
|
||||
Ok(EngineType::Universal)
|
||||
} else if self.shared_object {
|
||||
Ok(EngineType::SharedObject)
|
||||
} else if self.dylib {
|
||||
Ok(EngineType::Dylib)
|
||||
} else if self.object_file {
|
||||
Ok(EngineType::ObjectFile)
|
||||
} else {
|
||||
// Auto mode, we choose the best engine for that platform
|
||||
if cfg!(feature = "universal") {
|
||||
Ok(EngineType::Universal)
|
||||
} else if cfg!(feature = "shared-object") {
|
||||
Ok(EngineType::SharedObject)
|
||||
} else if cfg!(feature = "dylib") {
|
||||
Ok(EngineType::Dylib)
|
||||
} else if cfg!(feature = "object-file") {
|
||||
Ok(EngineType::ObjectFile)
|
||||
} else {
|
||||
@@ -449,19 +445,13 @@ impl StoreOptions {
|
||||
EngineType::Universal => {
|
||||
Arc::new(wasmer_engine_universal::Universal::headless().engine())
|
||||
}
|
||||
#[cfg(feature = "shared-object")]
|
||||
EngineType::SharedObject => {
|
||||
Arc::new(wasmer_engine_shared_object::SharedObject::headless().engine())
|
||||
}
|
||||
#[cfg(feature = "dylib")]
|
||||
EngineType::Dylib => Arc::new(wasmer_engine_dylib::Dylib::headless().engine()),
|
||||
#[cfg(feature = "object-file")]
|
||||
EngineType::ObjectFile => {
|
||||
Arc::new(wasmer_engine_object_file::ObjectFile::headless().engine())
|
||||
}
|
||||
#[cfg(not(all(
|
||||
feature = "universal",
|
||||
feature = "shared-object",
|
||||
feature = "object-file"
|
||||
)))]
|
||||
#[cfg(not(all(feature = "universal", feature = "dylib", feature = "object-file")))]
|
||||
engine => bail!(
|
||||
"The `{}` engine is not included in this binary.",
|
||||
engine.to_string()
|
||||
|
||||
Reference in New Issue
Block a user