build_all.sh 1.7 KB

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