From d47be1e17549b372d13402434fa133de7e46c62e Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 3 Dec 2019 14:31:00 -0800 Subject: [PATCH] start a script to package data, stick it in dropbox, suck it down for fast bootstrapping. split off developer instructions. not finished, because I need a better connection to upload the seed data and test everything... --- .gitignore | 1 + abstutil/src/time.rs | 2 +- get_fresh_osm.sh => data/get_fresh_osm.sh | 0 data/grab_seed_data.sh | 9 ++++ data/package_for_devs.sh | 12 +++++ docs/INSTRUCTIONS.md | 46 +++---------------- docs/dev.md | 54 +++++++++++++++++++++++ 7 files changed, 82 insertions(+), 42 deletions(-) rename get_fresh_osm.sh => data/get_fresh_osm.sh (100%) create mode 100755 data/grab_seed_data.sh create mode 100755 data/package_for_devs.sh create mode 100644 docs/dev.md diff --git a/.gitignore b/.gitignore index 8f537217a9..28453a0ca6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ data/input/blockface.bin data/input/google_transit_2018_18_08 +data/input/neighborhoods data/input/neighborhoods.geojson data/input/offstreet_parking.kml data/input/osm diff --git a/abstutil/src/time.rs b/abstutil/src/time.rs index 0f2c45bab6..86dc9bd55a 100644 --- a/abstutil/src/time.rs +++ b/abstutil/src/time.rs @@ -349,6 +349,7 @@ impl<'a> Timer<'a> { } impl<'a> std::ops::Drop for Timer<'a> { + // TODO This often hides a panic fn drop(&mut self) { if self.outermost_name == "throwaway" { return; @@ -408,7 +409,6 @@ impl<'a> std::ops::Drop for Timer<'a> { } // For repeated things -// TODO Why does the PartialEq derivation in sim require this? pub struct Profiler { entries: Vec, current_entries: HashMap, diff --git a/get_fresh_osm.sh b/data/get_fresh_osm.sh similarity index 100% rename from get_fresh_osm.sh rename to data/get_fresh_osm.sh diff --git a/data/grab_seed_data.sh b/data/grab_seed_data.sh new file mode 100755 index 0000000000..96201667a7 --- /dev/null +++ b/data/grab_seed_data.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Run from the base repo directory: ./data/grab_seed_data.sh + +set -e + +curl -L -o seed_data.zip http://dropbox.com/TODO # TODO Need to upload this +rm -rf data/input data/system +unzip seed_data.zip +rm -f seed_data.zip diff --git a/data/package_for_devs.sh b/data/package_for_devs.sh new file mode 100755 index 0000000000..3be8e92c79 --- /dev/null +++ b/data/package_for_devs.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Run from the base repo directory: ./data/package_for_devs.sh + +set -e + +if [ "$USER" != "dabreegster" ]; then + echo "Only Dustin runs this script, to help new developers avoid a long data import process."; + exit 1; +fi + +zip -r seed_data data/input data/system +echo "Fire at will: mv seed_data.zip ~/Dropbox" diff --git a/docs/INSTRUCTIONS.md b/docs/INSTRUCTIONS.md index fa1115304c..ff330e7f47 100644 --- a/docs/INSTRUCTIONS.md +++ b/docs/INSTRUCTIONS.md @@ -4,7 +4,9 @@ General disclaimer: This is a very rough demo. The user interface is clunky, and gameplay is not cohesively tied together yet. Please email or file a Github issue if you hit problems. -## Installing the game from pre-built binaries +## Installing the game + +Grab a pre-built binary release: - Windows: https://github.com/dabreegster/abstreet/releases/download/v0.1.17/abstreet_windows.zip @@ -17,6 +19,8 @@ Unzip the folder, then run `play_abstreet.sh` or `play_abstreet.bat`. On Windows, you'll probably get a warning about running software from an unknown publisher. +Or you can [build from source](/docs/dev.md). + ## Playing the game General controls: @@ -43,46 +47,6 @@ Things to try: - Go back to the main menu and pick a challenge. Should be self-explanatory from there -- leave me feedbck if not. -## For developers: Compiling from source - -You will first need: - -- Standard dependencies: `bash`, `curl`, `unzip`, `gunzip` -- `osmconvert`: See https://wiki.openstreetmap.org/wiki/Osmconvert#Download -- Rust, at least 1.38. https://www.rust-lang.org/tools/install - -One-time setup: - -1. Download the repository: - `git clone https://github.com/dabreegster/abstreet.git` - -2. Download all input data and build maps. Compilation times will be very slow - the first time. `cd abstreet; ./import.sh && ./precompute.sh --release` - -3. Run the game: `cd game; cargo run --release` - -### Development tips - -- You don't need to rerun `./import.sh` nd `./precompute.sh` most of the time. - - If you're just touching code in `game`, `sim`, and `ezgui`, you can just - `cargo run` from `game` - - If you're modifying the initial OSM data -> RawMap conversion in - `convert_osm`, then you do need to rerun `./import.sh` and `precompute.sh` - to regenerate the map. - - If you're modifying `map_model` but not the OSM -> RawMap conversion, then - you can just do `precompute.sh`. - - Both of those scripts can just regenerate a single map, which is much - faster: `./import.sh caphill; ./precompute.sh caphill` -- Compile faster by just doing `cargo run`. The executable will have debug stack - traces and run more slowly. You can do `cargo run --release` to build in - optimized release mode; compilation will be slower, but the executable much - faster. -- To add some extra debug modes to the game, `cargo run -- --dev` or press - Control+S to toggle in-game -- All code is automatically formatted using - https://github.com/rust-lang/rustfmt; please run `cargo fmt` before sending a - PR. - ## Data source licensing A/B Street binary releases contain pre-built maps that combine data from: diff --git a/docs/dev.md b/docs/dev.md new file mode 100644 index 0000000000..084f8a8872 --- /dev/null +++ b/docs/dev.md @@ -0,0 +1,54 @@ +# Developer guide + +## Getting started + +You will first need: + +- Standard dependencies: `bash`, `curl`, `unzip`, `gunzip` +- Rust, at least 1.38. https://www.rust-lang.org/tools/install + +One-time setup: + +1. Download the repository: + `git clone https://github.com/dabreegster/abstreet.git` + +2. Build all input data. This is very slow, so you should seed from a pre-built + copy: `./data/grab_seed_data.sh`. This will download about 1GB and expand to + about 5GB. + +3. Run the game: `cd game; cargo run --release` + +## Development tips + +- Compile faster by just doing `cargo run`. The executable will have debug stack + traces and run more slowly. You can do `cargo run --release` to build in + optimized release mode; compilation will be slower, but the executable much + faster. +- To add some extra debug modes to the game, `cargo run -- --dev` or press + Control+S to toggle in-game +- All code is automatically formatted using + https://github.com/rust-lang/rustfmt; please run `cargo fmt` before sending a + PR. + +## Building map data + +You can skip this section if you're just touching code in `game`, `ezgui`, and +`sim`. + +You'll need some extra dependencies: + +- `osmconvert`: See https://wiki.openstreetmap.org/wiki/Osmconvert#Download +- `cs2cs` from proj4 (See X or `apt-get install proj-bin` on Ubuntu) + +The seed data from `data/grab_seed_data.sh` can be built from scratch by doing +`./import.sh && ./precompute.sh --release`. This takes a while. + +Some tips: + +- If you're modifying the initial OSM data -> RawMap conversion in + `convert_osm`, then you do need to rerun `./import.sh` and `precompute.sh` to + regenerate the map. +- If you're modifying `map_model` but not the OSM -> RawMap conversion, then you + can just do `precompute.sh`. +- Both of those scripts can just regenerate a single map, which is much faster: + `./import.sh caphill; ./precompute.sh caphill`