Skip to content

Commit

Permalink
🔨 Fix preflight checks order (MarlinFirmware#27285)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellensp authored Jul 17, 2024
1 parent 2b8db0c commit c852e9c
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions buildroot/share/PlatformIO/scripts/preflight-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ def sanity_check_target():
if 'MARLIN_FEATURES' not in env:
raise SystemExit("Error: this script should be used after common Marlin scripts.")

# Useful values
project_dir = Path(env['PROJECT_DIR'])
config_files = ("Configuration.h", "Configuration_adv.h")

#
# 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', encoding="utf8") 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.')

if len(env['MARLIN_FEATURES']) == 0:
raise SystemExit("Error: Failed to parse Marlin features. See previous error messages.")

Expand All @@ -78,10 +100,6 @@ def sanity_check_target():
( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
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
#
Expand Down Expand Up @@ -140,22 +158,5 @@ def rm_ofile(subdir, name):
err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter (e.g., \"M600 T%c\") when NUM_RUNOUT_SENSORS is > 1"
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', encoding="utf8") 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()

0 comments on commit c852e9c

Please sign in to comment.