Merge upstream changes from Marlin 2.1.2.1

This commit is contained in:
Stefan Kalscheuer
2023-05-26 18:48:34 +02:00
parent 22dedaeb81
commit f92a587638
620 changed files with 41015 additions and 28889 deletions

View File

@@ -18,7 +18,16 @@ def apply_opt(name, val, conf=None):
if name == "lcd": name, val = val, "on"
# Create a regex to match the option and capture parts of the line
regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE)
# 1: Indentation
# 2: Comment
# 3: #define and whitespace
# 4: Option name
# 5: First space after name
# 6: Remaining spaces between name and value
# 7: Option value
# 8: Whitespace after value
# 9: End comment
regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s?)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE)
# Find and enable and/or update all matches
for file in ("Configuration.h", "Configuration_adv.h"):
@@ -37,10 +46,11 @@ def apply_opt(name, val, conf=None):
newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line)
else:
# For options with values, enable and set the value
newline = match[1] + match[3] + match[4] + match[5] + val
if match[8]:
sp = match[7] if match[7] else ' '
newline += sp + match[8]
addsp = '' if match[5] else ' '
newline = match[1] + match[3] + match[4] + match[5] + addsp + val + match[6]
if match[9]:
sp = match[8] if match[8] else ' '
newline += sp + match[9]
lines[i] = newline
blab(f"Set {name} to {val}")
@@ -85,12 +95,12 @@ def apply_opt(name, val, conf=None):
# Return True if any files were fetched.
def fetch_example(url):
if url.endswith("/"): url = url[:-1]
if url.startswith('http'):
url = url.replace("%", "%25").replace(" ", "%20")
else:
if not url.startswith('http'):
brch = "bugfix-2.1.x"
if '@' in path: path, brch = map(str.strip, path.split('@'))
if '@' in url: url, brch = map(str.strip, url.split('@'))
if url == 'examples/default': url = 'default'
url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}"
url = url.replace("%", "%25").replace(" ", "%20")
# Find a suitable fetch command
if shutil.which("curl") is not None:
@@ -104,7 +114,7 @@ def fetch_example(url):
import os
# Reset configurations to default
os.system("git reset --hard HEAD")
os.system("git checkout HEAD Marlin/*.h")
# Try to fetch the remote files
gotfile = False
@@ -180,10 +190,11 @@ def apply_config_ini(cp):
# For a key ending in .ini load and parse another .ini file
if ckey.endswith('.ini'):
sect = 'base'
if '@' in ckey: sect, ckey = ckey.split('@')
other_ini = configparser.ConfigParser()
other_ini.read(config_path(ckey))
apply_sections(other_ini, sect)
if '@' in ckey: sect, ckey = map(str.strip, ckey.split('@'))
cp2 = configparser.ConfigParser()
cp2.read(config_path(ckey))
apply_sections(cp2, sect)
ckey = 'base';
# (Allow 'example/' as a shortcut for 'examples/')
elif ckey.startswith('example/'):
@@ -191,11 +202,11 @@ def apply_config_ini(cp):
# For 'examples/<path>' fetch an example set from GitHub.
# For https?:// do a direct fetch of the URL.
elif ckey.startswith('examples/') or ckey.startswith('http'):
if ckey.startswith('examples/') or ckey.startswith('http'):
fetch_example(ckey)
ckey = 'base'
elif ckey == 'all':
if ckey == 'all':
apply_sections(cp)
else: