I've been working a lot with Bela and SuperCollider in the past years and in the process have had to come up with a few creative ways to manage a growing codebase that needs to be two-way synchronizable between my laptop and a Bela (or multiple Belas in the case of installations).
The rub is this: in the process of developing a Bela project you sometimes edit things locally on your machine, and sometimes edit things on the Bela itself (or on the Bela via the IDE). So how do you keep things synchronized?
I'm curious what kind of workflows people have developed for building projects with Bela. I'll share mine.
First of all, nearly all my Bela projects start with a github repository. I'll use my banjer repository as an example. Git is pretty crucial for being able to version control the project, but also introduces some extra hoops to jump through for the purpose of synchronizing a central codebase between my laptop and all the Bela boards I might be developing this project on.
Setting up the sync repository
After creating a new repository on github I clone it to my laptop. (note: in all the following terminal commands, the prompt
mypc> means the command is being run on my laptop, the prompt
bela> indicates commands run on the Bela.
mypc> git clone https://github.com/jreus/banjer.git
Inside the repo create a
BelaProjects directory, this is where I do most of my development work.
Also create an
ext directory, this is where any custom SuperCollider classes and UGen binaries will live.
mypc> cd banjer
mypc> mkdir BelaProjects
mypc> mkdir ext
Next I make a second 'bare' git repository. This repository will be the sync point for modifications to the code that go back and forth between machines. Whenever I make commits locally I push my changes to this repository in the same manner as pushing commits up to the main repository on Github. I put all my sync repositories in a folder named
mypc> git init --bare ~/gitsync/banjer.git
Next I add the sync repository as a new remote that I can push changes to.
mypc> git remote add local ~/gitsync/banjer.git/
And update the sync repository with all my project files..
mypc> git push local master
Getting the repository on to the Bela
To get the codebase on the Bela, SSH in and make a clone of the sync repository using your computer's login credentials. Something like this...
mypc> ssh email@example.com
bela> git clone firstname.lastname@example.org:~/gitsync/banjer.git
My general strategy from here is to completely replace the
/root/Bela/projects directory with a symbolic link to the BelaProjects directory in my repository.
bela> rm -rf ~/Bela/projects
bela> ln -s ~/banjer/BelaProjects ~/Bela/projects
I also make a symbolic link in the SuperCollider extensions directory to my custom UGens..
bela> ln -s ~/banjer/ext /usr/local/share/SuperCollider/Extensions/MyUGens
Syncing Changes from the Bela to my PC
Now everything is set up, if I make some changes to my code on the Bela I can commit it to my git repository there and push it to the sync repository on my PC.
bela> git add *
bela> git commit -m 'made some changes'
bela> git push
Then on my PC I can pull the changes from the sync repo into my working directory.
mypc> git pull local master
Syncing Changes from the PC to the Bela
In the opposite direction, I can made some changes to code in my working directory, commit them and push them to my sync repository.
mypc> git add *
mypc> git commit -m 'made some changes'
mypc> git push local master
And then I can pull these changes down from the sync repository on my Bela.
bela> git pull