Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script pulls down the VCV Rack community repo, finds source urls, pulls down source repos, and builds plugins.
#!/usr/bin/env bash
#################################################################################################################################
# community-builds-from-source.sh
# by Jeremy Wentworth
#
# Modified by Kent Williams chaircrusher@gmail.com
# Modified by Jon Williams jon@jonwillia.ms
#
# This script pulls down the VCV Rack community repo, finds source urls, pulls down source repos, and builds plugins.
#
# This script requires:
# Bash (>=4)
# git - https://git-scm.com/
# VCV Rack dev env - https://github.com/VCVRack/Rack#setting-up-your-development-environment
#
# Copy this script into:
# Rack/plugins
#
# Run this in Rack/plugins:
# . community-builds-from-source.sh
#
#################################################################################################################################
if [ $BASH_VERSINFO -lt '4' ]; then
echo "You need a newer version of Bash. You're using $BASH_VERSION"
exit 1
fi
# check for the community repo locally
if [ -d "community" ]; then
pushd community
# discard any changes
git reset HEAD --hard
# update the community repo if it exists
git pull
popd
else
# community repo does not exist so pull it down
git clone https://github.com/VCVRack/community
fi
buildfails=""
# the strategy is that you want the 'latest and greatest' version of
# each plugin -- the master branch. But some plugins won't compile
# unless you check out a specific git label. So the versionMap lets
# you look up that version below when checking out source.
declare -A versionMap
versionMap=([AudibleInstruments]=v0.5.0 [Autodafe]=skip [Befaco]=v0.5.0
[Fundamental]=v0.5.1 [RJModules]=0.5.0
[trowasoft-VCV]=v0.5.5)
# helper function to see if a particular key is in an associative array
exists(){
if [ "$2" != in ]; then
echo "Incorrect usage."
echo "Correct usage: exists {key} in {array}"
return
fi
eval '[ ${'$3'[$1]+muahaha} ]'
}
# loop through the json in the community repo
for gitPlugin in $(cat community/plugins/*.json | grep \"source\" | awk -F'"' '{print $4}')
do
# get the folder name and see if we already haave it locally
pluginDirName=$(echo $gitPlugin | awk -F'/' '{print $5}')
if [ -d "$pluginDirName" ]; then
echo "$pluginDirName exists"
else
echo "$pluginDirName does not exists yet"
userNameUrlPart=$(echo $gitPlugin | awk -F'/' '{print $4}')
git clone $gitPlugin #NOTE: not all plugins are on github, sonus is on gitlab
fi
# if there's a problem with checkout everything goes to hell
if [ ! -d ${pluginDirName} ] ; then
continue;
fi
# change to the repo dir
pushd $pluginDirName
# Some devs don't have a .gitignore so you can't pull until you do something with the changed files.
git reset HEAD --hard #discards any changes - we could do `git stash` here instead
# pull down the latest code
git fetch
if exists ${pluginDirName} in versionMap
then
if [ ${versionMap[${pluginDirName}]} == "skip" ]
then
popd
continue;
else
git checkout ${versionMap[${pluginDirName}]}
fi
else
git checkout master
fi
# try to update submodules if there are any
git submodule update --init --recursive
# clean old builds (might not be needed but can prevent issues)
make clean
make -j$(nproc||gnproc) dep
# finally, build the plugin
if make -j$(nproc||gnproc)
then
true; # say nothing
else
buildfails="${buildfails} ${pluginDirName}"
fi
# go back to the last dir
popd
done
echo "BUILD FAILURES: ${buildfails}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment