|
|
@ -1,5 +1,4 @@
|
|
|
|
use anyhow::{anyhow, Context, Result};
|
|
|
|
use anyhow::{anyhow, Context, Result};
|
|
|
|
use libloading::{Library, Symbol};
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::fs;
|
|
|
|
use std::fs;
|
|
|
|
use std::time::SystemTime;
|
|
|
|
use std::time::SystemTime;
|
|
|
@ -17,6 +16,9 @@ const DYLIB_EXTENSION: &str = "so";
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[cfg(windows)]
|
|
|
|
const DYLIB_EXTENSION: &str = "dll";
|
|
|
|
const DYLIB_EXTENSION: &str = "dll";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
|
|
|
|
const DYLIB_EXTENSION: &str = "wasm";
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
struct Configuration {
|
|
|
|
struct Configuration {
|
|
|
|
#[serde(rename = "use-grammars")]
|
|
|
|
#[serde(rename = "use-grammars")]
|
|
|
@ -57,7 +59,14 @@ pub enum GrammarSource {
|
|
|
|
const BUILD_TARGET: &str = env!("BUILD_TARGET");
|
|
|
|
const BUILD_TARGET: &str = env!("BUILD_TARGET");
|
|
|
|
const REMOTE_NAME: &str = "origin";
|
|
|
|
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> {
|
|
|
|
pub fn get_language(name: &str) -> Result<Language> {
|
|
|
|
|
|
|
|
use libloading::{Library, Symbol};
|
|
|
|
let name = name.to_ascii_lowercase();
|
|
|
|
let name = name.to_ascii_lowercase();
|
|
|
|
let mut library_path = crate::runtime_dir().join("grammars").join(&name);
|
|
|
|
let mut library_path = crate::runtime_dir().join("grammars").join(&name);
|
|
|
|
library_path.set_extension(DYLIB_EXTENSION);
|
|
|
|
library_path.set_extension(DYLIB_EXTENSION);
|
|
|
|