Browse Source

🛠 Replace lib_deps for custom_marlin.FEATURE (#20858)

Scott Lahteine 3 years ago
parent
commit
a54154e760
No account linked to committer's email address
2 changed files with 16 additions and 9 deletions
  1. 15
    8
      buildroot/share/PlatformIO/scripts/common-dependencies.py
  2. 1
    1
      platformio.ini

+ 15
- 8
buildroot/share/PlatformIO/scripts/common-dependencies.py View File

@@ -69,16 +69,23 @@ def add_to_feat_cnf(feature, flines):
69 69
 	except:
70 70
 		FEATURE_CONFIG[feature] = {}
71 71
 
72
+	# Get a reference to the FEATURE_CONFIG under construction
72 73
 	feat = FEATURE_CONFIG[feature]
73
-	atoms = re.sub(',\\s*', '\n', flines).strip().split('\n')
74
-	for dep in atoms:
75
-		parts = dep.split('=')
74
+
75
+	# Split up passed lines on commas or newlines and iterate
76
+	# Add common options to the features config under construction
77
+	# For lib_deps replace a previous instance of the same library
78
+	atoms = re.sub(r',\\s*', '\n', flines).strip().split('\n')
79
+	for line in atoms:
80
+		parts = line.split('=')
76 81
 		name = parts.pop(0)
77
-		rest = '='.join(parts)
78 82
 		if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
79
-			feat[name] = rest
83
+			feat[name] = '='.join(parts)
80 84
 		else:
81
-			feat['lib_deps'] += [dep]
85
+			for dep in line.split(','):
86
+				lib_name = re.sub(r'([@~^=]|[<>]=?)[\d.]+', '', dep.strip()).split('=').pop(0)
87
+				lib_re = re.compile('(?!^' + lib_name + '\\b)')
88
+				feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
82 89
 
83 90
 def load_config():
84 91
 	config = configparser.ConfigParser()
@@ -185,8 +192,8 @@ def apply_features_config():
185 192
 			blab("Adding src_filter for %s... " % feature)
186 193
 			src_filter = ' '.join(env.GetProjectOption('src_filter'))
187 194
 			# first we need to remove the references to the same folder
188
-			my_srcs = re.findall( r'[+-](<.*?>)', feat['src_filter'])
189
-			cur_srcs = re.findall( r'[+-](<.*?>)', src_filter)
195
+			my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter'])
196
+			cur_srcs = re.findall(r'[+-](<.*?>)', src_filter)
190 197
 			for d in my_srcs:
191 198
 				if d in cur_srcs:
192 199
 					src_filter = re.sub(r'[+-]' + d, '', src_filter)

+ 1
- 1
platformio.ini View File

@@ -404,7 +404,7 @@ BEZIER_CURVE_SUPPORT    = src_filter=+<src/module/planner_bezier.cpp> +<src/gcod
404 404
 PRINTCOUNTER            = src_filter=+<src/module/printcounter.cpp>
405 405
 HAS_BED_PROBE           = src_filter=+<src/module/probe.cpp> +<src/gcode/probe/G30.cpp> +<src/gcode/probe/M401_M402.cpp> +<src/gcode/probe/M851.cpp>
406 406
 IS_SCARA                = src_filter=+<src/module/scara.cpp>
407
-HAS_SERVOS              = src_filter=+<src/module/servo.cpp> +<src/gcode/control/M280.cpp> 
407
+HAS_SERVOS              = src_filter=+<src/module/servo.cpp> +<src/gcode/control/M280.cpp>
408 408
 MORGAN_SCARA            = src_filter=+<src/gcode/scara>
409 409
 HAS_MICROSTEPS          = src_filter=+<src/gcode/control/M350_M351.cpp>
410 410
 (ESP3D_)?WIFISUPPORT    = AsyncTCP, ESP Async WebServer

Loading…
Cancel
Save