Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor examples to build a single binary #805

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/bitcode_packing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ lz4_flex.workspace = true
rand.workspace = true

[lints]
workspace = true
workspace = true
1 change: 0 additions & 1 deletion benches/criterion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ harness = false
name = "message"
path = "src/message.rs"
harness = false

16 changes: 9 additions & 7 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ The top level `Cargo.toml` workspace defines the deps that examples can use and

## Running an example

- Run the server: `cargo run --features=server`
- Run client with id 1: `cargo run --features=client -- -c 1`
- Run client with id 2: `cargo run --features=client -- -c 2` (etc.)
- Run the client and server in two separate bevy Apps: `cargo run --features=server,client`
- Run the server with a gui: `cargo run --features=server,gui`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run --features=server,client -- -m=host-server`

- Run the server with a gui: `cargo run server`
- Run client with id 1: `cargo run client -c 1`
- Run client with id 2: `cargo run client -c 2`
- Run the client and server in two separate bevy Apps: `cargo run` or `cargo run separate`
- Run the server without a gui: `cargo run --no-default-features --features=server`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run host-server`

You can control the behaviour of the example by changing the list of features. By default, all features are enabled (client, server, gui).
For example you can run the server in headless mode (without gui) by running `cargo run --no-default-features --features=server`.
You can modify the file `assets/settings.ron` to modify some networking settings.

### Testing in wasm with webtransport
Expand Down
16 changes: 9 additions & 7 deletions examples/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ to the client. The client can then use the `ConnectToken` to start the `lightyea

## Running the example

- Run the server: `cargo run --features=server`
- Run client with id 1: `cargo run --features=client -- -c 1`
- Run client with id 2: `cargo run --features=client -- -c 2` (etc.)
- Run the client and server in two separate bevy Apps: `cargo run --features=server,client`
- Run the server with a gui: `cargo run --features=server,gui`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run --features=server,client -- -m=host-server`

- Run the server with a gui: `cargo run server`
- Run client with id 1: `cargo run client -c 1`
- Run client with id 2: `cargo run client -c 2`
- Run the client and server in two separate bevy Apps: `cargo run` or `cargo run separate`
- Run the server without a gui: `cargo run --no-default-features --features=server`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run host-server`

You can control the behaviour of the example by changing the list of features. By default, all features are enabled (client, server, gui).
For example you can run the server in headless mode (without gui) by running `cargo run --no-default-features --features=server`.
You can modify the file `assets/settings.ron` to modify some networking settings.

### Testing in wasm with webtransport
Expand Down
1 change: 1 addition & 0 deletions examples/auth/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub(crate) fn get_settings() -> MySettings {
},
},
ServerTransports::Udp { local_port: 5001 },
#[cfg(feature = "websocket")]
ServerTransports::WebSocket { local_port: 5002 },
#[cfg(feature = "steam")]
ServerTransports::Steam {
Expand Down
3 changes: 2 additions & 1 deletion examples/avian_3d_character/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2021"
publish = false

[features]
default = ["lightyear_examples_common/websocket"]
default = ["client", "server", "gui", "lightyear_examples_common/default"]
websocket = ["lightyear_examples_common/websocket"]
client = ["lightyear_examples_common/client", "gui"]
server = ["lightyear_examples_common/server"]
gui = ["lightyear_examples_common/gui"]
Expand Down
16 changes: 9 additions & 7 deletions examples/avian_3d_character/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ This is an example of a server containing server-authoritative, physics-based, 3

## Running the example

- Run the server: `cargo run --features=server`
- Run client with id 1: `cargo run --features=client -- -c 1`
- Run client with id 2: `cargo run --features=client -- -c 2` (etc.)
- Run the client and server in two separate bevy Apps: `cargo run --features=server,client`
- Run the server with a gui: `cargo run --features=server,gui`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run --features=server,client -- -m=host-server`

- Run the server with a gui: `cargo run server`
- Run client with id 1: `cargo run client -c 1`
- Run client with id 2: `cargo run client -c 2`
- Run the client and server in two separate bevy Apps: `cargo run` or `cargo run separate`
- Run the server without a gui: `cargo run --no-default-features --features=server`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run host-server`

You can control the behaviour of the example by changing the list of features. By default, all features are enabled (client, server, gui).
For example you can run the server in headless mode (without gui) by running `cargo run --no-default-features --features=server`.
You can modify the file `assets/settings.ron` to modify some networking settings.

### Testing in wasm with webtransport
Expand Down
2 changes: 1 addition & 1 deletion examples/avian_3d_character/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::shared::SharedPlugin;
use bevy::prelude::*;
use lightyear::prelude::client::PredictionConfig;
use lightyear_examples_common::app::{Apps, Cli};
use lightyear_examples_common::app::{Apps, Cli, Mode};
use lightyear_examples_common::settings::Settings;
use serde::{Deserialize, Serialize};

Expand Down
1 change: 1 addition & 0 deletions examples/avian_3d_character/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub(crate) fn get_settings() -> MySettings {
},
},
ServerTransports::Udp { local_port: 5001 },
#[cfg(feature = "websocket")]
ServerTransports::WebSocket { local_port: 5002 },
#[cfg(feature = "steam")]
ServerTransports::Steam {
Expand Down
3 changes: 2 additions & 1 deletion examples/avian_physics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2021"
publish = false

[features]
default = ["lightyear_examples_common/websocket"]
default = ["client", "server", "gui", "lightyear_examples_common/default"]
websocket = ["lightyear_examples_common/websocket"]
client = ["lightyear_examples_common/client", "gui"]
server = ["lightyear_examples_common/server"]
gui = ["lightyear_examples_common/gui"]
Expand Down
16 changes: 9 additions & 7 deletions examples/avian_physics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ enabled.*

## Running the example

- Run the server: `cargo run --features=server`
- Run client with id 1: `cargo run --features=client -- -c 1`
- Run client with id 2: `cargo run --features=client -- -c 2` (etc.)
- Run the client and server in two separate bevy Apps: `cargo run --features=server,client`
- Run the server with a gui: `cargo run --features=server,gui`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run --features=server,client -- -m=host-server`

- Run the server with a gui: `cargo run server`
- Run client with id 1: `cargo run client -c 1`
- Run client with id 2: `cargo run client -c 2`
- Run the client and server in two separate bevy Apps: `cargo run` or `cargo run separate`
- Run the server without a gui: `cargo run --no-default-features --features=server`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run host-server`

You can control the behaviour of the example by changing the list of features. By default, all features are enabled (client, server, gui).
For example you can run the server in headless mode (without gui) by running `cargo run --no-default-features --features=server`.
You can modify the file `assets/settings.ron` to modify some networking settings.

### Testing in wasm with webtransport
Expand Down
1 change: 1 addition & 0 deletions examples/avian_physics/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub(crate) fn get_settings() -> MySettings {
},
},
ServerTransports::Udp { local_port: 5001 },
#[cfg(feature = "websocket")]
ServerTransports::WebSocket { local_port: 5002 },
#[cfg(feature = "steam")]
ServerTransports::Steam {
Expand Down
3 changes: 2 additions & 1 deletion examples/bullet_prespawn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2021"
publish = false

[features]
default = ["lightyear_examples_common/websocket"]
default = ["client", "server", "gui", "lightyear_examples_common/default"]
websocket = ["lightyear_examples_common/websocket"]
client = ["lightyear_examples_common/client", "gui"]
server = ["lightyear_examples_common/server"]
gui = ["lightyear_examples_common/gui"]
Expand Down
16 changes: 9 additions & 7 deletions examples/bullet_prespawn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ https://github.com/cBournhonesque/lightyear/assets/8112632/ee547c32-1f14-4bdc-9e

## Running the example

- Run the server: `cargo run --features=server`
- Run client with id 1: `cargo run --features=client -- -c 1`
- Run client with id 2: `cargo run --features=client -- -c 2` (etc.)
- Run the client and server in two separate bevy Apps: `cargo run --features=server,client`
- Run the server with a gui: `cargo run --features=server,gui`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run --features=server,client -- -m=host-server`

- Run the server with a gui: `cargo run server`
- Run client with id 1: `cargo run client -c 1`
- Run client with id 2: `cargo run client -c 2`
- Run the client and server in two separate bevy Apps: `cargo run` or `cargo run separate`
- Run the server without a gui: `cargo run --no-default-features --features=server`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run host-server`

You can control the behaviour of the example by changing the list of features. By default, all features are enabled (client, server, gui).
For example you can run the server in headless mode (without gui) by running `cargo run --no-default-features --features=server`.
You can modify the file `assets/settings.ron` to modify some networking settings.

### Testing in wasm with webtransport
Expand Down
1 change: 1 addition & 0 deletions examples/bullet_prespawn/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub(crate) fn get_settings() -> MySettings {
},
},
ServerTransports::Udp { local_port: 5001 },
#[cfg(feature = "websocket")]
ServerTransports::WebSocket { local_port: 5002 },
#[cfg(feature = "steam")]
ServerTransports::Steam {
Expand Down
3 changes: 2 additions & 1 deletion examples/client_replication/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ license = "MIT OR Apache-2.0"
publish = false

[features]
default = ["lightyear_examples_common/websocket"]
default = ["client", "server", "gui", "lightyear_examples_common/default"]
websocket = ["lightyear_examples_common/websocket"]
client = ["lightyear_examples_common/client", "gui"]
server = ["lightyear_examples_common/server"]
gui = ["lightyear_examples_common/gui"]
Expand Down
16 changes: 9 additions & 7 deletions examples/client_replication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ https://github.com/cBournhonesque/lightyear/assets/8112632/718bfa44-80b5-4d83-a3

## Running the example

- Run the server: `cargo run --features=server`
- Run client with id 1: `cargo run --features=client -- -c 1`
- Run client with id 2: `cargo run --features=client -- -c 2` (etc.)
- Run the client and server in two separate bevy Apps: `cargo run --features=server,client`
- Run the server with a gui: `cargo run --features=server,gui`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run --features=server,client -- -m=host-server`

- Run the server with a gui: `cargo run server`
- Run client with id 1: `cargo run client -c 1`
- Run client with id 2: `cargo run client -c 2`
- Run the client and server in two separate bevy Apps: `cargo run` or `cargo run separate`
- Run the server without a gui: `cargo run --no-default-features --features=server`
- Run the client and server in "HostServer" mode, where the server is also a client (there is only one App): `cargo run host-server`

You can control the behaviour of the example by changing the list of features. By default, all features are enabled (client, server, gui).
For example you can run the server in headless mode (without gui) by running `cargo run --no-default-features --features=server`.
You can modify the file `assets/settings.ron` to modify some networking settings.

### Testing in wasm with webtransport
Expand Down
1 change: 1 addition & 0 deletions examples/client_replication/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub(crate) fn get_settings() -> Settings {
},
},
ServerTransports::Udp { local_port: 5001 },
#[cfg(feature = "websocket")]
ServerTransports::WebSocket { local_port: 5002 },
#[cfg(feature = "steam")]
ServerTransports::Steam {
Expand Down
Loading
Loading