diff --git a/abstutil/Cargo.toml b/abstutil/Cargo.toml index 1d54c28d37..b9b8548829 100644 --- a/abstutil/Cargo.toml +++ b/abstutil/Cargo.toml @@ -7,10 +7,12 @@ edition = "2018" [dependencies] bincode = "1.1.2" lazy_static = "1.3.0" -procfs = "0.4.7" rand = { version = "0.6.5", features = ["serde1"] } rand_xorshift = "0.1.1" serde = "1.0.89" serde_derive = "1.0.89" serde_json = "1.0.39" + +[target.'cfg(unix)'.dependencies] +procfs = "0.4.7" termion = "1.5.1" diff --git a/abstutil/src/time.rs b/abstutil/src/time.rs index 407caf5c51..407355a0eb 100644 --- a/abstutil/src/time.rs +++ b/abstutil/src/time.rs @@ -1,9 +1,7 @@ use crate::{notes, PROGRESS_FREQUENCY_SECONDS}; -use procfs; use std::collections::HashMap; use std::io::{stdout, Write}; use std::time::Instant; -use termion; pub fn elapsed_seconds(since: Instant) -> f64 { let dt = since.elapsed(); @@ -399,10 +397,17 @@ impl MeasureMemory { } } +#[cfg(unix)] fn process_used_memory_mb() -> usize { (procfs::Process::myself().unwrap().stat.vsize / 1024 / 1024) as usize } +#[cfg(windows)] +fn process_used_memory_mb() -> usize { + 0 +} + +#[cfg(unix)] pub(crate) fn clear_current_line() { let (terminal_width, _) = termion::terminal_size().unwrap(); print!( @@ -411,3 +416,8 @@ pub(crate) fn clear_current_line() { termion::cursor::Left(terminal_width) ); } + +#[cfg(windows)] +pub(crate) fn clear_current_line() { + print!("\r"); +} diff --git a/docs/development.md b/docs/development.md index 91f38bedfd..2a1b3fc38d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -4,8 +4,6 @@ Find packages to upgrade: `cargo outdated -R` Diff screencaps: http://www.imagemagick.org/Usage/compare/#methods -Cross-compilation: https://github.com/rust-embedded/cross - Debug OpenGL calls: apitrace trace --api gl ../target/debug/editor ../data/raw_maps/montlake.abst qapitrace editor.trace @@ -21,3 +19,15 @@ Run editor or headless with --enable_profiler google-pprof --no_strip_temp ../target/debug/editor profile google-pprof --no_strip_temp ../target/release/headless profile top30 --cum + +## Building releases + +Cross-compilation notes: https://github.com/rust-embedded/cross + +cross build --release --target x86_64-pc-windows-gnu --bin editor +wine target/x86_64-pc-windows-gnu/release/editor.exe data/maps/montlake_no_edits.abst + +Problems: +- build.rs tries to invoke python + - port the python script to rust ;) +- GLSL 1.40 not supported (in wine at least) diff --git a/ezgui/Cargo.toml b/ezgui/Cargo.toml index a0b78a79e6..c402db45f2 100644 --- a/ezgui/Cargo.toml +++ b/ezgui/Cargo.toml @@ -6,7 +6,6 @@ edition = "2018" [dependencies] abstutil = { path = "../abstutil" } -cpuprofiler = "0.0.3" geom = { path = "../geom" } glium = "0.23.0" glium-glyph = "0.3.0" @@ -15,3 +14,7 @@ palette = "0.4" serde = "1.0.89" serde_derive = "1.0.89" textwrap = "0.11" + +[target.'cfg(unix)'.dependencies] +# TODO Could add gperftools to the Windows Docker image +cpuprofiler = "0.0.3" diff --git a/ezgui/src/runner.rs b/ezgui/src/runner.rs index 84682a1863..9c3423e833 100644 --- a/ezgui/src/runner.rs +++ b/ezgui/src/runner.rs @@ -232,11 +232,14 @@ fn loop_forever>( prerender: Prerender, ) { if state.gui.profiling_enabled() { - cpuprofiler::PROFILER - .lock() - .unwrap() - .start("./profile") - .unwrap(); + #[cfg(unix)] + { + cpuprofiler::PROFILER + .lock() + .unwrap() + .start("./profile") + .unwrap(); + } } let mut wait_for_events = false; @@ -249,7 +252,10 @@ fn loop_forever>( if let glutin::Event::WindowEvent { event, .. } = event { if event == glutin::WindowEvent::CloseRequested { if state.gui.profiling_enabled() { - cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + #[cfg(unix)] + { + cpuprofiler::PROFILER.lock().unwrap().stop().unwrap(); + } } state.gui.before_quit(&state.canvas); process::exit(0);