mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-07-16 11:17:48 -06:00
🔨 Auto-replace BOTH / EITHER in configs (#27249)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
7c1f82cd96
commit
3385b4c280
1 changed files with 26 additions and 5 deletions
|
@ -78,12 +78,15 @@ if pioutil.is_pio_build():
|
||||||
( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
|
( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
|
||||||
raise SystemExit(err)
|
raise SystemExit(err)
|
||||||
|
|
||||||
|
# Useful values
|
||||||
|
project_dir = Path(env['PROJECT_DIR'])
|
||||||
|
config_files = ("Configuration.h", "Configuration_adv.h")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for Config files in two common incorrect places
|
# Check for Config files in two common incorrect places
|
||||||
#
|
#
|
||||||
epath = Path(env['PROJECT_DIR'])
|
for p in (project_dir, project_dir / "config"):
|
||||||
for p in [ epath, epath / "config" ]:
|
for f in config_files:
|
||||||
for f in ("Configuration.h", "Configuration_adv.h"):
|
|
||||||
if (p / f).is_file():
|
if (p / f).is_file():
|
||||||
err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
|
err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
|
||||||
raise SystemExit(err)
|
raise SystemExit(err)
|
||||||
|
@ -114,11 +117,11 @@ if pioutil.is_pio_build():
|
||||||
# Check for old files indicating an entangled Marlin (mixing old and new code)
|
# Check for old files indicating an entangled Marlin (mixing old and new code)
|
||||||
#
|
#
|
||||||
mixedin = []
|
mixedin = []
|
||||||
p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm")
|
p = project_dir / "Marlin/src/lcd/dogm"
|
||||||
for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
|
for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
|
||||||
if (p / f).is_file():
|
if (p / f).is_file():
|
||||||
mixedin += [ f ]
|
mixedin += [ f ]
|
||||||
p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl")
|
p = project_dir / "Marlin/src/feature/bedlevel/abl"
|
||||||
for f in [ "abl.cpp", "abl.h" ]:
|
for f in [ "abl.cpp", "abl.h" ]:
|
||||||
if (p / f).is_file():
|
if (p / f).is_file():
|
||||||
mixedin += [ f ]
|
mixedin += [ f ]
|
||||||
|
@ -137,4 +140,22 @@ if pioutil.is_pio_build():
|
||||||
err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter (e.g., \"M600 T%c\") when NUM_RUNOUT_SENSORS is > 1"
|
err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter (e.g., \"M600 T%c\") when NUM_RUNOUT_SENSORS is > 1"
|
||||||
raise SystemExit(err)
|
raise SystemExit(err)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Update old macros BOTH and EITHER in configuration files
|
||||||
|
#
|
||||||
|
conf_modified = False
|
||||||
|
for f in config_files:
|
||||||
|
conf_path = project_dir / "Marlin" / f
|
||||||
|
if conf_path.is_file():
|
||||||
|
with open(conf_path, 'r') as file:
|
||||||
|
text = file.read()
|
||||||
|
modified_text = text.replace("BOTH(", "ALL(").replace("EITHER(", "ANY(")
|
||||||
|
if text != modified_text:
|
||||||
|
conf_modified = True
|
||||||
|
with open(conf_path, 'w') as file:
|
||||||
|
file.write(modified_text)
|
||||||
|
|
||||||
|
if conf_modified:
|
||||||
|
raise SystemExit('WARNING: Configuration files needed an update to remove incompatible items. Try the build again to use the updated files.')
|
||||||
|
|
||||||
sanity_check_target()
|
sanity_check_target()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue