on master help sign in
helix-loader + helix-core now compile for WASM
9191af3Blaž Hrastnik
helix-loader/Cargo.toml+6−1
@@ -15,11 +15,16 @@ serde = { version = "1.0", features = ["derive"] }
15toml = "0.5"
15toml = "0.5"
16etcetera = "0.3"
16etcetera = "0.3"
17tree-sitter = "0.20"
17tree-sitter = "0.20"
18−libloading = "0.7"
19once_cell = "1.9"
18once_cell = "1.9"
20
19
21log = "0.4"
20log = "0.4"
22
21
22+# TODO: these two should be on !wasm32 only
23+
23# cloning/compiling tree-sitter grammars
24# cloning/compiling tree-sitter grammars
24cc = { version = "1" }
25cc = { version = "1" }
25threadpool = { version = "1.0" }
26threadpool = { version = "1.0" }
27+
28+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
29+libloading = "0.7"
30+
helix-loader/src/grammar.rs+10−1
@@ -1,5 +1,4 @@
1use anyhow::{anyhow, Context, Result};
1use anyhow::{anyhow, Context, Result};
2−use libloading::{Library, Symbol};
3use serde::{Deserialize, Serialize};
2use serde::{Deserialize, Serialize};
4use std::fs;
3use std::fs;
5use std::time::SystemTime;
4use std::time::SystemTime;
@@ -17,6 +16,9 @@ const DYLIB_EXTENSION: &str = "so";
17#[cfg(windows)]
16#[cfg(windows)]
18const DYLIB_EXTENSION: &str = "dll";
17const DYLIB_EXTENSION: &str = "dll";
19
18
19+#[cfg(target_arch = "wasm32")]
20+const DYLIB_EXTENSION: &str = "wasm";
21+
20#[derive(Debug, Serialize, Deserialize)]
22#[derive(Debug, Serialize, Deserialize)]
21struct Configuration {
23struct Configuration {
22 #[serde(rename = "use-grammars")]
24 #[serde(rename = "use-grammars")]
@@ -57,7 +59,14 @@ pub enum GrammarSource {
57const BUILD_TARGET: &str = env!("BUILD_TARGET");
59const BUILD_TARGET: &str = env!("BUILD_TARGET");
58const REMOTE_NAME: &str = "origin";
60const REMOTE_NAME: &str = "origin";
59
61
62+#[cfg(target_arch = "wasm32")]
63+pub fn get_language(name: &str) -> Result<Language> {
64+ unimplemented!()
65+}
66+
67+#[cfg(not(target_arch = "wasm32"))]
60pub fn get_language(name: &str) -> Result<Language> {
68pub fn get_language(name: &str) -> Result<Language> {
69+ use libloading::{Library, Symbol};
61 let name = name.to_ascii_lowercase();
70 let name = name.to_ascii_lowercase();
62 let mut library_path = crate::runtime_dir().join("grammars").join(&name);
71 let mut library_path = crate::runtime_dir().join("grammars").join(&name);
63 library_path.set_extension(DYLIB_EXTENSION);
72 library_path.set_extension(DYLIB_EXTENSION);