nuke the dlopen stuff

pull/8675/merge^2
mattwparas 1 year ago
parent f808fa083a
commit 81243247c6

116
Cargo.lock generated

@ -34,8 +34,8 @@ dependencies = [
"abi_stable_shared",
"as_derive_utils",
"core_extensions",
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"rustc_version",
"syn 1.0.109",
"typed-arena",
@ -152,8 +152,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff3c96645900a44cf11941c111bd08a6573b0e2f9f69bc9264b179d8fae753c4"
dependencies = [
"core_extensions",
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 1.0.109",
]
@ -465,29 +465,6 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946"
[[package]]
name = "dlopen"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e80ad39f814a9abe68583cd50a2d45c8a67561c3361ab8da240587dda80937"
dependencies = [
"dlopen_derive",
"lazy_static",
"libc",
"winapi",
]
[[package]]
name = "dlopen_derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f236d9e1b1fbd81cea0f9cbdc8dcc7e8ebcd80e6659cd7cb2ad5f6c05946c581"
dependencies = [
"libc",
"quote 0.6.13",
"syn 0.15.44",
]
[[package]]
name = "dunce"
version = "1.0.4"
@ -652,8 +629,8 @@ version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
]
@ -1531,8 +1508,6 @@ dependencies = [
"chrono",
"content_inspector",
"crossterm",
"dlopen",
"dlopen_derive",
"fern",
"futures-util",
"fuzzy-matcher",
@ -1883,8 +1858,8 @@ checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
dependencies = [
"beef",
"fnv",
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"regex-syntax 0.6.29",
"syn 1.0.109",
]
@ -2138,15 +2113,6 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid",
]
[[package]]
name = "proc-macro2"
version = "1.0.66"
@ -2192,22 +2158,13 @@ dependencies = [
"smallvec",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
]
[[package]]
name = "quote"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2 1.0.66",
"proc-macro2",
]
[[package]]
@ -2388,8 +2345,8 @@ version = "1.0.185"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
]
@ -2410,8 +2367,8 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
]
@ -2579,8 +2536,8 @@ dependencies = [
name = "steel-derive"
version = "0.4.0"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
]
@ -2615,25 +2572,14 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f026164926842ec52deb1938fae44f83dfdb82d0a5b0270c5bd5935ab74d6dd"
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid",
]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"unicode-ident",
]
@ -2643,8 +2589,8 @@ version = "2.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"unicode-ident",
]
@ -2705,8 +2651,8 @@ version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
]
@ -2799,8 +2745,8 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
]
@ -2945,12 +2891,6 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "url"
version = "2.4.0"
@ -3004,8 +2944,8 @@ dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
"wasm-bindgen-shared",
]
@ -3016,7 +2956,7 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
dependencies = [
"quote 1.0.33",
"quote",
"wasm-bindgen-macro-support",
]
@ -3026,8 +2966,8 @@ version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2 1.0.66",
"quote 1.0.33",
"proc-macro2",
"quote",
"syn 2.0.29",
"wasm-bindgen-backend",
"wasm-bindgen-shared",

@ -68,8 +68,6 @@ grep-searcher = "0.1.11"
# plugin support
steel-core = { workspace = true }
dlopen = "0.1.8"
dlopen_derive = "0.1.4"
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }

@ -1,7 +1,6 @@
pub(crate) mod dap;
pub(crate) mod engine;
pub(crate) mod lsp;
pub mod plugin;
pub(crate) mod typed;
pub use dap::*;

@ -55,7 +55,6 @@ use self::components::SteelDynamicComponent;
use super::{
indent,
insert::{insert_char, insert_string},
plugin::{DylibContainers, ExternalModule},
shell_impl, Context, MappableCommand, TYPABLE_COMMAND_LIST,
};
@ -63,11 +62,6 @@ thread_local! {
pub static ENGINE: std::rc::Rc<std::cell::RefCell<steel::steel_vm::engine::Engine>> = configure_engine();
}
pub struct ExternalContainersAndModules {
containers: DylibContainers,
modules: Vec<ExternalModule>,
}
mod components;
// pub struct PluginEngine<T: PluginSystem>(PhantomData<T>);
@ -577,7 +571,6 @@ fn run_initialization_script(cx: &mut Context) {
// TODO: Report the error from requiring the file!
ENGINE.with(|engine| {
let mut guard = engine.borrow_mut();
let res = guard.run(&format!(
@ -645,13 +638,12 @@ fn run_initialization_script(cx: &mut Context) {
// These contents need to be registered with the path?
if let Ok(contents) = std::fs::read_to_string(&helix_module_path) {
let res = guard
.run_with_reference_from_path::<Context, Context>(
cx,
"*helix.cx*",
&contents,
helix_module_path,
);
let res = guard.run_with_reference_from_path::<Context, Context>(
cx,
"*helix.cx*",
&contents,
helix_module_path,
);
match res {
Ok(_) => {}

@ -1,112 +0,0 @@
use std::{borrow::Cow, path::PathBuf, sync::Arc};
use dlopen::wrapper::{Container, WrapperApi};
use dlopen_derive::WrapperApi;
use crate::ui::PromptEvent;
use super::{CommandSignature, Context};
// use super::builtin::BuiltInModule;
#[repr(C)]
#[derive(Clone)]
pub struct ExternalModule {
pub name: Box<str>,
pub commands: Box<[CrossBoundaryTypableCommand]>,
}
impl ExternalModule {
pub fn new(name: String, commands: Vec<CrossBoundaryTypableCommand>) -> Self {
println!("Name: {}", name);
Self {
name: name.into_boxed_str(),
commands: commands.into_boxed_slice(),
}
}
pub fn get_name(&self) -> &str {
&self.name
}
}
// pub syn_loader: Arc<syntax::Loader>,
// pub theme_loader: Arc<theme::Loader>,
#[repr(C)]
#[derive(Clone)]
pub struct CrossBoundaryTypableCommand {
pub name: Box<str>,
pub aliases: Box<[String]>,
pub doc: Box<str>,
pub fun: for<'a> extern "C" fn(
&mut Context<'a>,
&helix_view::theme::Loader,
&helix_core::syntax::Loader,
Box<[Box<str>]>,
*const PromptEvent,
) -> anyhow::Result<()>,
pub signature: CommandSignature,
}
#[derive(WrapperApi, Clone)]
pub struct ModuleApi {
generate_module: fn() -> ExternalModule,
}
#[derive(Clone)]
pub(crate) struct DylibContainers {
pub(crate) containers: Vec<Arc<Container<ModuleApi>>>,
}
impl DylibContainers {
pub fn new() -> Self {
Self {
containers: Vec::new(),
}
}
pub fn load_modules_from_directory(&mut self, home: Option<String>) {
if let Some(home) = home {
let mut home = PathBuf::from(home);
home.push("native");
if home.exists() {
let paths = std::fs::read_dir(home).unwrap();
for path in paths {
println!("{:?}", path);
let path = path.unwrap().path();
if path.extension().unwrap() != "so" && path.extension().unwrap() != "dylib" {
continue;
}
let path_name = path.file_name().and_then(|x| x.to_str()).unwrap();
log::info!(target: "dylibs", "Loading dylib: {}", path_name);
// Load in the dylib
let cont: Container<ModuleApi> = unsafe { Container::load(path) }
.expect("Could not open library or load symbols");
// Keep the container alive for the duration of the program
// This should probably just get wrapped up with the engine as well, when registering modules, directly
// register an external dylib
self.containers.push(Arc::new(cont));
}
} else {
log::warn!(target: "dylibs", "$STEEL_HOME/native directory does not exist")
}
} else {
log::warn!(target: "dylibs", "STEEL_HOME variable missing - unable to read shared dylibs")
}
}
pub fn create_commands(&self) -> Vec<ExternalModule> {
self.containers
.iter()
.map(|x| x.generate_module())
.collect()
}
}
Loading…
Cancel
Save