Awesome
rgbenv
This is a version manager for RGBDS. It is a pure shell script.* Inspired by pyenv and 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
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
rgbenv install 0.7.0
rgbenv use 0.7.0
3. Use the default version
rgbenv exec rgbasm -V
(replace rgbasm -V
with your desired command)
To use it without rgbenv exec
…
echo 'export PATH="$HOME/.local/share/rgbenv/default/bin:$PATH"' >> .bashrc
source .bashrc
rgbasm -V
4. Execute with another version
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:
$ which rgbasm
What do I need?
- A Unix-like environment
- git
- curl
- RGBDS build dependencies
You can use these commands to get them:
<ul> <li>Debian: <pre><code># apt update # apt install libpng-dev pkg-config build-essential bison git curl </code></pre></li> <li>Alpine Linux: <pre><code># apk add git curl make libpng-dev bison gcc g++ libc-dev </code></pre></li> <li>OpenBSD: <pre><code># pkg_add png git bash curl bison </code></pre>In case something goes wrong, try using GCC as the compiler:<pre><code># pkg_add g++ gcc $ CC=egcc CXX=eg++ rgbenv install $YOUR_DESIRED_VERSION</code></pre></li> <li>Windows MSYS2 (MinGW64): <pre><code>$ pacman -S git make bison pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-libpng </code></pre>If you're using another environment with MSYS2, replace <code>mingw-w64-x86_64</code> with the corresponding name. You may need to do <code>mkdir -p /usr/local/bin</code> first.</li> <li>Windows Cygwin: From the setup program, select the latest versions of these packages:<ul> <li>git</li> <li>gcc-g++</li> <li>libpng-devel</li> <li>pkgconf</li> <li>bison</li> <li>make</li> </ul></li> </ul>How do I set it up?
<ol> <li>Install whatever dependencies it needs, through the above section.</li> <li>Download the rgbenv script, and place it in <code>/usr/local/bin/</code> (or any directory listed when you run <code>echo $PATH</code>) The fastest way is through: <pre><code># curl -Lo /usr/local/bin/rgbenv https://github.com/gbdev/rgbenv/raw/v0.1.3/rgbenv</code></pre></li> <li>Ensure the script is executable: <pre><code># chmod +x /usr/local/bin/rgbenv </code></pre>(replace <code>/usr/local/bin/rgbenv</code> with where you put the rgbenv script)</li> <li>Install the version you want, say 0.6.0:<pre><code>$ rgbenv install 0.6.0 </code></pre></li> <li>When prompted to add <code>export PATH=...</code> to <code>.bash_profile</code>, do so, then run: <pre><code>$ source ~/.bash_profile </code></pre><strong>Note: in some shells, you may need to specify <code>.profile</code> instead of <code>.bash_profile</code>.</strong></li> <li>Set your version as the default: <pre><code>$ rgbenv use 0.6.0 </code></pre></li> <li>Verify that RGBDS really is the version you picked: <pre><code>$ rgbasm -V </code></pre></li> </ol>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.1rgbenv no-use
- clear the defaults and use the system-provided RGBDS, if anyrgbenv exec -v 0.4.2 make
- runmake
using RGBDS 0.4.2rgbenv exec make
- runmake
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, the Bats repo will be cloned automatically inside the rgbenv directory if it is not present, and then Bats will be run from there.