Skip to content

Commit b92293b

Browse files
perehonchukfacebook-github-bot
authored andcommitted
specify escript path from cli
Summary: the same as previous diff but for `escript` Reviewed By: alanz Differential Revision: D56197690 fbshipit-source-id: d40eaf1b3be15331373ed5db9000ff4b62ecaf89
1 parent 0d5865c commit b92293b

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

crates/elp/src/bin/args.rs

+2
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ pub struct Args {
328328
pub log_file: Option<PathBuf>,
329329
#[bpaf(argument("ERL"))]
330330
pub erl: Option<PathBuf>,
331+
#[bpaf(argument("ESCRIPT"))]
332+
pub escript: Option<PathBuf>,
331333
pub no_log_buffering: bool,
332334
#[bpaf(external(command))]
333335
pub command: Command,

crates/elp/src/bin/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use bpaf::batteries;
1919
use elp::cli;
2020
use elp::cli::Cli;
2121
use elp::ServerSetup;
22+
use elp_ide::erlang_service::ESCRIPT;
2223
use elp_log::timeit;
2324
use elp_log::FileLogger;
2425
use elp_log::Logger;
@@ -85,6 +86,12 @@ fn setup_static(args: &Args) {
8586
let mut erl = ERL.write().unwrap();
8687
*erl = path.to_string_lossy().to_string();
8788
}
89+
90+
if let Some(escript) = &args.escript {
91+
let path = fs::canonicalize(escript).expect("escript path should be valid");
92+
let mut escript = ESCRIPT.write().unwrap();
93+
*escript = path.to_string_lossy().to_string();
94+
}
8895
}
8996

9097
fn try_main(cli: &mut dyn Cli, args: Args) -> Result<()> {

crates/elp/src/resources/test/help.stdout

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
Usage: [--log-file LOG_FILE] [--erl ERL] [--no-log-buffering] [COMMAND ...]
1+
Usage: [--log-file LOG_FILE] [--erl ERL] [--escript ESCRIPT] [--no-log-buffering] [COMMAND ...]
22

33
Available options:
44
--log-file <LOG_FILE>
55
--erl <ERL>
6+
--escript <ESCRIPT>
67
--no-log-buffering
78
-h, --help Prints help information
89

crates/erlang_service/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::process::ChildStdout;
1919
use std::process::Command;
2020
use std::process::Stdio;
2121
use std::sync::Arc;
22+
use std::sync::RwLock;
2223
use std::time::Duration;
2324

2425
use anyhow::anyhow;
@@ -46,6 +47,10 @@ use text_size::TextRange;
4647

4748
pub mod common_test;
4849

50+
lazy_static! {
51+
pub static ref ESCRIPT: RwLock<String> = RwLock::new("escript".to_string());
52+
}
53+
4954
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
5055
pub enum DiagnosticLocation {
5156
Normal(TextRange),
@@ -324,7 +329,9 @@ impl Connection {
324329
let mut escript = Builder::new().prefix("erlang_service").tempfile()?;
325330
escript.write_all(escript_src)?;
326331

327-
let mut cmd = Command::new("escript");
332+
let escript_bin = ESCRIPT.read().unwrap();
333+
334+
let mut cmd = Command::new(&*escript_bin);
328335
cmd.arg(escript.path());
329336

330337
cmd.stdin(Stdio::piped())

0 commit comments

Comments
 (0)