Skip to content

Commit c852e9c

Browse files
authored
🔨 Fix preflight checks order (#27285)
Followup to #27249
1 parent 2b8db0c commit c852e9c

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

buildroot/share/PlatformIO/scripts/preflight-checks.py

+22-21
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ def sanity_check_target():
6262
if 'MARLIN_FEATURES' not in env:
6363
raise SystemExit("Error: this script should be used after common Marlin scripts.")
6464

65+
# Useful values
66+
project_dir = Path(env['PROJECT_DIR'])
67+
config_files = ("Configuration.h", "Configuration_adv.h")
68+
69+
#
70+
# Update old macros BOTH and EITHER in configuration files
71+
#
72+
conf_modified = False
73+
for f in config_files:
74+
conf_path = project_dir / "Marlin" / f
75+
if conf_path.is_file():
76+
with open(conf_path, 'r', encoding="utf8") as file:
77+
text = file.read()
78+
modified_text = text.replace("BOTH(", "ALL(").replace("EITHER(", "ANY(")
79+
if text != modified_text:
80+
conf_modified = True
81+
with open(conf_path, 'w') as file:
82+
file.write(modified_text)
83+
84+
if conf_modified:
85+
raise SystemExit('WARNING: Configuration files needed an update to remove incompatible items. Try the build again to use the updated files.')
86+
6587
if len(env['MARLIN_FEATURES']) == 0:
6688
raise SystemExit("Error: Failed to parse Marlin features. See previous error messages.")
6789

@@ -78,10 +100,6 @@ def sanity_check_target():
78100
( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
79101
raise SystemExit(err)
80102

81-
# Useful values
82-
project_dir = Path(env['PROJECT_DIR'])
83-
config_files = ("Configuration.h", "Configuration_adv.h")
84-
85103
#
86104
# Check for Config files in two common incorrect places
87105
#
@@ -140,22 +158,5 @@ def rm_ofile(subdir, name):
140158
err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter (e.g., \"M600 T%c\") when NUM_RUNOUT_SENSORS is > 1"
141159
raise SystemExit(err)
142160

143-
#
144-
# Update old macros BOTH and EITHER in configuration files
145-
#
146-
conf_modified = False
147-
for f in config_files:
148-
conf_path = project_dir / "Marlin" / f
149-
if conf_path.is_file():
150-
with open(conf_path, 'r', encoding="utf8") as file:
151-
text = file.read()
152-
modified_text = text.replace("BOTH(", "ALL(").replace("EITHER(", "ANY(")
153-
if text != modified_text:
154-
conf_modified = True
155-
with open(conf_path, 'w') as file:
156-
file.write(modified_text)
157-
158-
if conf_modified:
159-
raise SystemExit('WARNING: Configuration files needed an update to remove incompatible items. Try the build again to use the updated files.')
160161

161162
sanity_check_target()

0 commit comments

Comments
 (0)