mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Add ability to bundle extools DLL with langserver
This commit is contained in:
parent
0ccdfbde17
commit
2cef03d40e
4 changed files with 35 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ use std::env;
|
|||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
// build info
|
||||
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
let mut f = File::create(&out_dir.join("build-info.txt")).unwrap();
|
||||
|
||||
|
|
@ -14,6 +15,12 @@ fn main() {
|
|||
writeln!(f, "commit: {}", commit).unwrap();
|
||||
}
|
||||
writeln!(f, "build date: {}", chrono::Utc::today()).unwrap();
|
||||
|
||||
// extools bundling
|
||||
println!("cargo:rerun-if-env-changed=EXTOOLS_BUNDLE_DLL");
|
||||
if env::var_os("EXTOOLS_BUNDLE_DLL").is_some() {
|
||||
println!("cargo:rustc-cfg=extools_bundle");
|
||||
}
|
||||
}
|
||||
|
||||
fn read_commit() -> Result<String, git2::Error> {
|
||||
|
|
|
|||
24
src/langserver/debugger/extools_bundle.rs
Normal file
24
src/langserver/debugger/extools_bundle.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#![cfg(extools_bundle)]
|
||||
use std::io::{Result, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::fs::File;
|
||||
|
||||
const BYTES: &[u8] = include_bytes!(env!("EXTOOLS_BUNDLE_DLL"));
|
||||
|
||||
fn write(path: &Path) -> Result<()> {
|
||||
File::create(path)?.write_all(BYTES)
|
||||
}
|
||||
|
||||
pub fn extract() -> Result<PathBuf> {
|
||||
let exe = std::env::current_exe()?;
|
||||
let directory = exe.parent().unwrap();
|
||||
for i in 0..9 {
|
||||
let dll = directory.join(format!("extools{}.dll", i));
|
||||
if let Ok(()) = write(&dll) {
|
||||
return Ok(dll);
|
||||
}
|
||||
}
|
||||
let dll = directory.join("extools9.dll");
|
||||
write(&dll)?;
|
||||
Ok(dll)
|
||||
}
|
||||
|
|
@ -36,6 +36,9 @@ impl Launched {
|
|||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null());
|
||||
#[cfg(extools_bundle)] {
|
||||
command.env("EXTOOLS_DLL", super::extools_bundle::extract()?);
|
||||
}
|
||||
if let Some(port) = port {
|
||||
command.env("EXTOOLS_MODE", "LAUNCHED");
|
||||
command.env("EXTOOLS_PORT", port.to_string());
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ mod launched;
|
|||
mod extools_types;
|
||||
mod extools;
|
||||
mod local_names;
|
||||
mod extools_bundle;
|
||||
|
||||
use std::error::Error;
|
||||
use std::sync::{atomic, Arc, Mutex};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue