Switch from start scripts to start programs on Windows
This commit is contained in:
parent
96b6027942
commit
4e9dd07f31
@ -1 +0,0 @@
|
||||
start /min cmd.exe /c "%HOMEDRIVE%%HOMEPATH%\zx" run vapor
|
||||
93
windows/Vapor.rs
Normal file
93
windows/Vapor.rs
Normal file
@ -0,0 +1,93 @@
|
||||
// Prepare environment for ZX and launch it using erl.exe
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::string::String;
|
||||
use std::ffi::OsString;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let zomp_dir = match env::var("ZOMP_DIR") {
|
||||
Ok(v) =>
|
||||
v,
|
||||
_ =>
|
||||
String::from(Path::new(&env::var("LOCALAPPDATA").unwrap())
|
||||
.join("zomp")
|
||||
.to_str()
|
||||
.unwrap()),
|
||||
};
|
||||
env::set_var("ZOMP_DIR", OsString::from(&zomp_dir));
|
||||
|
||||
let version_path = Path::new(&zomp_dir).join("etc").join("version.txt");
|
||||
let file = File::open(version_path);
|
||||
let mut reader = BufReader::new(file.unwrap());
|
||||
let mut version = String::new();
|
||||
reader.read_line(&mut version).unwrap();
|
||||
version = version.trim().to_string();
|
||||
env::set_var("ZX_VERSION", OsString::from(&version));
|
||||
|
||||
let zx_dir = Path::new(&zomp_dir)
|
||||
.join("lib")
|
||||
.join("otpr")
|
||||
.join("zx")
|
||||
.join(version);
|
||||
env::set_var("ZX_DIR", zx_dir.to_str().unwrap());
|
||||
|
||||
let env_pf = env::var("PROGRAMFILES").unwrap();
|
||||
let pf = Path::new(&env_pf);
|
||||
let mut maj: i32 = 0;
|
||||
let mut min: i32 = 0;
|
||||
let mut best_path = PathBuf::new();
|
||||
for entry in std::fs::read_dir(pf).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let installation = path.file_name().unwrap().to_str().unwrap();
|
||||
if installation.starts_with("erl") {
|
||||
let erl_ver = installation.trim_start_matches("erl");
|
||||
let parts: Vec<&str> = erl_ver.split('.').collect();
|
||||
let m_maj: i32 = parts[0].parse().unwrap();
|
||||
let m_min: i32 = parts[1].parse().unwrap();
|
||||
if m_maj > maj {
|
||||
maj = m_maj;
|
||||
min = m_min;
|
||||
best_path.push(&path);
|
||||
} else if m_maj == maj {
|
||||
if m_min > min {
|
||||
min = m_min;
|
||||
best_path.push(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let erl = Path::new(&best_path).join("bin").join("erl.exe");
|
||||
let escript = Path::new(&best_path).join("bin").join("escript.exe");
|
||||
|
||||
let zx_ebin = Path::new(&zx_dir).join("ebin");
|
||||
let zx_beam = Path::new(&zx_ebin).join("zx.beam");
|
||||
if ! zx_beam.exists() {
|
||||
println!("Rebuilding ZX. Just a moment...");
|
||||
let pwd = env::current_dir().unwrap();
|
||||
assert!(env::set_current_dir(zx_dir).is_ok());
|
||||
Command::new(escript)
|
||||
.arg("make_zx")
|
||||
.output()
|
||||
.expect("Failed to execute make_zx escript.");
|
||||
assert!(env::set_current_dir(pwd).is_ok());
|
||||
}
|
||||
|
||||
Command::new(erl)
|
||||
.arg("-noshell")
|
||||
.arg("-pa")
|
||||
.arg(zx_ebin.to_str().unwrap())
|
||||
.arg("-run")
|
||||
.arg("zx")
|
||||
.arg("do")
|
||||
.arg("-extra")
|
||||
.arg("run")
|
||||
.arg("vapor")
|
||||
.spawn()
|
||||
.expect("Failed to start Vapor.");
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Prepare the environment for ZX and launch it
|
||||
|
||||
set ZOMP_DIR="%LOCALAPPDATA%\zomp"
|
||||
set ZOMP_DIR=%ZOMP_DIR:"=%
|
||||
set /P ZX_VERSION=<"%ZOMP_DIR%\etc\version.txt"
|
||||
set ZX_DIR=%ZOMP_DIR%\lib\otpr\zx\%ZX_VERSION%
|
||||
set ZX_DIR=%ZX_DIR:"=%
|
||||
pushd "%ZX_DIR%"
|
||||
if not exist ebin\zx.erl "C:\Program Files\erl10.6\bin\escript.exe" make_zx
|
||||
popd
|
||||
"C:\Program Files\erl10.6\bin\erl.exe" -noshell -pa "%ZX_DIR%/ebin" -run zx do -extra %*
|
||||
95
windows/zx.rs
Normal file
95
windows/zx.rs
Normal file
@ -0,0 +1,95 @@
|
||||
// Prepare environment for ZX and launch it using erl.exe
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::string::String;
|
||||
use std::ffi::OsString;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
let zomp_dir = match env::var("ZOMP_DIR") {
|
||||
Ok(v) =>
|
||||
v,
|
||||
_ =>
|
||||
String::from(Path::new(&env::var("LOCALAPPDATA").unwrap())
|
||||
.join("zomp")
|
||||
.to_str()
|
||||
.unwrap()),
|
||||
};
|
||||
env::set_var("ZOMP_DIR", OsString::from(&zomp_dir));
|
||||
|
||||
let version_path = Path::new(&zomp_dir).join("etc").join("version.txt");
|
||||
let file = File::open(version_path);
|
||||
let mut reader = BufReader::new(file.unwrap());
|
||||
let mut version = String::new();
|
||||
reader.read_line(&mut version).unwrap();
|
||||
version = version.trim().to_string();
|
||||
env::set_var("ZX_VERSION", OsString::from(&version));
|
||||
|
||||
let zx_dir = Path::new(&zomp_dir)
|
||||
.join("lib")
|
||||
.join("otpr")
|
||||
.join("zx")
|
||||
.join(version);
|
||||
env::set_var("ZX_DIR", zx_dir.to_str().unwrap());
|
||||
|
||||
let env_pf = env::var("PROGRAMFILES").unwrap();
|
||||
let pf = Path::new(&env_pf);
|
||||
let mut maj: i32 = 0;
|
||||
let mut min: i32 = 0;
|
||||
let mut best_path = PathBuf::new();
|
||||
for entry in std::fs::read_dir(pf).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let installation = path.file_name().unwrap().to_str().unwrap();
|
||||
if installation.starts_with("erl") {
|
||||
let erl_ver = installation.trim_start_matches("erl");
|
||||
let parts: Vec<&str> = erl_ver.split('.').collect();
|
||||
let m_maj: i32 = parts[0].parse().unwrap();
|
||||
let m_min: i32 = parts[1].parse().unwrap();
|
||||
if m_maj > maj {
|
||||
maj = m_maj;
|
||||
min = m_min;
|
||||
best_path.push(&path);
|
||||
} else if m_maj == maj {
|
||||
if m_min > min {
|
||||
min = m_min;
|
||||
best_path.push(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let erl = Path::new(&best_path).join("bin").join("erl.exe");
|
||||
let escript = Path::new(&best_path).join("bin").join("escript.exe");
|
||||
|
||||
let zx_ebin = Path::new(&zx_dir).join("ebin");
|
||||
let zx_beam = Path::new(&zx_ebin).join("zx.beam");
|
||||
if ! zx_beam.exists() {
|
||||
println!("Rebuilding ZX. Just a moment...");
|
||||
let pwd = env::current_dir().unwrap();
|
||||
assert!(env::set_current_dir(zx_dir).is_ok());
|
||||
Command::new(escript)
|
||||
.arg("make_zx")
|
||||
.output()
|
||||
.expect("Failed to execute make_zx escript.");
|
||||
assert!(env::set_current_dir(pwd).is_ok());
|
||||
}
|
||||
|
||||
let output = Command::new(erl)
|
||||
.arg("-noshell")
|
||||
.arg("-pa")
|
||||
.arg(zx_ebin.to_str().unwrap())
|
||||
.arg("-run")
|
||||
.arg("zx")
|
||||
.arg("do")
|
||||
.arg("-extra")
|
||||
.args(&args[1..])
|
||||
.output()
|
||||
.expect("Failed to start ZX.");
|
||||
std::io::stdout().write_all(&output.stdout).unwrap();
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Prepare the environment for ZX and launch it
|
||||
|
||||
set ZOMP_DIR="%LOCALAPPDATA%\zomp"
|
||||
set ZOMP_DIR=%ZOMP_DIR:"=%
|
||||
set /P ZX_VERSION=<"%ZOMP_DIR%\etc\version.txt"
|
||||
set ZX_DIR=%ZOMP_DIR%\lib\otpr\zx\%ZX_VERSION%
|
||||
set ZX_DIR=%ZX_DIR:"=%
|
||||
pushd "%ZX_DIR%"
|
||||
if not exist ebin\zx.erl "C:\Program Files\erl10.6\bin\escript.exe" make_zx
|
||||
popd
|
||||
"C:\Program Files\erl10.6\bin\werl.exe" -pa "%ZX_DIR%/ebin" -run zx do -extra %*
|
||||
102
windows/zxh.rs
Normal file
102
windows/zxh.rs
Normal file
@ -0,0 +1,102 @@
|
||||
// Prepare environment for ZX and launch it using werl.exe
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::string::String;
|
||||
use std::ffi::OsString;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
let zomp_dir = match env::var("ZOMP_DIR") {
|
||||
Ok(v) =>
|
||||
v,
|
||||
_ =>
|
||||
String::from(Path::new(&env::var("LOCALAPPDATA").unwrap())
|
||||
.join("zomp")
|
||||
.to_str()
|
||||
.unwrap()),
|
||||
};
|
||||
env::set_var("ZOMP_DIR", OsString::from(&zomp_dir));
|
||||
println!("ZOMP_DIR: {}", zomp_dir);
|
||||
|
||||
let version_path = Path::new(&zomp_dir).join("etc").join("version.txt");
|
||||
let file = File::open(version_path);
|
||||
let mut reader = BufReader::new(file.unwrap());
|
||||
let mut version = String::new();
|
||||
reader.read_line(&mut version).unwrap();
|
||||
version = version.trim().to_string();
|
||||
env::set_var("ZX_VERSION", OsString::from(&version));
|
||||
println!("ZX_VERSION: {}", version);
|
||||
|
||||
let zx_dir = Path::new(&zomp_dir)
|
||||
.join("lib")
|
||||
.join("otpr")
|
||||
.join("zx")
|
||||
.join(version);
|
||||
env::set_var("ZX_DIR", zx_dir.to_str().unwrap());
|
||||
println!("ZX_DIR: {}", zx_dir.to_str().unwrap());
|
||||
|
||||
let env_pf = env::var("PROGRAMFILES").unwrap();
|
||||
let pf = Path::new(&env_pf);
|
||||
let mut maj: i32 = 0;
|
||||
let mut min: i32 = 0;
|
||||
let mut best_path = PathBuf::new();
|
||||
for entry in std::fs::read_dir(pf).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let installation = path.file_name().unwrap().to_str().unwrap();
|
||||
if installation.starts_with("erl") {
|
||||
let erl_ver = installation.trim_start_matches("erl");
|
||||
let parts: Vec<&str> = erl_ver.split('.').collect();
|
||||
let m_maj: i32 = parts[0].parse().unwrap();
|
||||
let m_min: i32 = parts[1].parse().unwrap();
|
||||
if m_maj > maj {
|
||||
maj = m_maj;
|
||||
min = m_min;
|
||||
best_path.push(&path);
|
||||
} else if m_maj == maj {
|
||||
if m_min > min {
|
||||
min = m_min;
|
||||
best_path.push(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let werl = Path::new(&best_path).join("bin").join("werl.exe");
|
||||
println!("werl.exe path: {}", werl.to_str().unwrap());
|
||||
|
||||
let escript = Path::new(&best_path).join("bin").join("escript.exe");
|
||||
println!("escript.exe path: {}", escript.to_str().unwrap());
|
||||
|
||||
let zx_ebin = Path::new(&zx_dir).join("ebin");
|
||||
let zx_beam = Path::new(&zx_ebin).join("zx.beam");
|
||||
println!("zx.beam path: {}", zx_beam.to_str().unwrap());
|
||||
if ! zx_beam.exists() {
|
||||
println!("Rebuilding ZX. Just a moment...");
|
||||
let pwd = env::current_dir().unwrap();
|
||||
assert!(env::set_current_dir(zx_dir).is_ok());
|
||||
Command::new(escript)
|
||||
.arg("make_zx")
|
||||
.output()
|
||||
.expect("Failed to execute make_zx escript.");
|
||||
assert!(env::set_current_dir(pwd).is_ok());
|
||||
} else {
|
||||
println!("ZX found. Running.");
|
||||
}
|
||||
|
||||
Command::new(werl)
|
||||
.arg("-pa")
|
||||
.arg(zx_ebin.to_str().unwrap())
|
||||
.arg("-run")
|
||||
.arg("zx")
|
||||
.arg("do")
|
||||
.arg("-extra")
|
||||
.args(&args[1..])
|
||||
.spawn()
|
||||
.expect("Failed to start ZX.");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user