Skip to content

Commit

Permalink
improve cross-compatibility of xtasks
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Jan 27, 2024
1 parent b9b4da0 commit 3d1275b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
10 changes: 8 additions & 2 deletions xtask/src/commands/copy_lsp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use xshell::{Shell, cmd};


const SRC: &str = "./target/debug/witcherscript-lsp.exe";
const SRC: &str = "./target/debug/witcherscript-lsp";
const DST: &str = "./editors/vscode/server/bin";

pub fn copy_lsp() -> anyhow::Result<()> {
Expand All @@ -10,7 +10,13 @@ pub fn copy_lsp() -> anyhow::Result<()> {
println!("Building the LSP...");
cmd!(sh, "cargo build --package witcherscript-lsp").run()?;

sh.copy_file(SRC, DST)?;
let src = if cfg!(unix) {
SRC.to_string()
} else {
format!("{SRC}.exe")
};

sh.copy_file(src, DST)?;
println!("Copied debug LSP into {}", DST);

Ok(())
Expand Down
10 changes: 8 additions & 2 deletions xtask/src/commands/copy_lsp_release.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use xshell::{Shell, cmd};


const SRC: &str = "./target/release/witcherscript-lsp.exe";
const SRC: &str = "./target/release/witcherscript-lsp";
const DST: &str = "./editors/vscode/server/bin";

pub fn copy_lsp_release() -> anyhow::Result<()> {
Expand All @@ -10,7 +10,13 @@ pub fn copy_lsp_release() -> anyhow::Result<()> {
println!("Building the LSP...");
cmd!(sh, "cargo build --package witcherscript-lsp --release").run()?;

sh.copy_file(SRC, DST)?;
let src = if cfg!(unix) {
SRC.to_string()
} else {
format!("{SRC}.exe")
};

sh.copy_file(src, DST)?;
println!("Copied release LSP into {}", DST);

Ok(())
Expand Down
10 changes: 8 additions & 2 deletions xtask/src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, bail};
use xshell::{Shell, cmd};


const LSP_SRC: &str = "./target/release/witcherscript-lsp.exe";
const LSP_SRC: &str = "./target/release/witcherscript-lsp";
const LSP_DST: &str = "./editors/vscode/server/bin";
const EXT_DIR: &str = "./editors/vscode";
const VSIX_NAME: &str = "witcherscript-ide.vsix";
Expand All @@ -13,7 +13,13 @@ pub fn install() -> anyhow::Result<()> {
println!("Building LSP release...");
cmd!(sh, "cargo build --package witcherscript-lsp --release").run()?;

sh.copy_file(LSP_SRC, LSP_DST)?;
let lsp_src = if cfg!(unix) {
LSP_SRC.to_string()
} else {
format!("{LSP_SRC}.exe")
};

sh.copy_file(lsp_src, LSP_DST)?;
println!("Copied LSP into {}", LSP_DST);

sh.change_dir(EXT_DIR);
Expand Down
10 changes: 8 additions & 2 deletions xtask/src/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Context;
use xshell::{Shell, cmd};


const LSP_SRC: &str = "./target/release/witcherscript-lsp.exe";
const LSP_SRC: &str = "./target/release/witcherscript-lsp";
const LSP_DST: &str = "./editors/vscode/server/bin";
const EXT_DIR: &str = "./editors/vscode";
const VSIX_NAME: &str = "witcherscript-ide.vsix";
Expand All @@ -13,7 +13,13 @@ pub fn package() -> anyhow::Result<()> {
println!("Building LSP release...");
cmd!(sh, "cargo build --package witcherscript-lsp --release").run()?;

sh.copy_file(LSP_SRC, LSP_DST)?;
let lsp_src = if cfg!(unix) {
LSP_SRC.to_string()
} else {
format!("{LSP_SRC}.exe")
};

sh.copy_file(lsp_src, LSP_DST)?;
println!("Copied LSP into {}", LSP_DST);


Expand Down

0 comments on commit 3d1275b

Please sign in to comment.