My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

mfconfig 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.0.x"}
  33. EXPORT=${3:-"bugfix-2.0.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 master
  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. echo "- Initializing BASE branch..."
  60. # Use the import branch as the source
  61. git checkout $IMPORT || exit
  62. # Copy to a temporary location
  63. TEMP=$( mktemp -d ) ; cp -R config $TEMP
  64. # Make sure we're not on the 'BASE' branch...
  65. git checkout master >/dev/null 2>&1 || exit
  66. # Create 'BASE' as a copy of 'init-repo' (README, LICENSE, etc.)
  67. git branch -D BASE 2>/dev/null
  68. git checkout init-repo -b BASE || exit
  69. # Copy all config files into place
  70. echo "- Copying configs from Marlin..."
  71. cp -R "$TEMP/config" .
  72. # Delete anything that's not a Configuration file
  73. find config -type f \! -name "Configuration*" -exec rm "{}" \;
  74. # DEBUG: Commit the original config files for comparison
  75. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null
  76. # Init Cartesian configurations to default
  77. echo "- Initializing configs to default state..."
  78. find "$CEXA" -name $BC ! -path */delta/* -print0 \
  79. | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
  80. find "$CEXA" -name $AC ! -path */delta/* -print0 \
  81. | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
  82. # DEBUG: Commit the reset for review
  83. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Cartesian/SCARA configs..." >/dev/null
  84. # Create base Delta configurations
  85. cp "$CDEF"/* "$CEXA/delta/generic"
  86. # DEBUG: Commit the reset for review
  87. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Generic Delta..." >/dev/null
  88. cp -R "$TEMP/$CEXA/delta/generic"/Conf* "$CEXA/delta/generic"
  89. # DEBUG: Commit Generic Delta changes for review
  90. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Apply Generic Delta..." >/dev/null
  91. find "$CEXA/delta" -name $BC ! -path */generic/* -print0 \
  92. | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$BC" "$F" ; done
  93. find "$CEXA/delta" -name $AC ! -path */generic/* -print0 \
  94. | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$AC" "$F" ; done
  95. # DEBUG: Commit the reset for review
  96. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Delta configs..." >/dev/null
  97. # SCARA configurations
  98. find "$CEXA/SCARA" -name $BC \
  99. | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
  100. find "$CEXA/SCARA" -name $AC \
  101. | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
  102. # DEBUG: Commit the reset for review or...
  103. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset SCARA..." >/dev/null
  104. # Update the %VERSION% in the README.md file
  105. SED=$(which gsed || which sed)
  106. VERS=$( echo $EXPORT | $SED 's/release-//' )
  107. eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
  108. rm -f README.md~
  109. # NOT DEBUGGING: Commit the 'BASE', ready for customizations
  110. ((COMMIT_STEPS)) || git add . >/dev/null && git commit --amend --no-edit >/dev/null
  111. # Create a new branch from 'BASE' for the final result
  112. echo "- Creating '$EXPORT' branch for the result..."
  113. git branch -D $EXPORT 2>/dev/null
  114. git checkout -b $EXPORT || exit
  115. # Delete temporary branch
  116. git branch -D BASE 2>/dev/null
  117. echo "- Applying example config customizations..."
  118. cp -R "$TEMP/config" .
  119. find config -type f \! -name "Configuration*" -exec rm "{}" \;
  120. echo "- Adding path labels to all configs..."
  121. config-labels.py >/dev/null 2>&1
  122. git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null
  123. echo "- Copying extras from Marlin..."
  124. cp -R "$TEMP/config" .
  125. # Apply labels again!
  126. config-labels.py >/dev/null 2>&1
  127. git add . >/dev/null && git commit -m "Examples Extras" >/dev/null
  128. rm -rf $TEMP
  129. git push -f --set-upstream upstream "$EXPORT"
  130. else
  131. echo "Usage: mfconfig init|manual|rebase"
  132. fi