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 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 bugfix-2.0.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. 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 init-repo >/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 all configs from fresh $IMPORT..."
  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/SCARA/TPARA configurations to default
  77. echo "- Initializing Cartesian/SCARA/TPARA 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/TPARA 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. # Reset all Delta configs to the generic version
  92. find "$CEXA/delta" -name $BC ! -path */generic/* -print0 \
  93. | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$BC" "$F" ; done
  94. find "$CEXA/delta" -name $AC ! -path */generic/* -print0 \
  95. | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$AC" "$F" ; done
  96. # DEBUG: Commit the Delta reset for review
  97. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Delta configs..." >/dev/null
  98. # Reset all SCARA configs to the default cartesian
  99. find "$CEXA/SCARA" -name $BC \
  100. | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
  101. find "$CEXA/SCARA" -name $AC \
  102. | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
  103. # DEBUG: Commit the SCARA reset for review
  104. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset SCARA..." >/dev/null
  105. # Reset all TPARA configs to the default cartesian
  106. find "$CEXA/TPARA" -name $BC \
  107. | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done
  108. find "$CEXA/TPARA" -name $AC \
  109. | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done
  110. # DEBUG: Commit the TPARA reset for review
  111. ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null
  112. # Update the %VERSION% in the README.md file
  113. SED=$(which gsed sed | head -n1)
  114. VERS=$( echo $EXPORT | $SED 's/release-//' )
  115. eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
  116. rm -f README.md~
  117. # NOT DEBUGGING: Commit the 'BASE', ready for customizations
  118. ((COMMIT_STEPS)) || git add . >/dev/null && git commit --amend --no-edit >/dev/null
  119. # Create a new branch from 'BASE' for the final result
  120. echo "- Creating '$EXPORT' branch for the result..."
  121. git branch -D $EXPORT 2>/dev/null
  122. git checkout -b $EXPORT || exit
  123. # Delete temporary branch
  124. git branch -D BASE 2>/dev/null
  125. echo "- Applying example config customizations..."
  126. cp -R "$TEMP/config" .
  127. find config -type f \! -name "Configuration*" -exec rm "{}" \;
  128. echo "- Adding path labels to all configs..."
  129. config-labels.py >/dev/null 2>&1
  130. git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null
  131. echo "- Copying extras from Marlin..."
  132. cp -R "$TEMP/config" .
  133. # Apply labels again!
  134. config-labels.py >/dev/null 2>&1
  135. git add . >/dev/null && git commit -m "Examples Extras" >/dev/null
  136. rm -rf $TEMP
  137. git push -f --set-upstream upstream "$EXPORT"
  138. else
  139. echo "Usage: mfconfig init|manual|rebase"
  140. fi