cargo new learn_bevy_game
cd learn_bevy_game
由於Rust在編譯Bevy時會花費很久M,可以啟用dynamic linking
、安裝LLD linker和Nightly Rust Compiler來達到編譯加速
brew install michaeleisel/zld/zld
.cargo
並在裡面新增config.toml
# Add the contents of this file to `config.toml` to enable "fast build" configuration. Please read the notes below.
# NOTE: For maximum performance, build using a nightly compiler
# If you are using rust stable, remove the "-Zshare-generics=y" below.
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]
# NOTE: you must install [Mach-O LLD Port](https://lld.llvm.org/MachO/index.html) on mac. you can easily do this by installing llvm which includes lld with the "brew" package manager:
# `brew install llvm`
[target.x86_64-apple-darwin]
rustflags = [
"-C",
"link-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld",
"-Zshare-generics=y",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C",
"link-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld",
"-Zshare-generics=y",
]
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=n"]
# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
#[profile.dev]
#debug = 1
新增rust-toolchain.toml
[toolchain]
channel = "nightly"
Cargo.toml
[package]
name = "learn_bevy_game"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = "0.11.2"
mkdir -p bevy/dynamic_linking
cargo run --features bevy/dynamic_linking
這邊會需要等一段時間,結束之後執行
cargo run
這邊也會編譯一段時間,之後再次編譯就會變快很多,今天先設定好環境明天再來開工。
設定後的專案結構