build_all.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # Copyright (c) 2019 Clementine Computing LLC.
  3. #
  4. # This file is part of PopuFare.
  5. #
  6. # PopuFare is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # PopuFare is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  18. #
  19. modules=`cat client_modules.list | xargs echo`
  20. function copy_to_bin_dir
  21. {
  22. module_dir_pattern=`for i in $modules; do echo "^\./$i"; done | xargs echo | tr ' ' '|'`
  23. built_binaries=`find . -name buildit.sh | xargs egrep -o -- "-o[[:space:]]+[^[:space:]]+" | sed 's/buildit.sh:-o //' | egrep $module_dir_pattern`
  24. (rm ./bin/$target/*; mkdir -p ./bin/$target/;) 2> /dev/null
  25. for i in $built_binaries; do
  26. cp $i ./bin/$target/
  27. done
  28. }
  29. target=$1
  30. failed_mods=""
  31. . configure_target.sh.include
  32. if [ -z "$target_ok" ]; then
  33. echo "No rules to build for target \"$target\""
  34. exit 2
  35. fi
  36. for mod in $modules; do
  37. if (cd $mod; ./buildit.sh); then
  38. echo "Module \"$mod\" built successfully for $target"
  39. else
  40. echo "Module \"$mod\" failed to build for $target"
  41. failed_mods="$failed_mods $mod"
  42. fi
  43. done
  44. if [ -n "$failed_mods" ]; then
  45. echo
  46. echo "The following modules failed to build: $failed_mods"
  47. exit 1
  48. else
  49. echo
  50. echo "All modules built! Attempting to copy to ./bin/$target"
  51. copy_to_bin_dir
  52. exit 0
  53. fi