From a1ada3877b14244c3f5ec67c3a374a75edca5ebf Mon Sep 17 00:00:00 2001 From: Abhijit Roy Date: Fri, 6 Oct 2023 18:27:55 +0530 Subject: [PATCH] Added Build & Install (using cargo) (#271) * added Install using cargo, build for all OS * added small info on optimized binary * minor info modification * minor change * updated as per comment https://github.com/subspace/pulsar/pull/271\#discussion_r1347247886 --- README.md | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8794ca36..e67cf253 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ Instead of running a terminal instance for the farmer, and running another termi ## How to Use (commands) -1. download the executable from [releases](https://github.com/subspace/pulsar/releases) -2. in your terminal, change your directory to where you download the file for example: if you downloaded your file to your `Downloads` folder, `cd Downloads`) -3. we will address your executable name as `pulsar`, change the below commands accordingly to your full executable name. -3. run `./pulsar init` -> this will initialize your config file, which will store the necessary information for you to farm. -4. run `./pulsar farm` -> this will start farming. Yes, it is that simple! Enjoy! +1. Download the executable from [releases](https://github.com/subspace/pulsar/releases) +2. In your terminal, change your directory to where you download the file for example: if you downloaded your file to your `Downloads` folder, `cd Downloads`. +3. We will address your executable name as `pulsar`, change the below commands accordingly to your full executable name. +4. Run `./pulsar init` -> this will initialize your config file, which will store the necessary information for you to farm. +5. Run `./pulsar farm` -> this will start farming. Yes, it is that simple! Enjoy! 🎉 ## Other commands @@ -51,7 +51,7 @@ $ ./pulsar farm Once it's running, you can detach the process by pressing `CTRL+b d` (read more about [detaching a sessions](https://linuxhint.com/detach-session-tmux/)) -That's it, you should be back to your terminal, with *subspace farming* running in the background as a session. +That's it, you should be back to your terminal, with _subspace farming_ running in the background as a session. To re-attach to your session, use tmux: @@ -67,7 +67,6 @@ tmux kill-session -t farming ### Example with `screen` - ```sh screen -S farming ``` @@ -91,3 +90,79 @@ If you ever want to delete/kill your farming session, enter the command: ```sh screen -S farming -X quit ``` + +## Developer + +### Pre-requisites + +You'll have to have [Rust toolchain](https://rustup.rs/) installed as well as LLVM, Clang and CMake in addition to usual developer tooling. + +Below are some examples of how to install these dependencies on different operating systems. + +#### Ubuntu + +```bash +sudo apt-get install llvm clang cmake +``` + +#### macOS + +1. Install via Homebrew: + +```bash +brew install llvm@15 clang cmake +``` + +2. Add `llvm` to your `~/.zshrc` or `~/.bashrc`: + +```bash +export PATH="/opt/homebrew/opt/llvm@15/bin:$PATH" +``` + +3. Activate the changes: + +```bash +source ~/.zshrc +# or +source ~/.bashrc +``` + +4. Verify that `llvm` is installed: + +```bash +llvm-config --version +``` + +### Build from Source + +Ensure the [pre-requisites](#pre-requisites). + +And then run: + +```sh +$ cargo build +``` + +> Use `--release` flag for a release build and optimized binary - `./target/release/pulsar` + +### Install CLI + +#### Using cargo + +After ensuring the [pre-requisites](#pre-requisites), just run: + +```sh +$ cargo run --release +``` + +This would generate an optimized binary. + +And then, you can install the binary (optimized) to your system: + +```sh +$ cargo install --path . +``` + +The binary gets added to `~/.cargo/bin`, which is included in the PATH environment variable by default during installation of Rust tools. So you can run it immediately from the shell. + +Using this, one doesn't need to download the executable (binary) from the [releases](https://github.com/subspace/pulsar/releases) page each time when there is a new release. They just need to pull the latest code (if already maintained) from the repository and build it locally.