Add new make-file-executable
API for extensions (#10047)
This PR adds a new function, `make-file-executable`, to the Zed extension API that can be used to mark a given file as executable (typically the language server binary). This is available in v0.0.5 of the `zed_extension_api` crate. We also reworked how we represent the various WIT versions on disk to make it a bit clearer what the version number entails. Release Notes: - N/A --------- Co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
6e49a2460e
commit
8b586ef8e7
13 changed files with 97 additions and 46 deletions
|
@ -1,5 +1,5 @@
|
|||
mod v0_0_1;
|
||||
mod v0_0_4;
|
||||
mod since_v0_0_1;
|
||||
mod since_v0_0_4;
|
||||
|
||||
use super::{wasm_engine, WasmState};
|
||||
use anyhow::{Context, Result};
|
||||
|
@ -11,7 +11,7 @@ use wasmtime::{
|
|||
Store,
|
||||
};
|
||||
|
||||
use v0_0_4 as latest;
|
||||
use since_v0_0_4 as latest;
|
||||
|
||||
pub use latest::{Command, LanguageServerConfig};
|
||||
|
||||
|
@ -30,12 +30,12 @@ fn wasi_view(state: &mut WasmState) -> &mut WasmState {
|
|||
|
||||
/// Returns whether the given Wasm API version is supported by the Wasm host.
|
||||
pub fn is_supported_wasm_api_version(version: SemanticVersion) -> bool {
|
||||
v0_0_1::VERSION <= version && version <= v0_0_4::VERSION
|
||||
since_v0_0_1::MIN_VERSION <= version && version <= latest::MAX_VERSION
|
||||
}
|
||||
|
||||
pub enum Extension {
|
||||
V004(v0_0_4::Extension),
|
||||
V001(v0_0_1::Extension),
|
||||
V004(since_v0_0_4::Extension),
|
||||
V001(since_v0_0_1::Extension),
|
||||
}
|
||||
|
||||
impl Extension {
|
||||
|
@ -44,17 +44,23 @@ impl Extension {
|
|||
version: SemanticVersion,
|
||||
component: &Component,
|
||||
) -> Result<(Self, Instance)> {
|
||||
if version < latest::VERSION {
|
||||
let (extension, instance) =
|
||||
v0_0_1::Extension::instantiate_async(store, &component, v0_0_1::linker())
|
||||
.await
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
if version < latest::MIN_VERSION {
|
||||
let (extension, instance) = since_v0_0_1::Extension::instantiate_async(
|
||||
store,
|
||||
&component,
|
||||
since_v0_0_1::linker(),
|
||||
)
|
||||
.await
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok((Self::V001(extension), instance))
|
||||
} else {
|
||||
let (extension, instance) =
|
||||
v0_0_4::Extension::instantiate_async(store, &component, v0_0_4::linker())
|
||||
.await
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
let (extension, instance) = since_v0_0_4::Extension::instantiate_async(
|
||||
store,
|
||||
&component,
|
||||
since_v0_0_4::linker(),
|
||||
)
|
||||
.await
|
||||
.context("failed to instantiate wasm extension")?;
|
||||
Ok((Self::V004(extension), instance))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue