From 067464ed85f1b1b3cbe43a54aa5e39b2442239b3 Mon Sep 17 00:00:00 2001 From: joelgomes1994 Date: Mon, 17 Jan 2022 09:41:47 -0300 Subject: [PATCH 01/13] project: add base rust project of launcher --- .gitignore | 1 + source/launcher/.cargo/config.toml | 2 + source/launcher/Cargo.lock | 133 +++++++++++++++++++++++++++++ source/launcher/Cargo.toml | 11 +++ source/launcher/src/main.rs | 45 ++++++++++ 5 files changed, 192 insertions(+) create mode 100644 source/launcher/.cargo/config.toml create mode 100644 source/launcher/Cargo.lock create mode 100644 source/launcher/Cargo.toml create mode 100644 source/launcher/src/main.rs diff --git a/.gitignore b/.gitignore index aa62a9d..cad23d7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ __pycache__ /data.dat /launcher/launcher.py /source/tools/Windows/ResourceHacker.ini +/source/launcher/target \ No newline at end of file diff --git a/source/launcher/.cargo/config.toml b/source/launcher/.cargo/config.toml new file mode 100644 index 0000000..6431540 --- /dev/null +++ b/source/launcher/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-C", "link-args=-no-pie"] \ No newline at end of file diff --git a/source/launcher/Cargo.lock b/source/launcher/Cargo.lock new file mode 100644 index 0000000..d4e1637 --- /dev/null +++ b/source/launcher/Cargo.lock @@ -0,0 +1,133 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bgarmor" +version = "0.1.0" +dependencies = [ + "clap", + "json", + "subprocess", +] + +[[package]] +name = "bitflags" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "json" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" + +[[package]] +name = "libc" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "subprocess" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "055cf3ebc2981ad8f0a5a17ef6652f652d87831f79fddcba2ac57bcb9a0aa407" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/source/launcher/Cargo.toml b/source/launcher/Cargo.toml new file mode 100644 index 0000000..162556f --- /dev/null +++ b/source/launcher/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "bgarmor" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +json = "0.12.4" +clap = "2.33.3" +subprocess = "0.2.8" \ No newline at end of file diff --git a/source/launcher/src/main.rs b/source/launcher/src/main.rs new file mode 100644 index 0000000..23d187a --- /dev/null +++ b/source/launcher/src/main.rs @@ -0,0 +1,45 @@ +use std::path::Path; +use clap::{Arg, App}; +use std::fs; +use json; + +fn main() { + let config_file = "./launcher.json"; + let config = Path::new(config_file); + + let matches = App::new("BGArmor Launcher") + .version("0.1.0") + .author("Joel Gomes da Silva ") + .about("BGE and UPBGE source code obfuscator and launcher toolchain.") + .arg(Arg::with_name("console") + .short("c") + .long("console") + .help("Enable console window")) + .arg(Arg::with_name("log") + .short("l") + .long("log") + .help("Log messages in console")) + .arg(Arg::with_name("args") + .short("a") + .long("args") + .takes_value(true) + .help("Pass arguments to engine executable (in quotes)")) + .get_matches(); + + if config.exists() { + + let config = json::parse( + fs::read_to_string(config) + .expect("X Could not read launcher.json") + .as_str()) + .unwrap(); + + if matches.is_present("args") { + println!("{}", matches.value_of("args").unwrap()); + } + println!("{}: {}", config["GameName"], matches.is_present("args")); + + } else { + println!("X Could not find file launcher.json"); + } +} From 2c1c802270e652aa65d6e22a2597cbbb888d406f Mon Sep 17 00:00:00 2001 From: joelgomes1994 Date: Mon, 17 Jan 2022 09:42:06 -0300 Subject: [PATCH 02/13] project: add rust launcher makefile --- Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..24c1f98 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +ifdef OS + TARGET = i686-pc-windows-gnu + DELETE = del /Q + COPY = copy /-Y + EXT = .exe + END = && + SOURCE_EXE = ".\target\$(TARGET)\release\bgarmor$(EXT)" + TARGET_EXE = "..\..\BGArmor$(EXT)" +else + TARGET = i686-unknown-linux-gnu + DELETE = rm -f + COPY = cp -f + EXT = + END = ; + SOURCE_EXE = "./target/$(TARGET)/release/bgarmor$(EXT)" + TARGET_EXE = "../../BGArmor$(EXT)" +endif + +build: + cd "./source/launcher/" $(END) \ + $(DELETE) $(TARGET_EXE) $(END) \ + cargo build --target=$(TARGET) --release $(END) \ + $(COPY) $(SOURCE_EXE) $(TARGET_EXE) $(END) \ + upx -5 $(TARGET_EXE) From a0b6c9aa8b0a90ec42f7cdd890b3162c3b030e47 Mon Sep 17 00:00:00 2001 From: joelgomes1994 Date: Mon, 17 Jan 2022 09:51:16 -0300 Subject: [PATCH 03/13] project: remove old C launcher --- lin-build-launcher.sh | 16 -- source/Launcher.c | 189 ------------------ .../Common/helper_scripts/build_launcher.py | 42 ---- win-build-launcher.bat | 16 -- 4 files changed, 263 deletions(-) delete mode 100755 lin-build-launcher.sh delete mode 100644 source/Launcher.c delete mode 100644 source/tools/Common/helper_scripts/build_launcher.py delete mode 100644 win-build-launcher.bat diff --git a/lin-build-launcher.sh b/lin-build-launcher.sh deleted file mode 100755 index c3f6c0e..0000000 --- a/lin-build-launcher.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -echo "----------------------------------" -echo "BGArmor Executable Builder - Linux" -echo "----------------------------------" -echo - -source './source/tools/Linux/get-python.sh' - -if [ ! -z $PYTHON_EXECUTABLE ]; then - $PYTHON_EXECUTABLE './source/tools/Common/helper_scripts/build_launcher.py' - rm -f Launcher.o -fi - -echo -echo "Done!" -read -p "Press any key to continue..." diff --git a/source/Launcher.c b/source/Launcher.c deleted file mode 100644 index ec551d7..0000000 --- a/source/Launcher.c +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include - -#define LINE_BUFFER_LENGTH 512 -#define COMMAND_BUFFER_LENGTH 2048 - -#ifdef _WIN32 - #ifdef _WIN32_WINNT - #undef _WIN32_WINNT - #endif - #define _WIN32_WINNT 0x0500 - #include - const char* COMMON_FILE_PATH = "./launcher/Windows/python_executable.txt"; - const char* COMMON_FILE_PATH_32 = "./launcher/Windows32/python_executable.txt"; - const char* COMMON_FILE_PATH_64 = "./launcher/Windows64/python_executable.txt"; - const char* COMMAND_PREFIX = "ECHO OFF && "; - const char* DEFAULT_QUOTE = "\""; -#elif defined(__unix__) - const char* COMMON_FILE_PATH = "./launcher/Linux/python_executable.txt"; - const char* COMMON_FILE_PATH_32 = "./launcher/Linux32/python_executable.txt"; - const char* COMMON_FILE_PATH_64 = "./launcher/Linux64/python_executable.txt"; - const char* COMMAND_PREFIX = ""; - const char* DEFAULT_QUOTE = "'"; -#endif - -typedef struct { - int readSuccess; // Set to 1 when all obligatory files are found - char pythonExecutable[LINE_BUFFER_LENGTH]; - char launcherScript[LINE_BUFFER_LENGTH]; -} Common; - -unsigned char logMessages = 0; - -void copyStringChunk(char* source, char* target, const char from, const char to) { - int started = 0; - - while (*source != from && *source != '\0') { - source++; - if (*source == from) { - started = 1; - source++; - break; - } - } - while (started && *source != '\0' && *source != to) { - *target = *source; - target++; - source++; - - if (*source == to) { - *target = '\0'; - started = 0; - } - } -} - -void getPathFromCommon(Common* common) { - const char* DEFAULT_LAUNCHER_SCRIPT = "./source/launcher.py"; - const char* FALLBACK_LAUNCHER_SCRIPT = "./launcher/launcher.py"; - char buffer[LINE_BUFFER_LENGTH]; - FILE* filePointer = fopen(COMMON_FILE_PATH, "r"); - - if (filePointer == NULL) { - if (logMessages) printf("X Not found: %s\n", COMMON_FILE_PATH); - filePointer = fopen(COMMON_FILE_PATH_32, "r"); - } - - if (filePointer == NULL) { - if (logMessages) printf("X Not found: %s\n", COMMON_FILE_PATH_32); - filePointer = fopen(COMMON_FILE_PATH_64, "r"); - } - - if (filePointer != NULL) { - while(fgets(buffer, LINE_BUFFER_LENGTH, filePointer) != NULL) { - if (strstr(buffer, "PYTHON_EXECUTABLE") != NULL) - copyStringChunk(buffer, common->pythonExecutable, *DEFAULT_QUOTE, *DEFAULT_QUOTE); - } - fclose(filePointer); - } - else { - if (logMessages) printf("X Not found: %s\n", COMMON_FILE_PATH_64); - return; - } - filePointer = fopen(DEFAULT_LAUNCHER_SCRIPT, "r"); - - if (filePointer) { - strcpy(common->launcherScript, DEFAULT_LAUNCHER_SCRIPT); - fclose(filePointer); - } - else { - if (logMessages) printf("X Not found: %s\n", DEFAULT_LAUNCHER_SCRIPT); - filePointer = fopen(FALLBACK_LAUNCHER_SCRIPT, "r"); - if (filePointer) { - strcpy(common->launcherScript, FALLBACK_LAUNCHER_SCRIPT); - fclose(filePointer); - } - else { - if (logMessages) printf("X Not found: %s\n", FALLBACK_LAUNCHER_SCRIPT); - return; - } - } - common->readSuccess = 1; -} - -int main(int argc, char** argv) { - Common common; - common.readSuccess = 0; - char command[COMMAND_BUFFER_LENGTH]; - char extraArgs[COMMAND_BUFFER_LENGTH]; - int showConsole = 0; - const char* HELP_TEXT = "\nLAUNCHER COMMAND LINE ARGUMENTS:\n\n" - "-c or --console\tEnable console window.\n" - "-h or --help \tShow this help text.\n" - "-l or --log \tLog messages in console.\n"; - - // Cleanup strings - strcpy(common.launcherScript, ""); - strcpy(common.pythonExecutable, ""); - strcpy(command, ""); - strcpy(extraArgs, ""); - - // Loop over arguments - if (argc > 1) { - int i; - for (i = 1; i < argc; i++) { - // Enable console view - if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--console")) { - showConsole = 1; - strcat(extraArgs, " -c"); - } - // Show help text and exit - else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { - printf("%s\n", HELP_TEXT); - return 0; - } - // Show log messages - else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--log")) { - logMessages = 1; - } - // Add extra args to pass towards Python script - else { - strcat(extraArgs, " "); - strcat(extraArgs, argv[i]); - } - } - } - - #ifdef _WIN32 - HWND hWnd = GetConsoleWindow(); - if (!showConsole) { - ShowWindow(hWnd, SW_MINIMIZE); - ShowWindow(hWnd, SW_HIDE); - } - #endif - - getPathFromCommon(&common); - - if (common.readSuccess) { - if (logMessages) printf("> Python path: %s\n> Launcher script path: %s\n\n", common.pythonExecutable, common.launcherScript); - - #ifdef __unix__ - strcat(command, "chmod +x "); - strcat(command, COMMAND_PREFIX); - strcat(command, DEFAULT_QUOTE); - strcat(command, common.pythonExecutable); - strcat(command, DEFAULT_QUOTE); - if (logMessages) printf("Command: %s\n", command); - system(command); - strcpy(command, ""); - #endif - - strcat(command, COMMAND_PREFIX); - strcat(command, DEFAULT_QUOTE); - strcat(command, common.pythonExecutable); - strcat(command, DEFAULT_QUOTE); - strcat(command, " "); - strcat(command, DEFAULT_QUOTE); - strcat(command, common.launcherScript); - strcat(command, DEFAULT_QUOTE); - strcat(command, extraArgs); - - if (logMessages) printf("Command: %s\n\n", command); - system(command); - } - else { - printf("X Could not read python executable or launcher path!\n"); - } -} diff --git a/source/tools/Common/helper_scripts/build_launcher.py b/source/tools/Common/helper_scripts/build_launcher.py deleted file mode 100644 index d8e064b..0000000 --- a/source/tools/Common/helper_scripts/build_launcher.py +++ /dev/null @@ -1,42 +0,0 @@ -import os -import platform -import subprocess -from pathlib import Path -from ast import literal_eval -from pprint import pprint - -import common - -data = common.getData() - -if data is not None: - platExt = ".exe" if platform.system() == "Windows" else "" - launcherPath = data["CurPath"] / ("BGArmor" + platExt) - - print("\n> Building launcher...") - - if platform.system() == "Linux": - command = 'gcc -m32 -no-pie -c ./source/Launcher.c -o Launcher.o' - print("Command:", command) - os.system(command) - command = "gcc -m32 -no-pie -o ?" + launcherPath.as_posix() + "? Launcher.o" - command = command.replace('?', data["Quote"]) - print("Command:", command) - os.system(command) - - if platform.system() == "Windows": - command = 'gcc -m32 -no-pie -o ?' + launcherPath.as_posix() + '? ?./source/Launcher.c?' - command = command.replace('?', data["Quote"]) - print("Command:", command) - subprocess.call(command) - - command = '?./source/tools/Windows/ResourceHacker.exe? ' - command += '-open ?' + launcherPath.as_posix() + '? ' - command += '-save ?' + launcherPath.as_posix() + '? ' - command += '-action addoverwrite -res ?./source/icons/icon-launcher.ico? ' - command += '-mask ICONGROUP,APPICON, ' - command = command.replace('?', data["Quote"]) - print("\n> Setting icon of launcher...") - print("Command:", command) - subprocess.call(command) - diff --git a/win-build-launcher.bat b/win-build-launcher.bat deleted file mode 100644 index fdd6a6c..0000000 --- a/win-build-launcher.bat +++ /dev/null @@ -1,16 +0,0 @@ -echo off -cls - -echo ------------------------------------ -echo BGArmor Executable Builder - Windows -echo ------------------------------------ -echo. -echo This script will build the launcher executable from the C source code. -echo NOTE: You need the GNU GCC compiler (MinGW) in order to build the launcher. -echo. - -call ".\source\tools\Windows\get-python.bat" ".\source\tools\Common\helper_scripts\build_launcher.py" - -echo. -echo Done! -pause From 2fa2756f64021f701320af1bbef6728054bd3a9a Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 01:04:45 -0300 Subject: [PATCH 04/13] feat: get executables from config - validate if engine and python executables exist - show error message if any exe is found --- source/launcher/src/main.rs | 94 +++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 15 deletions(-) diff --git a/source/launcher/src/main.rs b/source/launcher/src/main.rs index 23d187a..cf57b56 100644 --- a/source/launcher/src/main.rs +++ b/source/launcher/src/main.rs @@ -1,14 +1,14 @@ use std::path::Path; +use std::env; use clap::{Arg, App}; use std::fs; -use json; +// use subprocess::Popen; + fn main() { - let config_file = "./launcher.json"; - let config = Path::new(config_file); let matches = App::new("BGArmor Launcher") - .version("0.1.0") + .version("0.0.6") .author("Joel Gomes da Silva ") .about("BGE and UPBGE source code obfuscator and launcher toolchain.") .arg(Arg::with_name("console") @@ -25,21 +25,85 @@ fn main() { .takes_value(true) .help("Pass arguments to engine executable (in quotes)")) .get_matches(); + + + let cur_os = if env::consts::FAMILY == "windows" {"Windows"} else {"Linux"}; + let executables = get_executables(cur_os); + if executables.len() == 2 { + for el in executables { + println!("{}", el); + } + if matches.is_present("a") { + } + } else { + println!("X Could not find any Python and engine executable") + } +} + + +fn get_executables(cur_os: &str) -> Vec { + let launcher_base_path_str = String::from("./launcher/"); + let python_config_name = "python_executable.txt"; + let engine_config_name = "engine_executable.txt"; + + let launcher_paths = [ + [launcher_base_path_str.clone().as_str(), cur_os, "32/"].join(""), + [launcher_base_path_str.clone().as_str(), cur_os, "64/"].join(""), + ]; - if config.exists() { + for path in launcher_paths { + let path = String::from(path); + + let python_config_path_str = [path.clone(), python_config_name.to_string()].join(""); + let engine_config_path_str = [path.clone(), engine_config_name.to_string()].join(""); - let config = json::parse( - fs::read_to_string(config) - .expect("X Could not read launcher.json") - .as_str()) - .unwrap(); + let python_config_path = Path::new(&python_config_path_str); + let engine_config_path = Path::new(&engine_config_path_str); + + let python_executable_path_str = get_executable_from_config(&python_config_path).clone(); + let engine_executable_path_str = get_executable_from_config(&engine_config_path).clone(); + let python_executable_path = Path::new(python_executable_path_str.as_str()); + let engine_executable_path = Path::new(engine_executable_path_str.as_str()); + let mut executables: Vec = Vec::new(); + + if python_executable_path.exists() { + executables.push(python_executable_path_str.clone()); - if matches.is_present("args") { - println!("{}", matches.value_of("args").unwrap()); + if engine_executable_path.exists() { + executables.push(engine_executable_path_str.clone()); + return executables; + } else { + println!("X Invalid engine executable path on {}", engine_config_path_str); + } + } else { + println!("X Invalid Python executable path on {}", python_config_path_str); } - println!("{}: {}", config["GameName"], matches.is_present("args")); + } + return Vec::new(); +} + +fn get_executable_from_config(config_path: &Path) -> String { + + if config_path.exists() { + let file_data_str = String::from(fs::read_to_string(config_path).expect("").as_str()); + let mut elements: Vec = Vec::new(); - } else { - println!("X Could not find file launcher.json"); + for el in file_data_str.split("=") { + let mut el = String::from(el.clone()); + el = String::from(el.trim()); + el = el.replace("'", "").replace("\"", ""); + elements.push(el); + } + + if elements.len() == 2 { + let executable_path_str = elements[1].clone(); + let executable_path = Path::new(executable_path_str.as_str()); + + if executable_path.exists() { + return executable_path_str; + } + } + return String::from(""); } + return String::from(""); } From d2980657810dd719b5a972cbc405db4508ca658f Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 11:20:02 -0300 Subject: [PATCH 05/13] feat: implement launcher execution with Python interpreter --- source/launcher/src/main.rs | 69 ++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/source/launcher/src/main.rs b/source/launcher/src/main.rs index cf57b56..b841110 100644 --- a/source/launcher/src/main.rs +++ b/source/launcher/src/main.rs @@ -2,7 +2,7 @@ use std::path::Path; use std::env; use clap::{Arg, App}; use std::fs; -// use subprocess::Popen; +use subprocess::*; fn main() { @@ -26,25 +26,24 @@ fn main() { .help("Pass arguments to engine executable (in quotes)")) .get_matches(); + let executables = get_executables(); - let cur_os = if env::consts::FAMILY == "windows" {"Windows"} else {"Linux"}; - let executables = get_executables(cur_os); if executables.len() == 2 { - for el in executables { - println!("{}", el); - } + let mut args: Vec = Vec::new(); + if matches.is_present("a") { + args.push("a".to_string()); } + + run_python_executable(executables, args); } else { println!("X Could not find any Python and engine executable") } } - -fn get_executables(cur_os: &str) -> Vec { +fn get_executables() -> Vec { + let cur_os = if env::consts::FAMILY == "windows" {"Windows"} else {"Linux"}; let launcher_base_path_str = String::from("./launcher/"); - let python_config_name = "python_executable.txt"; - let engine_config_name = "engine_executable.txt"; let launcher_paths = [ [launcher_base_path_str.clone().as_str(), cur_os, "32/"].join(""), @@ -54,16 +53,16 @@ fn get_executables(cur_os: &str) -> Vec { for path in launcher_paths { let path = String::from(path); - let python_config_path_str = [path.clone(), python_config_name.to_string()].join(""); - let engine_config_path_str = [path.clone(), engine_config_name.to_string()].join(""); - + let python_config_path_str = [path.clone(), "python_executable.txt".to_string()].join(""); + let engine_config_path_str = [path.clone(), "engine_executable.txt".to_string()].join(""); let python_config_path = Path::new(&python_config_path_str); let engine_config_path = Path::new(&engine_config_path_str); let python_executable_path_str = get_executable_from_config(&python_config_path).clone(); let engine_executable_path_str = get_executable_from_config(&engine_config_path).clone(); - let python_executable_path = Path::new(python_executable_path_str.as_str()); - let engine_executable_path = Path::new(engine_executable_path_str.as_str()); + let python_executable_path = Path::new(&python_executable_path_str); + let engine_executable_path = Path::new(&engine_executable_path_str); + let mut executables: Vec = Vec::new(); if python_executable_path.exists() { @@ -100,10 +99,48 @@ fn get_executable_from_config(config_path: &Path) -> String { let executable_path = Path::new(executable_path_str.as_str()); if executable_path.exists() { - return executable_path_str; + return executable_path.canonicalize().unwrap().into_os_string().into_string().unwrap(); } } return String::from(""); } return String::from(""); } + +fn run_python_executable(executables: Vec, _args: Vec) { + + // Enable executable execution on Linux + if env::consts::FAMILY != "windows" { + + for el in executables.iter() { + + let mut _process = Popen::create(&["chmod", "+x", el.as_str()], PopenConfig { + stdout: Redirection::Pipe, ..Default::default() + }).expect("X Could not enable execution of Python executable"); + } + } + + let mut launcher_script = Path::new("./launcher/launcher.py"); + + if !launcher_script.exists() { + launcher_script = Path::new("./source/launcher.py"); + + if !launcher_script.exists() { + println!("X Could not find script launcher.py"); + return; + } + } + + let launcher_script = launcher_script.canonicalize().unwrap(); + let launcher_script = launcher_script.as_path(); + + // Execute launcher script on Python interpreter + for el in executables.iter() { + + let mut _process = Popen::create(&[el.as_str(), launcher_script.to_str().unwrap()], PopenConfig { + stdout: Redirection::Pipe, ..Default::default() + }).expect("X Could not run script launcher.py"); + + return; + } +} \ No newline at end of file From 37adac92c021c78fce5458e030c13456eb639ada Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 12:38:35 -0300 Subject: [PATCH 06/13] fix: fix logic on launcher.py add and type comments --- source/launcher.py | 109 +++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 34 deletions(-) diff --git a/source/launcher.py b/source/launcher.py index 38f364c..486f4e2 100644 --- a/source/launcher.py +++ b/source/launcher.py @@ -18,20 +18,28 @@ ITEM_SEPARATOR = "\t" curPath = Path(__file__).resolve().parent +rootPath = curPath.parent curPlatform = platform.system() + if curPath.name == "source": curPath = curPath.parent / "launcher" os.chdir(curPath.as_posix()) - + + def debugMsg(*args, waitInput=True): + # type: (object, bool) -> None + if _DEBUG: finalMsg = "" for arg in args: finalMsg += str(arg) print(finalMsg) if waitInput: input("Press any key to continue...") + def loadConfig(path): + # type: (Path) -> None + config = None configPath = path / "config.json" engineCandidates = [curPlatform, curPlatform + "32", curPlatform + "64"] @@ -39,28 +47,41 @@ def loadConfig(path): for _path in engineCandidates: _path = path / (_path + "/engine_executable.txt") + if _path.exists(): - enginePath = _path.resolve() - break + _path = _path.resolve() + + with open(_path.as_posix(), "r") as sourceFile: + enginePathRead = rootPath / literal_eval(sourceFile.read().split('=')[-1]) # type: Path + + if enginePathRead.exists(): + enginePath = enginePathRead + break - if configPath.exists() and enginePath is not None: + if configPath.exists(): + with open(configPath.as_posix(), "r") as sourceFile: config = literal_eval(sourceFile.read()) print("> Read config from", configPath.as_posix()) - if enginePath.exists(): - with open(enginePath.as_posix(), "r") as sourceFile: - enginePathRead = literal_eval(sourceFile.read().split('=')[-1]) + if enginePath and enginePath.exists(): + config["EnginePath"] = enginePath.as_posix() + print("> Read engine path from", enginePath.as_posix()) + return config - if enginePathRead: - config["EnginePath"] = enginePathRead - print("> Read engine path from", enginePath.as_posix()) - - return config + else: + print("X Could not find suitable engine executable") + + else: + print("X Could not find config file at", configPath) + def getGameDir(config): + # type: (dict[str, object]) -> Path def getGameDirName(name): + # type: (str) -> str + result = "" allowedChars = string.ascii_lowercase + string.ascii_uppercase + " -" for c in name: @@ -81,8 +102,11 @@ def getGameDirName(name): gameDir.mkdir(parents=True, exist_ok=True) return gameDir - + + def getTempDir(config): + # type: (dict[str, object]) -> Path + tempDir = Path.home() tempDirName = md5(("BGArmor" + str(time())).encode()).hexdigest().upper() @@ -98,34 +122,42 @@ def getTempDir(config): ctypes.windll.kernel32.SetFileAttributesW(tempDir.as_posix(), 2) return tempDir - + + def getFilesLists(path): - persistentFiles = [] - generalFiles = [] - - # Populate persistent files list - for pattern in config["Persistent"]: - persistentFiles += [Path(p).resolve() for p in glob.glob( - path.as_posix() + "/**/" + pattern, recursive=True)] - - # Populate general files list - generalFiles += [Path(p).resolve() for p in glob.glob( - path.as_posix() + "/**/*", recursive=True) - if Path(p).is_file()] - - # Remove persistent files from general files list - for pers in persistentFiles: - for gen in generalFiles: - if pers.samefile(gen): - generalFiles.remove(gen) - - return [persistentFiles, generalFiles] + # type: (Path) -> list[list[Path]] + + persistentFiles = [] + generalFiles = [] + + # Populate persistent files list + for pattern in config["Persistent"]: + persistentFiles += [Path(p).resolve() for p in glob.glob( + path.as_posix() + "/**/" + pattern, recursive=True)] + + # Populate general files list + generalFiles += [Path(p).resolve() for p in glob.glob( + path.as_posix() + "/**/*", recursive=True) + if Path(p).is_file()] + + # Remove persistent files from general files list + for pers in persistentFiles: + for gen in generalFiles: + if pers.samefile(gen): + generalFiles.remove(gen) + + return [persistentFiles, generalFiles] + def ensurePath(path): + # type: (Path) -> Path path.parent.mkdir(parents=True, exist_ok=True) return path + def decompressDataFile(dataFile, targetPath): + # type: (Path, Path) -> None + startTime = time() if dataFile.exists(): @@ -163,13 +195,19 @@ def decompressDataFile(dataFile, targetPath): print("> Done! Time taken:", round(time() - startTime, 3), "seconds\n") + def copyPersistentFiles(pathFrom, pathTo, filesList): + # type: (Path, Path, list[Path]) -> None + for fileFrom in filesList: fileRelative = Path(fileFrom.as_posix().replace(pathFrom.as_posix(), "")[1:]) fileTo = (pathTo / fileRelative) shutil.copy(fileFrom.as_posix(), ensurePath(fileTo).as_posix()) + def removeEmptyDirs(path): + # type: (Path) -> None + for root, dirs, files in os.walk(path.as_posix(), topdown=False): root = Path(root).resolve() for _dir in dirs: @@ -179,8 +217,10 @@ def removeEmptyDirs(path): except: pass + config = loadConfig(curPath) + if config is not None: dataFile = curPath.parent / config["DataFile"] @@ -226,3 +266,4 @@ def removeEmptyDirs(path): else: print("X Could not find game data at", dataFile.as_posix()) + From 3692ad462786ef00d8f466f87d10ab11fd89b757 Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 12:39:30 -0300 Subject: [PATCH 07/13] feat: print process output to stdout --- source/launcher/src/main.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/source/launcher/src/main.rs b/source/launcher/src/main.rs index b841110..7d7ab6c 100644 --- a/source/launcher/src/main.rs +++ b/source/launcher/src/main.rs @@ -71,11 +71,7 @@ fn get_executables() -> Vec { if engine_executable_path.exists() { executables.push(engine_executable_path_str.clone()); return executables; - } else { - println!("X Invalid engine executable path on {}", engine_config_path_str); } - } else { - println!("X Invalid Python executable path on {}", python_config_path_str); } } return Vec::new(); @@ -117,6 +113,15 @@ fn run_python_executable(executables: Vec, _args: Vec) { let mut _process = Popen::create(&["chmod", "+x", el.as_str()], PopenConfig { stdout: Redirection::Pipe, ..Default::default() }).expect("X Could not enable execution of Python executable"); + let _exit_status = _process.wait(); + + let (out, _err) = _process.communicate(None).unwrap(); + + if out != None { + println!("{}", out.unwrap()); + } + + println!("Enable execution of: {}", el); } } @@ -136,11 +141,20 @@ fn run_python_executable(executables: Vec, _args: Vec) { // Execute launcher script on Python interpreter for el in executables.iter() { - + println!("Run executable: {} {}", el, launcher_script.to_str().unwrap()); + let mut _process = Popen::create(&[el.as_str(), launcher_script.to_str().unwrap()], PopenConfig { stdout: Redirection::Pipe, ..Default::default() }).expect("X Could not run script launcher.py"); + let (out, _err) = _process.communicate(None).unwrap(); + + if out != None { + println!("{}", out.unwrap()); + } + + let _exit_status = _process.wait().expect("X Could not get exit status"); + println!("Exit success: {}", _exit_status.success()); return; } } \ No newline at end of file From 7674ca763129d5078abc2e8b737cfe2256dfb360 Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 14:17:46 -0300 Subject: [PATCH 08/13] feat: add package winres and build script --- source/launcher/Cargo.lock | 32 +++++++++++++++++++++++++------- source/launcher/Cargo.toml | 3 ++- source/launcher/build.rs | 14 ++++++++++++++ 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 source/launcher/build.rs diff --git a/source/launcher/Cargo.lock b/source/launcher/Cargo.lock index d4e1637..555ee9d 100644 --- a/source/launcher/Cargo.lock +++ b/source/launcher/Cargo.lock @@ -27,8 +27,8 @@ name = "bgarmor" version = "0.1.0" dependencies = [ "clap", - "json", "subprocess", + "winres", ] [[package]] @@ -61,18 +61,18 @@ dependencies = [ "libc", ] -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - [[package]] name = "libc" version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +[[package]] +name = "serde" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" + [[package]] name = "strsim" version = "0.8.0" @@ -98,6 +98,15 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + [[package]] name = "unicode-width" version = "0.1.8" @@ -131,3 +140,12 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winres" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c" +dependencies = [ + "toml", +] diff --git a/source/launcher/Cargo.toml b/source/launcher/Cargo.toml index 162556f..eacabf3 100644 --- a/source/launcher/Cargo.toml +++ b/source/launcher/Cargo.toml @@ -2,10 +2,11 @@ name = "bgarmor" version = "0.1.0" edition = "2018" +build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -json = "0.12.4" +winres = "0.1.12" clap = "2.33.3" subprocess = "0.2.8" \ No newline at end of file diff --git a/source/launcher/build.rs b/source/launcher/build.rs new file mode 100644 index 0000000..5b98505 --- /dev/null +++ b/source/launcher/build.rs @@ -0,0 +1,14 @@ +use std::io; +#[cfg(windows)] +use winres::WindowsResource; + +fn main() -> io::Result<()> { + #[cfg(windows)] + { + WindowsResource::new() + .set_icon("../icons/icon-launcher.ico") + .compile() + .expect("X Could not set icon"); + } + Ok(()) +} From ce2f8316811b6dd1697ea5bc58d1ee89f4222e4e Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 14:18:18 -0300 Subject: [PATCH 09/13] feat: set version to v0.0.6 --- launcher/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/config.json b/launcher/config.json index d8e6e22..b8cfd56 100644 --- a/launcher/config.json +++ b/launcher/config.json @@ -1,6 +1,6 @@ { "GameName": "Example Game", - "Version": "0.0.5", + "Version": "0.0.6", "MainFile": "Example Game.blend", "DataFile": "./data.dat", "DataSource": "./data", From 968f611733667a0415255dbf206313781c9c462d Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 14:19:24 -0300 Subject: [PATCH 10/13] refactor: change release_files extension from .json to .py --- source/{release_files.json => release_files.py} | 0 source/tools/Common/helper_scripts/build_bgarmor.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename source/{release_files.json => release_files.py} (100%) diff --git a/source/release_files.json b/source/release_files.py similarity index 100% rename from source/release_files.json rename to source/release_files.py diff --git a/source/tools/Common/helper_scripts/build_bgarmor.py b/source/tools/Common/helper_scripts/build_bgarmor.py index 9de0df8..140c315 100644 --- a/source/tools/Common/helper_scripts/build_bgarmor.py +++ b/source/tools/Common/helper_scripts/build_bgarmor.py @@ -13,7 +13,7 @@ if data is not None: compress = False - releaseFilesList = data["CurPath"] / "source/release_files.json" + releaseFilesList = data["CurPath"] / "source/release_files.py" targetPath = (data["CurPath"] / "release") / common.formatFileName( "bgarmor-v" + data["Version"] + " Win Linux", spaces=False, From 501e1068ca28afb35b9509fb731212957a0a7451 Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 14:19:54 -0300 Subject: [PATCH 11/13] fix: replace copy functions with copy2 --- source/launcher.py | 2 +- source/tools/Common/helper_scripts/build_bgarmor.py | 2 +- source/tools/Common/helper_scripts/build_release.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/launcher.py b/source/launcher.py index 486f4e2..662a3e5 100644 --- a/source/launcher.py +++ b/source/launcher.py @@ -202,7 +202,7 @@ def copyPersistentFiles(pathFrom, pathTo, filesList): for fileFrom in filesList: fileRelative = Path(fileFrom.as_posix().replace(pathFrom.as_posix(), "")[1:]) fileTo = (pathTo / fileRelative) - shutil.copy(fileFrom.as_posix(), ensurePath(fileTo).as_posix()) + shutil.copy2(fileFrom.as_posix(), ensurePath(fileTo).as_posix()) def removeEmptyDirs(path): diff --git a/source/tools/Common/helper_scripts/build_bgarmor.py b/source/tools/Common/helper_scripts/build_bgarmor.py index 140c315..9434b62 100644 --- a/source/tools/Common/helper_scripts/build_bgarmor.py +++ b/source/tools/Common/helper_scripts/build_bgarmor.py @@ -55,7 +55,7 @@ if elementType == "folder" and not path.exists(): shutil.copytree(sourcePath.as_posix(), path.as_posix()) else: - shutil.copy(sourcePath.as_posix(), path.as_posix()) + shutil.copy2(sourcePath.as_posix(), path.as_posix()) print(" > Copied", elementType, "to:", path.as_posix()) diff --git a/source/tools/Common/helper_scripts/build_release.py b/source/tools/Common/helper_scripts/build_release.py index fa0608f..b13dc66 100644 --- a/source/tools/Common/helper_scripts/build_release.py +++ b/source/tools/Common/helper_scripts/build_release.py @@ -98,13 +98,13 @@ def getAvailableTargets(path): releaseTargetEnginePath.mkdir() print(" > Copying data file to:", (releaseTargetPath / dataFile.name).as_posix()) - shutil.copy(dataFile.as_posix(), (releaseTargetPath / dataFile.name).as_posix()) + shutil.copy2(dataFile.as_posix(), (releaseTargetPath / dataFile.name).as_posix()) print(" > Copying launcher files to:", (releaseTargetLauncherPath / target).as_posix()) shutil.copytree((launcherDir / target).as_posix(), (releaseTargetLauncherPath / target).as_posix()) for _file in launcherDir.iterdir(): if not _file.is_dir(): - shutil.copy(_file.as_posix(), releaseTargetLauncherPath.as_posix()) + shutil.copy2(_file.as_posix(), releaseTargetLauncherPath.as_posix()) print(" > Copying engine files to:", (releaseTargetEnginePath / target).as_posix()) shutil.copytree((engineDir / target).as_posix(), (releaseTargetEnginePath / target).as_posix()) @@ -119,7 +119,7 @@ def getAvailableTargets(path): if launcherExecutable is not None: launcherExecutableTarget = releaseTargetPath / (common.formatFileName(data["GameName"]) + launcherExt) print(" > Copying launcher executable to:", launcherExecutableTarget.as_posix()) - shutil.copy( + shutil.copy2( launcherExecutable.as_posix(), launcherExecutableTarget.as_posix() ) From 79b6882e3b6f844d12a3b1bbb4d419e7b5440cdb Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 17:00:20 -0300 Subject: [PATCH 12/13] fix: disable upx on windows build - this fixes corruption when setting icons --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 24c1f98..3d80327 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ ifdef OS END = && SOURCE_EXE = ".\target\$(TARGET)\release\bgarmor$(EXT)" TARGET_EXE = "..\..\BGArmor$(EXT)" + UPX = REM else TARGET = i686-unknown-linux-gnu DELETE = rm -f @@ -14,6 +15,7 @@ else END = ; SOURCE_EXE = "./target/$(TARGET)/release/bgarmor$(EXT)" TARGET_EXE = "../../BGArmor$(EXT)" + UPX = upx -5 endif build: @@ -21,4 +23,4 @@ build: $(DELETE) $(TARGET_EXE) $(END) \ cargo build --target=$(TARGET) --release $(END) \ $(COPY) $(SOURCE_EXE) $(TARGET_EXE) $(END) \ - upx -5 $(TARGET_EXE) + $(UPX) $(TARGET_EXE) From 94b0f4798607166880f14051acee79bb84c3c95f Mon Sep 17 00:00:00 2001 From: Joel Gomes da Silva Date: Sun, 13 Feb 2022 17:03:33 -0300 Subject: [PATCH 13/13] feat: add icon and manifest to launcher exe at build time --- source/launcher/Cargo.lock | 22 +++++++++++----------- source/launcher/Cargo.toml | 17 ++++++++++++----- source/launcher/bgarmor.manifest.xml | 10 ++++++++++ source/launcher/build.rs | 20 ++++++++------------ 4 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 source/launcher/bgarmor.manifest.xml diff --git a/source/launcher/Cargo.lock b/source/launcher/Cargo.lock index 555ee9d..53f1d7c 100644 --- a/source/launcher/Cargo.lock +++ b/source/launcher/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] @@ -24,7 +24,7 @@ dependencies = [ [[package]] name = "bgarmor" -version = "0.1.0" +version = "0.0.6" dependencies = [ "clap", "subprocess", @@ -33,15 +33,15 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "clap" -version = "2.33.3" +version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.99" +version = "0.2.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" [[package]] name = "serde" @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "vec_map" diff --git a/source/launcher/Cargo.toml b/source/launcher/Cargo.toml index eacabf3..1c5ed73 100644 --- a/source/launcher/Cargo.toml +++ b/source/launcher/Cargo.toml @@ -1,12 +1,19 @@ [package] name = "bgarmor" -version = "0.1.0" +version = "0.0.6" edition = "2018" build = "build.rs" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -winres = "0.1.12" clap = "2.33.3" -subprocess = "0.2.8" \ No newline at end of file +subprocess = "0.2.8" + +[build-dependencies] +winres = "0.1.12" + +[package.metadata.winres] +FileDescription = "BGArmor: BGE and UPBGE game packer and launcher." +ProductName = "BGArmor" +OriginalFilename = "BGArmor.exe" +LegalCopyright = "MIT" +CompanyName = "BGEmpire" \ No newline at end of file diff --git a/source/launcher/bgarmor.manifest.xml b/source/launcher/bgarmor.manifest.xml new file mode 100644 index 0000000..ecea6f7 --- /dev/null +++ b/source/launcher/bgarmor.manifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/source/launcher/build.rs b/source/launcher/build.rs index 5b98505..fb0829c 100644 --- a/source/launcher/build.rs +++ b/source/launcher/build.rs @@ -1,14 +1,10 @@ -use std::io; -#[cfg(windows)] -use winres::WindowsResource; +extern crate winres; -fn main() -> io::Result<()> { - #[cfg(windows)] - { - WindowsResource::new() - .set_icon("../icons/icon-launcher.ico") - .compile() - .expect("X Could not set icon"); - } - Ok(()) +fn main() { + if cfg!(target_os = "windows") { + let mut res = winres::WindowsResource::new(); + res.set_icon("../icons/icon-launcher.ico"); + res.set_manifest_file("./bgarmor.manifest.xml"); + res.compile().unwrap(); + } }