Forked from jeremywen/community-builds-from-source.sh
Last active
April 27, 2025 18:31
-
-
Save Chaircrusher/4cc6de7a8203a526a3777a9ea1d3439f to your computer and use it in GitHub Desktop.
This script pulls down the VCV Rack community repo, finds source urls, pulls down source repos, and builds plugins.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################################################################################# | |
# community-builds-from-source.sh | |
# by Jeremy Wentworth | |
# | |
# Modified by Kent Williams [email protected] | |
# | |
# This script pulls down the VCV Rack community repo, finds source urls, pulls down source repos, and builds plugins. | |
# | |
# This script requires: | |
# 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 | |
# | |
################################################################################################################################# | |
# 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="" | |
# 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 jsonFile in community/plugins/*.json | |
do | |
gitPlugin="$(cat "${jsonFile}" | grep \"source\" | awk -F'"' '{print $4}')" | |
# skip no-source plugins | |
if [[ -z "${gitPlugin}" ]] | |
then | |
continue; | |
fi | |
# poke around in the json file | |
# to get the version | |
version=$(grep '"version":' "${jsonFile}" | awk -F'"' '{print $4}') | |
# 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 | |
# tries to cope with inconsistent version | |
# tags. | |
if [[ -z "${version}" ]] | |
then | |
git checkout master | |
echo checked out master | |
else | |
git checkout "v${version}" | |
if [ $? -ne 0 ] | |
then | |
git checkout "${version}" | |
if [ $? -ne 0 ] | |
then | |
git checkout master | |
echo checked out master | |
else | |
echo checked out "${version}" | |
fi | |
else | |
echo checked out "v${version}" | |
fi | |
fi | |
# try to check out the right tag | |
git checkout | |
# 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) dep | |
# finally, build the plugin | |
if make -j$(nproc) | |
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