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:
parent
37b90fe6b4
commit
9de2383712
|
@ -1,4 +1,5 @@
|
||||||
language: rust
|
language: rust
|
||||||
|
dist: bionic
|
||||||
rust:
|
rust:
|
||||||
# MSRV
|
# MSRV
|
||||||
- 1.40.0
|
- 1.40.0
|
||||||
|
@ -13,7 +14,7 @@ before_script:
|
||||||
- rustup component add clippy
|
- rustup component add clippy
|
||||||
- rustup component add rustfmt
|
- rustup component add rustfmt
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
- sudo apt-get -y install libudev-dev
|
- sudo apt-get -y install libsdl2-dev
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo clippy --all -- -D warnings
|
- cargo clippy --all -- -D warnings
|
||||||
|
|
44
Cargo.toml
44
Cargo.toml
|
@ -27,54 +27,12 @@ thiserror = "1.0.15"
|
||||||
wgpu = "0.5.0"
|
wgpu = "0.5.0"
|
||||||
futures = "0.3"
|
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]
|
[dev-dependencies]
|
||||||
pixels-mocks = { path = "pixels-mocks" }
|
pixels-mocks = { path = "pixels-mocks" }
|
||||||
winit = "0.22.0"
|
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]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"examples/*",
|
||||||
"pixels-mocks",
|
"pixels-mocks",
|
||||||
"simple-invaders",
|
|
||||||
]
|
]
|
||||||
|
|
17
examples/conway/Cargo.toml
Normal file
17
examples/conway/Cargo.toml
Normal 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"
|
|
@ -5,7 +5,7 @@
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo run --release --example conway --features conway
|
cargo run --release --package conway
|
||||||
```
|
```
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
18
examples/invaders/Cargo.toml
Normal file
18
examples/invaders/Cargo.toml
Normal 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"
|
|
@ -7,7 +7,7 @@ The pixels have invaded!
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo run --release --example invaders --features invaders
|
cargo run --release --package invaders
|
||||||
```
|
```
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
12
examples/minimal-sdl2/Cargo.toml
Normal file
12
examples/minimal-sdl2/Cargo.toml
Normal 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 = "../.." }
|
|
@ -7,11 +7,9 @@ Minimal example with SDL2 using `beryllium`.
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo run --release --example minimal-sdl2 --features minimal-sdl2
|
cargo run --release --package minimal-sdl2
|
||||||
```
|
```
|
||||||
|
|
||||||
## About
|
## 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.
|
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.
|
|
||||||
|
|
|
@ -72,10 +72,10 @@ impl World {
|
||||||
|
|
||||||
/// Update the `World` internal state; bounce the box around the screen.
|
/// Update the `World` internal state; bounce the box around the screen.
|
||||||
fn update(&mut self) {
|
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;
|
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;
|
self.velocity_y *= -1;
|
||||||
}
|
}
|
||||||
|
|
13
examples/minimal-winit/Cargo.toml
Normal file
13
examples/minimal-winit/Cargo.toml
Normal 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"
|
|
@ -7,7 +7,7 @@ Minimal example with `winit`.
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo run --release --example minimal-winit --features minimal-winit
|
cargo run --release --package minimal-winit
|
||||||
```
|
```
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
|
@ -87,10 +87,10 @@ impl World {
|
||||||
|
|
||||||
/// Update the `World` internal state; bounce the box around the screen.
|
/// Update the `World` internal state; bounce the box around the screen.
|
||||||
fn update(&mut self) {
|
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;
|
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;
|
self.velocity_y *= -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,7 +487,7 @@ impl<'req> PixelsBuilder<'req> {
|
||||||
|
|
||||||
// Create all render passes
|
// Create all render passes
|
||||||
renderers.extend(self.renderer_factories.iter().map(|f| {
|
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(
|
f(
|
||||||
device.clone(),
|
device.clone(),
|
||||||
queue.clone(),
|
queue.clone(),
|
||||||
|
|
Loading…
Reference in a new issue