https://github.com/laundmo/simple_bevy_template
cargo-generate template for a very simple bevy project. No conditionals, fast compiles active, only bevy.
https://github.com/laundmo/simple_bevy_template
bevy bevy-engine cargo-generate template
Last synced: 7 months ago
JSON representation
cargo-generate template for a very simple bevy project. No conditionals, fast compiles active, only bevy.
- Host: GitHub
- URL: https://github.com/laundmo/simple_bevy_template
- Owner: laundmo
- License: other
- Created: 2024-01-03T21:48:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-05T21:45:38.000Z (over 1 year ago)
- Last Synced: 2025-02-05T22:58:18.648Z (over 1 year ago)
- Topics: bevy, bevy-engine, cargo-generate, template
- Language: Liquid
- Homepage:
- Size: 15.6 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Basic Bevy template
Basic Bevy project template to get started quickly.
Use this template with:
```bash
cargo generate laundmo/simple_bevy_template --allow-commands
```
Fast-compile config, optional during setup:
- Mold (when on linux)
- Nightly Rust (generics sharing)
- Cranelift
- Parallel frontend
Other useful files included:
- Bacon config for running on save
- KDE Window Rule for always on top without focus stealing
- Import .kwinrule in the KDE "Window Rules" settings
- Move window and detect properties, then click on checkmark for position and size to adjust to your screen layout
Re-compile time for small changes (string content):
| time | options | OS/Kernel | CPU | RAM | Disk |
| ----- | ------- | -------------- | ----------- | ------------------------- | -------------------- |
| 0.53s | All | 6.14.3-arch1-1 | Ryzen 5800X | 2x16GB CL16 DDR4 3200MT/s | Samsung 980 PRO NVMe |
## Global cargo config / expert mode
Or: What is meant by "Skip generating cargo/toolchain config? (expert only)"?
I added that question for primarily myself, since i configure cargo with most of these options globally.
The downside of doing that is that it will cause cargo to complain about unstable options when trying to compile a project with the stable toolchain. This can be worked around by wrapping `cargo` in a shell function which runs with an extra config based on some conditions.
This is in my `.zshrc` - it defaults to nightly with fastcompiles config unless the local a `rust-toolchain.toml` (relative to call) specifies `stable`. You might want to adjust this, its supposed to serve as an example more than a finished solution.
```sh
function cargo() {
if [[ -f "rust-toolchain.toml" ]]; then
local channel=$(awk '/^channel =/ {print $3}' rust-toolchain.toml)
# Don't pass extra config for stable
if [[ $channel == *"stable"* ]]; then
echo Running cargo with stable config
command cargo "$@"
return
fi
fi
# Default behavior
echo Running cargo with fastcompiles config
command cargo --config ~/.cargo/config-fastcompiles.toml "$@"
return
}
compdef _cargo cargo
```
This is my `~/.cargo/config-fastcompiles.toml` - it matches pretty closely what is generated by this template, with the exception of setting `opt-level` in it instead of in `Cargo.toml` and configuring a global target dir so projects can share cache.
```toml
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
"-Clink-arg=-fuse-ld=/usr/bin/mold",
# Nightly
"-Zshare-generics=y",
"-Zthreads=0",
]
[unstable]
codegen-backend = true
[profile.dev]
codegen-backend = "cranelift"
opt-level = 3
[profile.dev.package."*"]
codegen-backend = "llvm"
opt-level = 3
[build]
target-dir = "/home/a/rust-projects/GLOBAL_TARGET_DIR/"
```