trying to cross-compile to windows. making some unix-only dependencies

optional.
This commit is contained in:
Dustin Carlino 2019-03-11 16:23:39 -07:00
parent 5ca359998c
commit 3eb5270d51
5 changed files with 43 additions and 12 deletions

View File

@ -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"

View File

@ -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");
}

View File

@ -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)

View File

@ -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"

View File

@ -232,11 +232,14 @@ fn loop_forever<T, G: GUI<T>>(
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<T, G: GUI<T>>(
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);