mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-22 16:35:33 +00:00
fix(c-api): Make all the engines in the top-level enum visible, then use is_engine_available
to match
This commit is contained in:
20
Makefile
20
Makefile
@ -559,7 +559,7 @@ build-docs-capi:
|
||||
|
||||
build-capi:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
--no-default-features --features wat,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) --locked
|
||||
--no-default-features --features wat,sys-default,compiler,wasi,middlewares,webc_runner $(capi_compiler_features) --locked
|
||||
|
||||
build-capi-singlepass:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
@ -585,9 +585,21 @@ build-capi-llvm-universal:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
--no-default-features --features wat,compiler,llvm,wasi,middlewares,webc_runner --locked
|
||||
|
||||
build-capi-v8:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
--no-default-features --features wat,v8-default,wasi --locked
|
||||
|
||||
build-capi-wamr:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
--no-default-features --features wat,wamr-default,wasi --locked
|
||||
|
||||
build-capi-wasmi:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
--no-default-features --features wat,wasmi-default,wasi --locked
|
||||
|
||||
build-capi-jsc:
|
||||
RUSTFLAGS="${RUSTFLAGS}" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
|
||||
--no-default-features --features wat,jsc,wasi --locked
|
||||
--no-default-features --features wat,jsc-default,wasi --locked
|
||||
|
||||
# Headless (we include the minimal to be able to run)
|
||||
|
||||
@ -703,6 +715,10 @@ test-capi-ci: $(foreach compiler_engine,$(capi_compilers_engines),test-capi-crat
|
||||
# compilers first
|
||||
test-capi: build-capi package-capi test-capi-ci
|
||||
|
||||
test-capi-v8: build-capi-v8 package-capi test-capi-integration-v8
|
||||
test-capi-wasmi: build-capi-wasmi package-capi test-capi-integration-wasmi
|
||||
test-capi-wamr: build-capi-wamr package-capi test-capi-integration-wamr
|
||||
|
||||
test-capi-jsc: build-capi-jsc package-capi test-capi-integration-jsc
|
||||
|
||||
test-capi-crate-%:
|
||||
|
@ -4,6 +4,7 @@ use super::unstable::features::wasmer_features_t;
|
||||
use wasmer_api::Engine;
|
||||
|
||||
mod config;
|
||||
#[allow(unused_imports)]
|
||||
pub use config::*;
|
||||
|
||||
/// Kind of engines that can be used by the store.
|
||||
@ -15,22 +16,18 @@ pub use config::*;
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum wasmer_engine_t {
|
||||
/// The sys (cranelift, llvm, or singlepass) backend.
|
||||
#[cfg(feature = "sys")]
|
||||
UNIVERSAL = 0,
|
||||
|
||||
#[cfg(feature = "v8")]
|
||||
/// The V8 backend.
|
||||
V8,
|
||||
|
||||
#[cfg(feature = "wasmi")]
|
||||
/// The WASMI backend.
|
||||
WASMI,
|
||||
|
||||
#[cfg(feature = "wamr")]
|
||||
/// The WAMR backend.
|
||||
WAMR,
|
||||
|
||||
#[cfg(feature = "jsc")]
|
||||
/// The JSC backend.
|
||||
JSC,
|
||||
}
|
||||
|
||||
@ -64,7 +61,6 @@ impl Default for wasmer_engine_t {
|
||||
// features.
|
||||
//
|
||||
// See the impl of `Default` for `BackendEngine` in the `wasmer` (API) crate.
|
||||
#[derive(Default)]
|
||||
pub struct wasm_engine_t {
|
||||
pub(crate) inner: Engine,
|
||||
}
|
||||
@ -130,7 +126,8 @@ pub extern "C" fn wasm_engine_new_with_config(
|
||||
#[cfg(feature = "wamr")]
|
||||
wasmer_engine_t::WAMR => config::wamr::wasm_wamr_engine_new_with_config(config),
|
||||
#[cfg(feature = "jsc")]
|
||||
wasmer_engine_t::JSC => config::jsc::wasm_jsc_engine_new_sys_with_config(config),
|
||||
wasmer_engine_t::JSC => config::jsc::wasm_jsc_engine_new_with_config(config),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,13 @@ pub extern "C" fn wasmer_is_headless() -> bool {
|
||||
/// compiled library.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasmer_is_engine_available(engine: wasmer_engine_t) -> bool {
|
||||
matches!(engine, wasmer_engine_t::UNIVERSAL if cfg!(feature = "compiler"))
|
||||
match engine {
|
||||
wasmer_engine_t::UNIVERSAL => cfg!(feature = "sys"),
|
||||
wasmer_engine_t::V8 => cfg!(feature = "v8"),
|
||||
wasmer_engine_t::WASMI => cfg!(feature = "wasmi"),
|
||||
wasmer_engine_t::WAMR => cfg!(feature = "wamr"),
|
||||
wasmer_engine_t::JSC => cfg!(feature = "wasmi"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user