spoticord/COMPILING.md

90 lines
2.9 KiB
Markdown
Raw Normal View History

2022-11-07 15:54:41 +00:00
# Compiling from source
2024-08-12 14:14:24 +00:00
2022-11-07 15:54:41 +00:00
## Initial setup
2024-08-12 14:14:24 +00:00
2022-11-07 15:54:41 +00:00
Spoticord is built using [rust](https://www.rust-lang.org/), so you'll need to install that first. It is cross-platform, so it should work on Windows, Linux and MacOS. You can find more info about how to install rust [here](https://www.rust-lang.org/tools/install).
### Rust formatter
2024-08-12 14:14:24 +00:00
2022-11-07 15:54:41 +00:00
Spoticord uses [rustfmt](https://github.com/rust-lang/rustfmt) to format the code, and we ask everyone that contributes to Spoticord to use it as well. You can install it by running the following command in your terminal:
```sh
rustup component add rustfmt
```
If you are using VSCode, you can install the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer) extension, which will automatically format your code when you save it (if you have `format on save` enabled). Although rust-analyzer is recommended anyway, as it provides a lot of useful features.
## Build dependencies
2024-08-12 14:14:24 +00:00
2022-11-07 15:54:41 +00:00
On Windows you'll need to install the [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) to be able to compile executables in rust (this will also be explained during the rust installation).
If you are on Linux, you can use your package manager to install the following dependencies:
```sh
# Debian/Ubuntu
sudo apt install build-essential
# Arch
sudo pacman -S base-devel
# Fedora
sudo dnf install gcc
```
2023-09-23 21:35:09 +00:00
Additionally, you will need to install CMake. On Windows, you can download CMake [here](https://cmake.org/download/). On Linux, you can use your package manager to install it:
2022-11-07 15:54:41 +00:00
```sh
# Debian/Ubuntu
2023-09-23 21:35:09 +00:00
sudo apt install cmake
2022-11-07 15:54:41 +00:00
# Arch
2023-09-23 21:35:09 +00:00
sudo pacman -S cmake
2022-11-07 15:54:41 +00:00
# Fedora
2023-09-23 21:35:09 +00:00
sudo dnf install cmake
2022-11-07 15:54:41 +00:00
```
## Compiling
2024-08-12 14:14:24 +00:00
2022-11-07 15:54:41 +00:00
Now that you have all the dependencies installed, you can compile Spoticord. To do this, you'll first need to clone the repository:
```sh
git clone https://github.com/SpoticordMusic/spoticord.git
```
After cloning the repo run the following command in the root of the repository:
```sh
2022-11-07 18:05:50 +00:00
cargo build
2022-11-07 15:54:41 +00:00
```
Or if you want to build a release version:
```sh
cargo build --release
```
This will compile the bot and place the executable in `target/release`. You can now run the bot by running the following command:
```sh
./target/release/spoticord
```
If you are actively developing Spoticord, you can use the following command to build and run the bot (this is easier than building and running the bot manually):
```sh
cargo run
2022-11-07 18:05:50 +00:00
```
2023-02-17 11:53:15 +00:00
2023-09-19 11:49:32 +00:00
# Features
As of now, Spoticord has one optional feature: `stats`. This feature enables collecting a few statistics, total and active servers. These statistics will be sent to a redis server, where they then can be read for whatever purpose. If you want to enable this feature, you can do so by running the following command:
```sh
2024-08-12 14:14:24 +00:00
cargo build [--release] --features stats
2023-09-19 11:49:32 +00:00
```
2023-02-17 11:53:15 +00:00
# MSRV
2024-08-12 14:14:24 +00:00
The current minimum supported rust version is `1.75.0` _(Checked with `cargo-msrv`)_.