Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [
"crates/mod-host-types",
"crates/telemetry",
"crates/xtask",
"crates/binary-analysis",
"crates/binary-analysis", "crates/mod-host-api",
]
resolver = "2"

Expand Down
10 changes: 9 additions & 1 deletion crates/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub struct Options {
#[clap(long, help_heading = "Configuration", value_hint = clap::ValueHint::DirPath)]
pub(crate) windows_binaries_dir: Option<Box<Path>>,

/// Path to a directory used to store me3 log files.
#[clap(long, help_heading = "Configuration", value_hint = clap::ValueHint::DirPath)]
pub(crate) log_dir: Option<Box<Path>>,

#[clap(skip)]
#[serde(default)]
pub(crate) game: BTreeMap<Game, GameOptions>,
Expand All @@ -53,7 +57,10 @@ pub struct Config {

impl Config {
pub fn log_dir(&self) -> Option<Box<Path>> {
self.known_dirs.data_dir().join("logs")
self.options
.log_dir
.clone()
.or_else(|| self.known_dirs.data_dir().join("logs"))
}

pub fn cache_dir(&self) -> Option<Box<Path>> {
Expand Down Expand Up @@ -107,6 +114,7 @@ impl Options {
Self {
crash_reporting: other.crash_reporting.or(self.crash_reporting),
game: other.game.into_iter().chain(self.game).collect(),
log_dir: other.log_dir.or(self.log_dir),
profile_dir: other.profile_dir.or(self.profile_dir),
steam_dir: other.steam_dir.or(self.steam_dir),
windows_binaries_dir: other.windows_binaries_dir.or(self.windows_binaries_dir),
Expand Down
14 changes: 14 additions & 0 deletions crates/mod-host-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "me3-mod-host-api"
version = "0.9.0"
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
me3-launcher-attach-protocol.workspace = true
serde_json.workspace = true

[lints]
workspace = true
6 changes: 6 additions & 0 deletions crates/mod-host-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use me3_launcher_attach_protocol::AttachConfig;

pub fn current_attach_config() -> Option<AttachConfig> {
let json_var = std::env::var("ME3_ATTACH_CONFIG").ok();
json_var.map(|v| serde_json::from_str(&v).expect("mod host serialized invalid data"))
}
6 changes: 6 additions & 0 deletions crates/mod-host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ fn on_attach(request: AttachRequest) -> AttachResult {
me3_telemetry::install_error_handler();

let attach_config = Arc::new(request.config);
let attach_config_json = serde_json::to_string(&*attach_config)?;

// SAFETY: only called on Windows
unsafe {
std::env::set_var("ME3_ATTACH_CONFIG", attach_config_json);
}

let telemetry_vars: TelemetryVars = me3_env::deserialize_from_env()?;

Expand Down
Loading