Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

27249 Followup, re order preflight-checks.py #27285

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading