mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
Fix running external tools on Windows [rebuild] [release]
This commit is contained in:
parent
9d4587d000
commit
d41482febd
@ -1,7 +1,7 @@
|
||||
// TODO This doesn't really belong in gameplay/freeform
|
||||
|
||||
use map_gui::load::FutureLoader;
|
||||
use map_gui::tools::{find_exe_dir, RunCommand};
|
||||
use map_gui::tools::{find_exe, RunCommand};
|
||||
use widgetry::EventCtx;
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -27,7 +27,7 @@ pub fn import(ctx: &mut EventCtx) -> Transition {
|
||||
ctx,
|
||||
app,
|
||||
vec![
|
||||
format!("{}/import_grid2demand", find_exe_dir()),
|
||||
find_exe("import_grid2demand"),
|
||||
format!("--map={}", app.primary.map.get_name().path()),
|
||||
format!("--input={}", path),
|
||||
],
|
||||
|
@ -9,7 +9,7 @@ use widgetry::{
|
||||
};
|
||||
|
||||
use crate::load::MapLoader;
|
||||
use crate::tools::{find_exe_dir, open_browser, PopupMsg};
|
||||
use crate::tools::{find_exe, open_browser, PopupMsg};
|
||||
use crate::AppLike;
|
||||
|
||||
pub struct ImportCity<A: AppLike> {
|
||||
@ -98,10 +98,8 @@ impl<A: AppLike + 'static> State<A> for ImportCity<A> {
|
||||
Transition::Keep
|
||||
}
|
||||
"Import the area from your clipboard" => {
|
||||
let mut args = vec![
|
||||
format!("{}/one_step_import", find_exe_dir()),
|
||||
"boundary.geojson".to_string(),
|
||||
];
|
||||
let mut args =
|
||||
vec![find_exe("one_step_import"), "boundary.geojson".to_string()];
|
||||
if self.panel.is_checked("left handed driving") {
|
||||
args.push("--drive_on_left".to_string());
|
||||
}
|
||||
|
@ -213,9 +213,9 @@ pub fn open_browser<I: AsRef<str>>(url: I) {
|
||||
let _ = webbrowser::open(url.as_ref());
|
||||
}
|
||||
|
||||
/// Native-only: Locate the directory with other executables.
|
||||
pub fn find_exe_dir() -> &'static str {
|
||||
vec![
|
||||
/// Returns the path to an executable. Native-only.
|
||||
pub fn find_exe(cmd: &str) -> String {
|
||||
let dir = vec![
|
||||
"./target/release",
|
||||
"../target/release",
|
||||
"../../target/release",
|
||||
@ -224,5 +224,12 @@ pub fn find_exe_dir() -> &'static str {
|
||||
]
|
||||
.into_iter()
|
||||
.find(|x| std::path::Path::new(x).exists())
|
||||
.unwrap_or("./target/release")
|
||||
.unwrap_or("./target/release");
|
||||
// Apparently std::path on Windows doesn't do any of this correction. We could build up a
|
||||
// PathBuf properly, I guess
|
||||
if cfg!(windows) {
|
||||
format!("{}/{}.exe", dir, cmd).replace("/", "\\")
|
||||
} else {
|
||||
format!("{}/{}", dir, cmd)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user