@@ -78,12 +78,15 @@ def sanity_check_target():
78
78
( build_env , motherboard , ", " .join ([ e [4 :] for e in board_envs if e .startswith ("env:" ) ]) )
79
79
raise SystemExit (err )
80
80
81
+ # Useful values
82
+ project_dir = Path (env ['PROJECT_DIR' ])
83
+ config_files = ("Configuration.h" , "Configuration_adv.h" )
84
+
81
85
#
82
86
# Check for Config files in two common incorrect places
83
87
#
84
- epath = Path (env ['PROJECT_DIR' ])
85
- for p in [ epath , epath / "config" ]:
86
- for f in ("Configuration.h" , "Configuration_adv.h" ):
88
+ for p in (project_dir , project_dir / "config" ):
89
+ for f in config_files :
87
90
if (p / f ).is_file ():
88
91
err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
89
92
raise SystemExit (err )
@@ -114,11 +117,11 @@ def rm_ofile(subdir, name):
114
117
# Check for old files indicating an entangled Marlin (mixing old and new code)
115
118
#
116
119
mixedin = []
117
- p = Path ( env [ 'PROJECT_DIR' ], "Marlin/src/lcd/dogm" )
120
+ p = project_dir / "Marlin/src/lcd/dogm"
118
121
for f in [ "ultralcd_DOGM.cpp" , "ultralcd_DOGM.h" ]:
119
122
if (p / f ).is_file ():
120
123
mixedin += [ f ]
121
- p = Path ( env [ 'PROJECT_DIR' ], "Marlin/src/feature/bedlevel/abl" )
124
+ p = project_dir / "Marlin/src/feature/bedlevel/abl"
122
125
for f in [ "abl.cpp" , "abl.h" ]:
123
126
if (p / f ).is_file ():
124
127
mixedin += [ f ]
@@ -137,4 +140,22 @@ def rm_ofile(subdir, name):
137
140
err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter (e.g., \" M600 T%c\" ) when NUM_RUNOUT_SENSORS is > 1"
138
141
raise SystemExit (err )
139
142
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' ) 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.' )
160
+
140
161
sanity_check_target ()
0 commit comments