Files
rusty-path-of-building/src/main.rs
T
faumaray 4118c3943f
CI / check (push) Failing after 7s
Native release / linux (push) Successful in 1m33s
Native release / windows (push) Failing after 9s
Native release / publish (push) Skipped
Release 0.3.6 with a game chooser and native installers
2026-11-27 21:48:45 +03:00

79 lines
2.1 KiB
Rust

use crate::{app::App, args::Args};
use clap::Parser;
use std::path::{Path, PathBuf};
use winit::event_loop::EventLoop;
mod app;
mod args;
mod batcher;
mod chooser;
mod clipboard;
mod color;
mod dpi;
mod draw_commands;
mod fonts;
mod gfx;
mod input;
mod installer;
mod math;
mod pob;
mod renderer;
mod stage;
mod util;
mod uv;
mod window;
mod worker_pool;
fn main() -> anyhow::Result<()> {
profiling::register_thread!("Main Thread");
env_logger::init();
#[cfg(feature = "profile-with-puffin")]
let _puffin_server = {
let server_addr = format!("127.0.0.1:{}", puffin_http::DEFAULT_PORT);
let server = puffin_http::Server::new(&server_addr).unwrap();
eprintln!("Serving profiling data on {server_addr}. Run `puffin_viewer` to view it.");
profiling::puffin::set_scopes_on(true);
server
};
let args = Args::parse();
let script_dir = find_nearby_launch_script();
let mut app = App::new(args, script_dir)?;
let event_loop = EventLoop::with_user_event().build()?;
event_loop.run_app(&mut app)?;
Ok(())
}
/// Search for the Launch.lua file in nearby locations
fn find_nearby_launch_script() -> Option<PathBuf> {
let mut candidates = vec![Path::new("Launch.lua"), Path::new("src/Launch.lua")];
if let Ok(cwd) = std::env::current_dir()
&& cwd.ends_with("runtime")
{
candidates.push(Path::new("../src/Launch.lua"));
}
for candidate in candidates {
if candidate.try_exists().is_ok_and(|exists| exists)
&& let Ok(candidate) = candidate.canonicalize()
&& let Some(dir) = candidate.parent()
{
// remove the windows extended length path syntax as it contains a
// question mark which will interfere with lua's require()
const WINDOWS_PREFIX: &str = r#"\\?\"#;
let path_str = dir.display().to_string();
return match path_str.strip_prefix(WINDOWS_PREFIX) {
Some(stripped) => Some(PathBuf::from(stripped)),
None => Some(dir.to_path_buf()),
};
};
}
None
}