aboutsummaryrefslogtreecommitdiff
path: root/helix-loader
diff options
context:
space:
mode:
Diffstat (limited to 'helix-loader')
-rw-r--r--helix-loader/Cargo.toml7
-rw-r--r--helix-loader/src/grammar.rs11
2 files changed, 16 insertions, 2 deletions
diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml
index 607d1a0a..c8cbf6d1 100644
--- a/helix-loader/Cargo.toml
+++ b/helix-loader/Cargo.toml
@@ -15,11 +15,16 @@ serde = { version = "1.0", features = ["derive"] }
toml = "0.5"
etcetera = "0.3"
tree-sitter = "0.20"
-libloading = "0.7"
once_cell = "1.9"
log = "0.4"
+# TODO: these two should be on !wasm32 only
+
# cloning/compiling tree-sitter grammars
cc = { version = "1" }
threadpool = { version = "1.0" }
+
+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
+libloading = "0.7"
+
diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs
index 9d63a2be..df88f24b 100644
--- a/helix-loader/src/grammar.rs
+++ b/helix-loader/src/grammar.rs
@@ -1,5 +1,4 @@
use anyhow::{anyhow, Context, Result};
-use libloading::{Library, Symbol};
use serde::{Deserialize, Serialize};
use std::fs;
use std::time::SystemTime;
@@ -17,6 +16,9 @@ const DYLIB_EXTENSION: &str = "so";
#[cfg(windows)]
const DYLIB_EXTENSION: &str = "dll";
+#[cfg(target_arch = "wasm32")]
+const DYLIB_EXTENSION: &str = "wasm";
+
#[derive(Debug, Serialize, Deserialize)]
struct Configuration {
#[serde(rename = "use-grammars")]
@@ -57,7 +59,14 @@ pub enum GrammarSource {
const BUILD_TARGET: &str = env!("BUILD_TARGET");
const REMOTE_NAME: &str = "origin";
+#[cfg(target_arch = "wasm32")]
+pub fn get_language(name: &str) -> Result<Language> {
+ unimplemented!()
+}
+
+#[cfg(not(target_arch = "wasm32"))]
pub fn get_language(name: &str) -> Result<Language> {
+ use libloading::{Library, Symbol};
let name = name.to_ascii_lowercase();
let mut library_path = crate::runtime_dir().join("grammars").join(&name);
library_path.set_extension(DYLIB_EXTENSION);