Skip to content

Commit

Permalink
Feature/exe files (#3)
Browse files Browse the repository at this point in the history
* :)

* exe compilation workign kinda

* compiling working

* started with settings

* fix cancel button

* added custom c#-compiler path

* find out cec path

* add update app card

* added updates

* disable updates for now as we dont have code singing

* bump version

* cleanup

* fix all
  • Loading branch information
mono424 authored Jan 16, 2023
1 parent 0f10baa commit 6b7daeb
Show file tree
Hide file tree
Showing 18 changed files with 875 additions and 77 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "drawbridge",
"private": true,
"version": "0.0.2",
"version": "0.0.3",
"type": "module",
"scripts": {
"dev": "vite dev",
Expand Down
189 changes: 188 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "drawbridge"
version = "0.0.2"
version = "0.0.3"
description = "A Tauri App"
authors = ["Khadim Fall"]
license = ""
Expand All @@ -17,7 +17,7 @@ tonic-build = "0.8.4"
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["dialog-open", "dialog-save", "shell-open", "window-all"] }
tauri = { version = "1.2", features = ["dialog-open", "dialog-save", "shell-open", "updater", "window-all"] }
tonic = "0.8.3"
tokio = { version = "1.24.1", features = ["macros", "rt-multi-thread"] }
prost = "0.11.5"
Expand All @@ -26,6 +26,8 @@ futures = "0.3.25"
async-trait = "0.1.60"
directories = "4.0.1"
base64 = "0.21.0"
regex = "1.7.1"
rust-embed = "6.4.2"

[features]
# by default Tauri runs in production mode
Expand Down
Binary file added src-tauri/public/win/icon.ico
Binary file not shown.
37 changes: 8 additions & 29 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
)]

#[cfg(target_family = "windows")]
mod win_cmd;
mod win_bat;

#[cfg(target_family = "windows")]
mod win_exe;

mod driver;
mod storage;
Expand Down Expand Up @@ -66,42 +69,18 @@ fn os_create_shortcut(output: String, id: String) -> bool {

#[cfg(target_family = "windows")]
fn os_create_shortcut(output: String, id: String) -> bool {
use directories::ProjectDirs;
use fs::File;
use std::fs;
use std::io::Write;

let exec_path;
match env::current_exe() {
Ok(exe_path) => exec_path = exe_path.display().to_string(),
Err(_) => return false,
};

let mut bat_file;
if let Some(proj_dirs) = ProjectDirs::from("im", "khad", "drawbridge") {
bat_file = proj_dirs.data_local_dir().to_path_buf();
bat_file.push(format!("engine_{}.bat", id));

let file = File::create(bat_file.clone());
if let Err(_err) = file.unwrap().write_all(format!("\"{}\" connect {}", exec_path, id).as_bytes()) {
return false;
}
if output.ends_with(".exe") {
win_exe::compile_cs_file(exec_path, id, output).unwrap();
} else {
return false;
win_bat::create_bat_shortcut(exec_path, id, output).unwrap();
}

win_cmd::run_temp_script(
format!(
"
Set oWS = WScript.CreateObject(\"WScript.Shell\")
Set oLink = oWS.CreateShortcut(\"{}\")
oLink.TargetPath = \"{}\"
oLink.Arguments = \"connect {}\"
oLink.IconLocation = \"{}, 0\"
oLink.Save()
", output, bat_file.to_string_lossy(), id, exec_path),
"mk_shortcut.vbs",
).unwrap();

return true;
}

Expand Down
Loading

0 comments on commit 6b7daeb

Please sign in to comment.