Skip to content

Commit a891ecb

Browse files
authored
Merge pull request #735 from Zagrios/bugfix/reduce-dll-deps-and-add-logs-file-to-external-scripts
Reduce DLL dependencies for "oculus-allow-dev-sideloaded.exe" and add logging for external scripts
2 parents 467ca6e + 17bd2e8 commit a891ecb

File tree

13 files changed

+538
-20
lines changed

13 files changed

+538
-20
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ npm-debug.log.*
2929
*.scss.d.ts
3030

3131
# externals
32-
externals/**/target/*
32+
externals/**/target/**
43 KB
Binary file not shown.
190 KB
Binary file not shown.

externals/bs-admin-start/Cargo.lock

Lines changed: 224 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

externals/bs-admin-start/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ version = "0.1.0"
44
edition = "2021"
55
build = "build.rs"
66

7+
[dependencies]
8+
simplelog = { version = "0.12.2", default-features = false }
9+
log = "0.4.24"
10+
711
[build-dependencies]
812
winres = "0.1.12"
913

1014
[profile.release]
1115
codegen-units = 1
1216
lto = true
1317
opt-level = "z"
18+
panic = "abort"
1419

1520
[package.metadata.winres]
1621
FileDescription = "Start Beat Saber as Admin"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "1.77.0"

externals/bs-admin-start/src/main.rs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11

22
use std::{process::Command, path::Path};
3+
use std::env::current_exe;
4+
use std::fs::File;
5+
use std::path::PathBuf;
6+
use log::{error, info, LevelFilter};
7+
use simplelog::{CombinedLogger, Config, WriteLogger};
38

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

1621
fn main() {
22+
23+
let default_log_file_path = current_exe().unwrap().with_file_name("bs-admin-start.log");
24+
let args: Vec<String> = std::env::args().collect();
25+
26+
let log_file_path: PathBuf = if let Some(pos) = args.iter().position(|arg| arg == "--log-path") {
27+
if let Some(log_path) = args.get(pos + 1) {
28+
PathBuf::from(log_path)
29+
} else {
30+
default_log_file_path
31+
}
32+
} else {
33+
default_log_file_path
34+
};
35+
36+
CombinedLogger::init(
37+
vec![
38+
WriteLogger::new(LevelFilter::Info, Config::default(), File::create(log_file_path).unwrap()),
39+
]
40+
).unwrap();
41+
42+
1743
let args: Vec<String> = std::env::args().collect();
1844

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

2147
if executable_path.file_name().unwrap() != EXECUTABLE_NAME {
22-
eprintln!("Executable path is not Beat Saber.exe.");
23-
return;
48+
return error!("Executable path is not Beat Saber.exe.");
2449
}
2550

2651
if !executable_path.exists() || !executable_path.is_file() {
27-
eprintln!("Executable path is not valid.");
28-
return;
52+
return error!("Executable path is not valid.");
2953
}
3054

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

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

46-
let _ = command.spawn();
70+
let res = command.spawn();
71+
72+
if let Err(e) = res {
73+
return error!("Failed to start Beat Saber ({}): {}", executable_path.display(), e);
74+
}
75+
76+
info!("Beat Saber started ({})", executable_path.display());
4777
}

0 commit comments

Comments
 (0)