build_example 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. #
  3. # build_example
  4. #
  5. # Usage: build_example internal config-home config-folder
  6. #
  7. . mfutil
  8. # Require 'internal' as the first argument
  9. [[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
  10. echo "Testing $3:"
  11. SUB=$2/config/examples/$3
  12. [[ -d "$SUB" ]] || { echo "$SUB is not a good path" ; exit 1 ; }
  13. compgen -G "${SUB}Con*.h" > /dev/null || { echo "No configuration files found in $SUB" ; exit 1 ; }
  14. echo "Getting configuration files from $SUB"
  15. cp "$2/config/default"/*.h Marlin/
  16. cp "$SUB"/Configuration.h Marlin/ 2>/dev/null
  17. cp "$SUB"/Configuration_adv.h Marlin/ 2>/dev/null
  18. cp "$SUB"/_Bootscreen.h Marlin/ 2>/dev/null
  19. cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null
  20. set -e
  21. # Strip #error lines from Configuration.h
  22. IFS=$'\n'; set -f
  23. $SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h
  24. rm Marlin/Configuration.h~
  25. unset IFS; set +f
  26. echo "Building the firmware now..."
  27. $HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; }
  28. echo "Success"