Precompile plugins depending on target triple
This commit is contained in:
parent
4a5b8fd2e6
commit
80b45ef93b
6 changed files with 50 additions and 27 deletions
|
@ -5,30 +5,33 @@ use collections::HashMap;
|
|||
use futures::lock::Mutex;
|
||||
use gpui::executor::Background;
|
||||
use language::{LanguageServerName, LspAdapter};
|
||||
// use plugin_runtime::{Plugin, PluginBinary, PluginBuilder, WasiFn};
|
||||
use plugin_runtime::{Plugin, WasiFn};
|
||||
use plugin_runtime::{Plugin, PluginBinary, PluginBuilder, WasiFn};
|
||||
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||
use util::ResultExt;
|
||||
|
||||
// pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
|
||||
// let plugin = PluginBuilder::new_default()?
|
||||
// .host_function_async("command", |command: String| async move {
|
||||
// let mut args = command.split(' ');
|
||||
// let command = args.next().unwrap();
|
||||
// smol::process::Command::new(command)
|
||||
// .args(args)
|
||||
// .output()
|
||||
// .await
|
||||
// .log_err()
|
||||
// .map(|output| output.stdout)
|
||||
// })?
|
||||
// .init(PluginBinary::Precompiled(include_bytes!(
|
||||
// "../../../../plugins/bin/json_language.wasm.pre"
|
||||
// )))
|
||||
// .await?;
|
||||
//
|
||||
// PluginLspAdapter::new(plugin, executor).await
|
||||
// }
|
||||
#[allow(dead_code)]
|
||||
pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
|
||||
let bytes = include_bytes!(concat!(
|
||||
"../../../../plugins/bin/json_language.wasm.",
|
||||
env!("TARGET_TRIPLE"),
|
||||
));
|
||||
|
||||
let plugin = PluginBuilder::new_default()?
|
||||
.host_function_async("command", |command: String| async move {
|
||||
let mut args = command.split(' ');
|
||||
let command = args.next().unwrap();
|
||||
smol::process::Command::new(command)
|
||||
.args(args)
|
||||
.output()
|
||||
.await
|
||||
.log_err()
|
||||
.map(|output| output.stdout)
|
||||
})?
|
||||
.init(PluginBinary::Precompiled(bytes))
|
||||
.await?;
|
||||
|
||||
PluginLspAdapter::new(plugin, executor).await
|
||||
}
|
||||
|
||||
pub struct PluginLspAdapter {
|
||||
name: WasiFn<(), String>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue