My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/usr/bin/env bash
  2. #
  3. # mfconfig init source dest
  4. # mfconfig manual source dest
  5. #
  6. # The MarlinFirmware/Configurations layout could be broken up into branches,
  7. # but this makes management more complicated and requires more commits to
  8. # perform the same operation, so this uses a single branch with subfolders.
  9. #
  10. # init - Initialize the repo with a base commit and changes:
  11. # - Source will be an 'import' branch containing all current configs.
  12. # - Create an empty 'BASE' branch from 'init-repo'.
  13. # - Add Marlin config files, but reset all to defaults.
  14. # - Commit this so changes will be clear in following commits.
  15. # - Add changed Marlin config files and commit.
  16. #
  17. # manual - Manually import changes from the Marlin repo
  18. # - Replace 'default' configs with those from the Marlin repo.
  19. # - Wait for manual propagation to the rest of the configs.
  20. # - Run init with the given 'source' and 'dest'
  21. #
  22. REPOHOME="`dirname ~/Projects/Maker/Firmware/.`"
  23. MARLINREPO="$REPOHOME/MarlinFirmware"
  24. CONFIGREPO="$REPOHOME/Configurations"
  25. CEXA=config/examples
  26. CDEF=config/default
  27. BC=Configuration.h
  28. AC=Configuration_adv.h
  29. COMMIT_STEPS=0
  30. #cd "$CONFIGREPO" 2>/dev/null || { echo "Can't find Configurations repo!" ; exit 1; }
  31. ACTION=${1:-init}
  32. IMPORT=${2:-"import-2.1.x"}
  33. EXPORT=${3:-"bugfix-2.1.x"}
  34. echo -n "Doing grhh ... " ; grhh ; echo
  35. if [[ $ACTION == "manual" ]]; then
  36. #
  37. # Copy the latest default configs from MarlinFirmware/Marlin
  38. # or one of the import branches here, then use them to construct
  39. # a 'BASE' branch with only defaults as a starting point.
  40. #
  41. echo "- Updating '$IMPORT' from Marlin..."
  42. git checkout $IMPORT || exit
  43. # Reset from the latest complete state
  44. #git reset --hard bugfix-2.1.x
  45. cp "$MARLINREPO/Marlin/"Configuration*.h "$CDEF/"
  46. #git add . && git commit -m "Changes from Marlin ($(date '+%Y-%m-%d %H:%M'))."
  47. echo "- Fix up the import branch and come back."
  48. read -p "- Ready to init [y/N] ?" INIT_YES
  49. echo
  50. [[ $INIT_YES == 'Y' || $INIT_YES == 'y' ]] || { echo "Done." ; exit ; }
  51. ACTION='init'
  52. fi
  53. if [[ $ACTION == "init" ]]; then
  54. #
  55. # Copy all configs from a source such as MarlinFirmware/Marlin
  56. # or one of the import branches here, then use them to construct
  57. # a 'BASE' branch with only defaults as a starting point.
  58. #
  59. SED=$(which gsed sed | head -n1)
  60. echo "- Initializing BASE branch..."
  61. # Use the import branch as the source
  62. git checkout $IMPORT || exit
  63. # Copy to a temporary location
  64. TEMP=$( mktemp -d ) ; cp -R config $TEMP
  65. # Strip all #error lines
  66. IFS=$'\n'; set -f
  67. for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do
  68. $SED -i~ -e "20,30{/#error/d}" "$fn"
  69. rm "$fn~"
  70. done
  71. unset IFS; set +f
  72. # Make sure we're not on the 'BASE' branch...
  73. git checkout init-repo >/dev/null 2>&1 || exit
  74. # Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.)
  75. git branch -D BASE 2>/dev/null
  76. git checkout init-repo -b BASE || exit
  77. # Copy all config files into place
  78. echo "- Copying all configs from fresh $IMPORT..."
  79. cp -R "$TEMP/config" .
  80. # Delete anything that's not a Configuration file
  81. find config -type f \! -name "Configuration*" -exec rm "{}" \;
  82. # DEBUG: Commit the original config files for comparison
  83. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null
  84. # Init Cartesian/SCARA/TPARA configurations to default
  85. echo "- Initializing configs to default state..."
  86. find "$CEXA" -name $BC -print0 \
  87. | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
  88. find "$CEXA" -name $AC -print0 \
  89. | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
  90. # DEBUG: Commit the reset for review
  91. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset configs..." >/dev/null
  92. # Update the %VERSION% in the README.md file
  93. VERS=$( echo $EXPORT | $SED 's/release-//' )
  94. eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
  95. rm -f README.md~
  96. # NOT DEBUGGING: Commit the 'BASE', ready for customizations
  97. ((COMMIT_STEPS)) || git add . >/dev/null && git commit --amend --no-edit >/dev/null
  98. # Create a new branch from 'BASE' for the final result
  99. echo "- Creating '$EXPORT' branch for the result..."
  100. git branch -D $EXPORT 2>/dev/null
  101. git checkout -b $EXPORT || exit
  102. # Delete temporary branch
  103. git branch -D BASE 2>/dev/null
  104. echo "- Applying example config customizations..."
  105. cp -R "$TEMP/config" .
  106. find config -type f \! -name "Configuration*" -exec rm "{}" \;
  107. echo "- Adding path labels to all configs..."
  108. config-labels.py >/dev/null 2>&1
  109. git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null
  110. echo "- Copying extras from Marlin..."
  111. cp -R "$TEMP/config" .
  112. # Apply labels again!
  113. config-labels.py >/dev/null 2>&1
  114. git add . >/dev/null && git commit -m "Examples Extras" >/dev/null
  115. rm -rf $TEMP
  116. git push -f --set-upstream upstream "$EXPORT"
  117. else
  118. echo "Usage: mfconfig init|manual|rebase"
  119. fi