outfly/HACKING.md

96 lines
3 KiB
Markdown
Raw Normal View History

2024-04-29 14:31:58 +00:00
# Dev Features
For development, it's recommended to use `--features dev`:
```
cargo [run|build] --features dev
```
This enables the following:
- Mutes music by default (you can still unmute it)
- Enables "dev mode", which changes the game slightly:
- Enables additional cheats (see source code)
- Speeds up dialogs
- Adds additional debugging features
- Enables dynamic linking for faster compile times. Note that this makes it harder to run the game directly with `./outfly`, please use `cargo run` instead.
- Enables bevy's "file watcher" feature that auto-reloads changed assets while the game is running. This obviously works only if the assets are not embedded directly into the binary with the `embed_assets` feature. Since `embed_assets` is enabled by default, you must customize your compile features in order to use the file watcher feature, e.g. like: `--no-default-features --features "dev x11"`
# pack.sh
The [pack.sh](src/build/pack.sh) script is used by the developer team to compile and pack release binaries into official packages.
It could serve as a starting point for package maintainers or tinkerers.
# Building OutFly
If there is no package for the version or operating system that you need, or if you wish to tinker on the game, you can also build outfly yourself.
## On Linux
Install the build dependencies. On ArchLinux, it's the following, though you can replace `rust` with `rustup`:
```
pacman -S rust libx11 pkgconf alsa-lib
```
Then run the following commands, replacing `[URL]` with the clone URL of the git repository:
```
git clone [URL]
cd outfly
cargo run --release
```
## Building for Windows on Linux
```
rustup target add x86_64-pc-windows-gnu
pacman -S mingw-w64-toolchain # on ArchLinux. other distros have their equivalent package
cargo build --target=x86_64-pc-windows-gnu --release
```
More information here: https://bevy-cheatbook.github.io/setup/cross/linux-windows.html
## Building on Mac OS
Install homebrew, and then get the following dependencies:
```
brew install pkg-config molten-vk rustup
rustup-init
```
Download, compile and run the game:
```
git clone [URL]
cd outfly
cargo run --release
```
## Building for WASM/Browser
This is a work in progress, for now these are just some general hints:
```
git clone [URL]
cd outfly
rustup target install wasm32-unknown-unknown
pacman -S wasm-bindgen binaryen
mkdir outfly_wasm
cargo build --release --target wasm32-unknown-unknown
wasm-bindgen --out-name outfly --out-dir outfly_wasm --target web target/wasm32-unknown-unknown/release/outfly.wasm
wasm-opt -Oz --output wasm/outfly_bg.wasm wasm/outfly_bg.wasm
echo '<script type="module">import init from "./outfly.js"; init()</script>' > wasm/index.html
python -m http.server -d wasm
```
## Building release versions optimized for packaging
To build release versions optimized for final deployment, build with the following features: (see also [pack.sh](https://codeberg.org/hut/outfly/src/branch/main/src/build/pack.sh))
```
cargo build --release --no-default-features --features release_[linux|windows] [--target=$YOUR_TARGET]
```