Fix dependency bloat (#67)

* Move all examples to individual crates

* CI: Add libsdl2

* Use Ubuntu bionic for updated libsdl; 2.0.8

* Clippy

* libudev-dev is a dependency of libsdl2-dev

* Clippy

* Remove unnecessary dev-dependency

* `winit` is actually used in unit tests

* Fix a typo

* Move `simple-invaders` crate
This commit is contained in:
Jay Oster 2020-04-13 10:12:18 -07:00 committed by GitHub
parent 37b90fe6b4
commit 9de2383712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 72 additions and 55 deletions

View file

@ -1,4 +1,5 @@
language: rust
dist: bionic
rust:
# MSRV
- 1.40.0
@ -13,7 +14,7 @@ before_script:
- rustup component add clippy
- rustup component add rustfmt
- sudo apt-get update
- sudo apt-get -y install libudev-dev
- sudo apt-get -y install libsdl2-dev
script:
- cargo clippy --all -- -D warnings

View file

@ -27,54 +27,12 @@ thiserror = "1.0.15"
wgpu = "0.5.0"
futures = "0.3"
# These are only used by the examples, and enabled with features
# See: https://github.com/rust-lang/cargo/issues/1982
beryllium = { version = "0.2.1", features = [ "extern_crate_raw_window_handle" ], optional = true }
byteorder = { version = "1.3.4", optional = true }
env_logger = { version = "0.7.1", optional = true }
getrandom = { version = "0.1.14", optional = true }
gilrs = { version = "0.7.4", optional = true }
line_drawing = { version = "0.8.0", optional = true }
log = { version = "0.4.8", features = [ "release_max_level_warn" ], optional = true }
randomize = { version = "3.0.1", optional = true }
simple-invaders = { path = "simple-invaders", optional = true }
winit = { version = "0.22.0", optional = true }
winit_input_helper = { version = "0.6.0", optional = true }
[dev-dependencies]
pixels-mocks = { path = "pixels-mocks" }
winit = "0.22.0"
[[example]]
name = "conway"
required-features = ["conway"]
[[example]]
name = "invaders"
required-features = ["invaders"]
[[example]]
name = "minimal-sdl2"
required-features = ["minimal-sdl2"]
[[example]]
name = "minimal-winit"
required-features = ["minimal-winit"]
[features]
default = []
log-deps = ["env_logger", "log"]
random-deps = ["byteorder", "getrandom", "randomize"]
sdl2-deps = ["beryllium"]
winit-deps = ["winit", "winit_input_helper"]
conway = ["line_drawing", "log-deps", "random-deps", "winit-deps"]
invaders = ["gilrs", "log-deps", "random-deps", "simple-invaders", "winit-deps"]
minimal-sdl2 = ["log-deps", "sdl2-deps"]
minimal-winit = ["log-deps", "winit-deps"]
[workspace]
members = [
"examples/*",
"pixels-mocks",
"simple-invaders",
]

View file

@ -0,0 +1,17 @@
[package]
name = "conway"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
publish = false
[dependencies]
byteorder = "1.3.4"
env_logger = "0.7.1"
getrandom = "0.1.14"
line_drawing = "0.8.0"
log = { version = "0.4.8", features = [ "release_max_level_warn" ] }
pixels = { path = "../.." }
randomize = "3.0.1"
winit = "0.22.0"
winit_input_helper = "0.6.0"

View file

@ -5,7 +5,7 @@
## Running
```bash
cargo run --release --example conway --features conway
cargo run --release --package conway
```
## Controls

View file

@ -0,0 +1,18 @@
[package]
name = "invaders"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
publish = false
[dependencies]
byteorder = "1.3.4"
env_logger = "0.7.1"
getrandom = "0.1.14"
gilrs = "0.7.4"
log = { version = "0.4.8", features = [ "release_max_level_warn" ] }
pixels = { path = "../.." }
randomize = "3.0.1"
simple-invaders = { path = "simple-invaders" }
winit = "0.22.0"
winit_input_helper = "0.6.0"

View file

@ -7,7 +7,7 @@ The pixels have invaded!
## Running
```bash
cargo run --release --example invaders --features invaders
cargo run --release --package invaders
```
## Controls

View file

@ -0,0 +1,12 @@
[package]
name = "minimal-sdl2"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
publish = false
[dependencies]
beryllium = { version = "0.2.1", features = [ "extern_crate_raw_window_handle" ] }
env_logger = "0.7.1"
log = { version = "0.4.8", features = [ "release_max_level_warn" ] }
pixels = { path = "../.." }

View file

@ -7,11 +7,9 @@ Minimal example with SDL2 using `beryllium`.
## Running
```bash
cargo run --release --example minimal-sdl2 --features minimal-sdl2
cargo run --release --package minimal-sdl2
```
## About
This example demonstrates the absolute minimum for creating an SDL2 window and pixel buffer. It animates a purple box moving on a blue background, just for _something_ interesting to display.
The example currently does not run on macOS. See [#47](https://github.com/parasyte/pixels/issues/47) for details.

View file

@ -72,10 +72,10 @@ impl World {
/// Update the `World` internal state; bounce the box around the screen.
fn update(&mut self) {
if self.box_x <= 0 || self.box_x + BOX_SIZE - 1 >= WIDTH as i16 {
if self.box_x <= 0 || self.box_x + BOX_SIZE > WIDTH as i16 {
self.velocity_x *= -1;
}
if self.box_y <= 0 || self.box_y + BOX_SIZE - 1 >= HEIGHT as i16 {
if self.box_y <= 0 || self.box_y + BOX_SIZE > HEIGHT as i16 {
self.velocity_y *= -1;
}

View file

@ -0,0 +1,13 @@
[package]
name = "minimal-winit"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
publish = false
[dependencies]
env_logger = "0.7.1"
log = { version = "0.4.8", features = [ "release_max_level_warn" ] }
pixels = { path = "../.." }
winit = "0.22.0"
winit_input_helper = "0.6.0"

View file

@ -7,7 +7,7 @@ Minimal example with `winit`.
## Running
```bash
cargo run --release --example minimal-winit --features minimal-winit
cargo run --release --package minimal-winit
```
## About

View file

@ -87,10 +87,10 @@ impl World {
/// Update the `World` internal state; bounce the box around the screen.
fn update(&mut self) {
if self.box_x <= 0 || self.box_x + BOX_SIZE - 1 >= WIDTH as i16 {
if self.box_x <= 0 || self.box_x + BOX_SIZE > WIDTH as i16 {
self.velocity_x *= -1;
}
if self.box_y <= 0 || self.box_y + BOX_SIZE - 1 >= HEIGHT as i16 {
if self.box_y <= 0 || self.box_y + BOX_SIZE > HEIGHT as i16 {
self.velocity_y *= -1;
}

View file

@ -487,7 +487,7 @@ impl<'req> PixelsBuilder<'req> {
// Create all render passes
renderers.extend(self.renderer_factories.iter().map(|f| {
// TODO: Create a texture chain so that each pass recieves the texture drawn by the previous
// TODO: Create a texture chain so that each pass receives the texture drawn by the previous
f(
device.clone(),
queue.clone(),