Forked from Chaircrusher/community-builds-from-source.sh
Last active
January 14, 2018 03:06
-
-
Save wizardishungry/a817d22b9860ca4c17a10ec25793d72d 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
#!/usr/bin/env bash | |
################################################################################################################################# | |
# community-builds-from-source.sh | |
# by Jeremy Wentworth | |
# | |
# Modified by Kent Williams [email protected] | |
# Modified by Jon 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: | |
# 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