Skip to content

Commit

Permalink
Merge pull request #735 from Zagrios/bugfix/reduce-dll-deps-and-add-l…
Browse files Browse the repository at this point in the history
…ogs-file-to-external-scripts

Reduce DLL dependencies for "oculus-allow-dev-sideloaded.exe"  and add logging for external scripts
  • Loading branch information
Zagrios authored Jan 11, 2025
2 parents 467ca6e + 17bd2e8 commit a891ecb
Show file tree
Hide file tree
Showing 13 changed files with 538 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ npm-debug.log.*
*.scss.d.ts

# externals
externals/**/target/*
externals/**/target/**
Binary file modified assets/scripts/oculus-allow-dev-sideloaded.exe
Binary file not shown.
Binary file modified assets/scripts/start_beat_saber_admin.exe
Binary file not shown.
224 changes: 224 additions & 0 deletions externals/bs-admin-start/Cargo.lock

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

5 changes: 5 additions & 0 deletions externals/bs-admin-start/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ version = "0.1.0"
edition = "2021"
build = "build.rs"

[dependencies]
simplelog = { version = "0.12.2", default-features = false }
log = "0.4.24"

[build-dependencies]
winres = "0.1.12"

[profile.release]
codegen-units = 1
lto = true
opt-level = "z"
panic = "abort"

[package.metadata.winres]
FileDescription = "Start Beat Saber as Admin"
Expand Down
2 changes: 2 additions & 0 deletions externals/bs-admin-start/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.77.0"
40 changes: 35 additions & 5 deletions externals/bs-admin-start/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

use std::{process::Command, path::Path};
use std::env::current_exe;
use std::fs::File;
use std::path::PathBuf;
use log::{error, info, LevelFilter};
use simplelog::{CombinedLogger, Config, WriteLogger};

const EXECUTABLE_NAME: &str = "Beat Saber.exe";
const AUTORIZED_ARGS: [&str; 8] = [
Expand All @@ -14,18 +19,37 @@ const AUTORIZED_ARGS: [&str; 8] = [
];

fn main() {

let default_log_file_path = current_exe().unwrap().with_file_name("bs-admin-start.log");
let args: Vec<String> = std::env::args().collect();

let log_file_path: PathBuf = if let Some(pos) = args.iter().position(|arg| arg == "--log-path") {
if let Some(log_path) = args.get(pos + 1) {
PathBuf::from(log_path)
} else {
default_log_file_path
}
} else {
default_log_file_path
};

CombinedLogger::init(
vec![
WriteLogger::new(LevelFilter::Info, Config::default(), File::create(log_file_path).unwrap()),
]
).unwrap();


let args: Vec<String> = std::env::args().collect();

let executable_path = Path::new(&args[1]);

if executable_path.file_name().unwrap() != EXECUTABLE_NAME {
eprintln!("Executable path is not Beat Saber.exe.");
return;
return error!("Executable path is not Beat Saber.exe.");
}

if !executable_path.exists() || !executable_path.is_file() {
eprintln!("Executable path is not valid.");
return;
return error!("Executable path is not valid.");
}

let mut command = Command::new(executable_path);
Expand All @@ -43,5 +67,11 @@ fn main() {

command.env("SteamAppId", "620980");

let _ = command.spawn();
let res = command.spawn();

if let Err(e) = res {
return error!("Failed to start Beat Saber ({}): {}", executable_path.display(), e);
}

info!("Beat Saber started ({})", executable_path.display());
}
Loading

0 comments on commit a891ecb

Please sign in to comment.