https://github.com/gbdev/rgbenv
RGBDS version manager
https://github.com/gbdev/rgbenv
Last synced: 9 months ago
JSON representation
RGBDS version manager
- Host: GitHub
- URL: https://github.com/gbdev/rgbenv
- Owner: gbdev
- License: mit
- Created: 2022-11-13T14:17:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-25T05:49:00.000Z (almost 2 years ago)
- Last Synced: 2025-04-11T14:04:57.122Z (12 months ago)
- Language: Shell
- Homepage:
- Size: 42 KB
- Stars: 10
- Watchers: 4
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rgbenv
This is a version manager for [RGBDS](https://github.com/gbdev/rgbds). It is a pure shell script.* Inspired by [pyenv](https://github.com/pyenv/pyenv) and [rbenv](https://github.com/rbenv/rbenv), it lets you easily switch between multiple versions of the RGBDS suite to suit different projects.
\* Bash script, at the moment. Compatibility with other shells is not guaranteed.
## Quickstart (Debian)
### 1. Get rgbenv
```sh
sudo apt install -y libpng-dev pkg-config build-essential bison git curl
sudo curl -Lo /usr/local/bin/rgbenv https://github.com/gbdev/rgbenv/raw/v0.1.3/rgbenv
sudo chmod +x /usr/local/bin/rgbenv
```
### 2. Install a version and set it as the default
```sh
rgbenv install 0.7.0
rgbenv use 0.7.0
```
### 3. Use the default version
```sh
rgbenv exec rgbasm -V
```
(replace `rgbasm -V` with your desired command)
To use it without `rgbenv exec`…
```sh
echo 'export PATH="$HOME/.local/share/rgbenv/default/bin:$PATH"' >> .bashrc
source .bashrc
rgbasm -V
```
### 4. Execute with another version
```sh
rgbenv install 0.6.1
rgbenv exec -v 0.6.1 rgbasm -V
```
(replace `rgbasm -V` with your desired command)
## What does it do?
* Installs or uninstalls a specific version of the RGBDS suite.
* Lets you configure the default version to use.
* Lets you specify a version to be used with a specific project.
## How does it do that?
`PATH` is the variable used by the system to determine where to find some program. It contains a list of directories, separated by a colon each:
```
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin
```
Left-most directories take priority. If a program isn't found there, it will search the directory next to it.
As an example, if you installed RGBDS 0.6.0 through your package manager, it would place the suite programs in `/usr/bin`. If you compiled, say, version 0.4.1 of RGBDS manually and placed it in `/usr/local/bin`, then *that* version would take precedence over 0.6.0.
What rgbenv does is override this variable so that its managed folder takes precedence over that of the system. In Unix-like systems, you can check which directory a program is to be run from (for example, `rgbasm`) using this command:
```sh
$ which rgbasm
```
## What do I need?
* A Unix-like environment
* Linux or BSD preferable
* On Windows, you may use either:
* [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) with a distro of choice
* [MSYS2](https://www.msys2.org/)
* [Cygwin](https://cygwin.com/)
* git
* curl
* [RGBDS build dependencies](https://rgbds.gbdev.io/install/source/#2-build)
You can use these commands to get them:
- Debian:
# apt update
# apt install libpng-dev pkg-config build-essential bison git curl - Alpine Linux:
# apk add git curl make libpng-dev bison gcc g++ libc-dev - OpenBSD:
In case something goes wrong, try using GCC as the compiler:# pkg_add png git bash curl bison# pkg_add g++ gcc
$ CC=egcc CXX=eg++ rgbenv install $YOUR_DESIRED_VERSION - Windows MSYS2 (MinGW64):
If you're using another environment with MSYS2, replace$ pacman -S git make bison pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-libpngmingw-w64-x86_64with the corresponding name. You may need to domkdir -p /usr/local/binfirst. - Windows Cygwin: From the setup program, select the latest versions of these packages:
- git
- gcc-g++
- libpng-devel
- pkgconf
- bison
- make
## How do I set it up?
- Install whatever dependencies it needs, through the above section.
- Download the rgbenv script, and place it in
/usr/local/bin/(or any directory listed when you runecho $PATH) The fastest way is through:# curl -Lo /usr/local/bin/rgbenv https://github.com/gbdev/rgbenv/raw/v0.1.3/rgbenv - Ensure the script is executable:
(replace# chmod +x /usr/local/bin/rgbenv/usr/local/bin/rgbenvwith where you put the rgbenv script) - Install the version you want, say 0.6.0:
$ rgbenv install 0.6.0 - When prompted to add
export PATH=...to.bash_profile, do so, then run:$ source ~/.bash_profile
Note: in some shells, you may need to specify.profileinstead of.bash_profile. - Set your version as the default:
$ rgbenv use 0.6.0 - Verify that RGBDS really is the version you picked:
$ rgbasm -V
## How to set a project-specified version
On the current working directory, make a file named `.rgbds-version`. This shall be a text file containing only the version number to be used. For example:
```
$ cat .rgbds-version
0.6.0
```
## Quick commands
* `rgbenv use 0.5.1` - set default RGBDS version to 0.5.1
* `rgbenv no-use` - clear the defaults and use the system-provided RGBDS, if any
* `rgbenv exec -v 0.4.2 make` - run `make` using RGBDS 0.4.2
* `rgbenv exec make` - run `make` with the project-specified RGBDS version.
## Development
At the moment, rgbenv is hosted on GitHub.
To run the unit tests on your own machine, clone the rgbenv repo (instead of just downloading the script as above), and then run `make test`:
```
$ git clone https://github.com/gbdev/rgbenv
$ cd rgbenv
$ make test
```
As the unit tests use [Bats](https://github.com/bats-core/bats-core), the Bats repo will be cloned automatically inside the rgbenv directory if it is not present, and then Bats will be run from there.