You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.7KB

  1. #!/bin/bash
  2. #################################################################################################################################
  3. # community-builds-from-source.sh
  4. # by Jeremy Wentworth
  5. #
  6. # Modified by Kent Williams chaircrusher@gmail.com
  7. # Modified by Gerhard Brandt gbrandt@cern.ch
  8. #
  9. # This script pulls down the VCV Rack community repo, finds source urls, pulls down source repos, and builds plugins.
  10. #
  11. # This script requires:
  12. # bash - brew install bash # on mac
  13. # git - https://git-scm.com/
  14. # VCV Rack dev env - https://github.com/VCVRack/Rack#setting-up-your-development-environment
  15. #
  16. # Copy this script into:
  17. # Rack/plugins
  18. #
  19. # Run this in Rack/plugins:
  20. # . community-builds-from-source.sh
  21. #
  22. #################################################################################################################################
  23. nproc=`sysctl -n hw.physicalcpu` #mac
  24. #nproc=`nproc` #linux
  25. echo "threads: " $nproc
  26. # check for the community repo locally
  27. echo [Update community repo]
  28. echo
  29. if [ -d "community" ]; then
  30. pushd community
  31. # discard any changes
  32. git reset HEAD --hard
  33. # update the community repo if it exists
  34. if ! git pull; then
  35. git status
  36. exit
  37. fi
  38. popd
  39. else
  40. # community repo does not exist so pull it down
  41. git clone https://github.com/VCVRack/community
  42. fi
  43. echo
  44. buildfails=""
  45. # the strategy is that you want the 'latest and greatest' version of
  46. # each plugin -- the master branch. But some plugins won't compile
  47. # unless you check out a specific git label. So the versionMap lets
  48. # you look up that version below when checking out source.
  49. declare -A versionMap
  50. versionMap=([Autodafe]=skip [Autodafe-Drums]=skip
  51. [AepelzensParasites]=skip [NYSTHI]=skip
  52. [VCV-Console]=skip [VCV-PulseMatrix]=skip
  53. [Vult]=skip [VultModules]=skip
  54. [southpole-vcvrack]=skip
  55. [vcvrack-rtlsdr]=skip
  56. [Alikins-rack-plugins]=v0.5.2
  57. [AudibleInstruments]=v0.5.0
  58. [Befaco]=v0.5.0
  59. [BogaudioModules]=0.5.4
  60. [DHE-Modules]=v0.5.0
  61. [ESeries]=v0.5.0
  62. [JW-Modules]=v0.5.11
  63. [vcv_luckyxxl]=v0.5.1)
  64. # helper function to see if a particular key is in an associative array
  65. exists(){
  66. if [ "$2" != in ]; then
  67. echo "Incorrect usage."
  68. echo "Correct usage: exists {key} in {array}"
  69. return
  70. fi
  71. eval '[ ${'$3'[$1]+muahaha} ]'
  72. }
  73. # loop through the json in the community repo
  74. for gitPlugin in $(cat community/plugins/*.json | grep \"source\" | awk -F'"' '{print $4}')
  75. do
  76. #strip eventual extension
  77. gitPlugin=${gitPlugin%.git}
  78. # get the folder name and see if we already haave it locally
  79. pluginDirName=$(echo $gitPlugin | awk -F'/' '{print $5}')
  80. echo
  81. echo [$pluginDirName]
  82. if exists ${pluginDirName} in versionMap
  83. then
  84. echo ${versionMap[${pluginDirName}]}
  85. if [ ${versionMap[${pluginDirName}]} == "skip" ]
  86. then
  87. echo [$pluginDirName SKIPPING]
  88. continue;
  89. fi
  90. fi
  91. #echo ${gitPlugin%.git}
  92. if [ -d "$pluginDirName" ]; then
  93. echo "[$pluginDirName exists]"
  94. else
  95. echo "[$pluginDirName does not exist yet]"
  96. userNameUrlPart=$(echo $gitPlugin | awk -F'/' '{print $4}')
  97. #git clone ${gitPlugin%.git} #strip eventual extension
  98. git clone $gitPlugin #NOTE: not all plugins are on github, sonus is on gitlab
  99. fi
  100. # if there's a problem with checkout everything goes to hell
  101. if [ ! -d ${pluginDirName} ] ; then
  102. echo "[$pluginDirName] clone failed!!!"
  103. exit
  104. continue;
  105. fi
  106. # change to the repo dir
  107. pushd $pluginDirName
  108. # Some devs don't have a .gitignore so you can't pull until you do something with the changed files.
  109. git reset HEAD --hard #discards any changes - we could do `git stash` here instead
  110. git clean -f -d
  111. # pull down the latest code
  112. git pull
  113. if exists ${pluginDirName} in versionMap
  114. then
  115. git checkout ${versionMap[${pluginDirName}]}
  116. else
  117. latest=`git describe --tags --abbrev=0`
  118. if [[ ! -z $latest ]]; then
  119. echo "[$pluginDirName Latest tag: $latest]"
  120. #git checkout $latest
  121. git checkout master
  122. git pull
  123. else
  124. echo "[$pluginDirName no tags - using master !!!]"
  125. git checkout master
  126. fi
  127. fi
  128. # try to update submodules if there are any
  129. git submodule update --init --recursive
  130. # clean old builds (might not be needed but can prevent issues)
  131. #make clean
  132. make -q dep
  133. if test $? -le 1 ; then
  134. make -j$nproc dep
  135. fi
  136. # finally, build the plugin
  137. if make -j$nproc
  138. then
  139. true; # say nothing
  140. else
  141. # if master failed try again with latest tag
  142. echo "[$pluginDirName master failed - trying latest tag $latest]"
  143. git checkout $latest
  144. make clean
  145. if make -j$nproc
  146. then
  147. true;
  148. else
  149. buildfails="${buildfails} ${pluginDirName}"
  150. fi
  151. fi
  152. # go back to the last dir
  153. popd
  154. done
  155. echo "BUILD FAILURES: ${buildfails}"
  156. echo
  157. echo "Binaries only:"
  158. for binOnly in $(grep -L \"source\" community/plugins/*.json)
  159. do
  160. for dlurl in $(cat $binOnly | grep \"download\" | awk -F'"' '{print $4}')
  161. do
  162. echo $dlurl
  163. done
  164. done