Quellcode durchsuchen

Ignore unused (but downloaded) libraries (#18728)

Victor Oliveira vor 3 Jahren
Ursprung
Commit
9ca070fa10
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 31 neuen und 0 gelöschten Zeilen
  1. 31
    0
      buildroot/share/PlatformIO/scripts/common-features-dependencies.py

+ 31
- 0
buildroot/share/PlatformIO/scripts/common-features-dependencies.py Datei anzeigen

@@ -36,6 +36,36 @@ def load_config():
36 36
 			else:
37 37
 				FEATURE_DEPENDENCIES[key[0].upper()]['lib_deps'] += [dep]
38 38
 
39
+def get_all_known_libs():
40
+	known_libs = []
41
+	for feature in FEATURE_DEPENDENCIES:
42
+		if not 'lib_deps' in FEATURE_DEPENDENCIES[feature]:
43
+			continue
44
+		for dep in FEATURE_DEPENDENCIES[feature]['lib_deps']:
45
+			name, _, _ = PackageManager.parse_pkg_uri(dep)
46
+			known_libs.append(name)
47
+	return known_libs
48
+
49
+def get_all_env_libs():
50
+	env_libs = []
51
+	lib_deps = env.GetProjectOption("lib_deps")
52
+	for dep in lib_deps:
53
+		name, _, _ = PackageManager.parse_pkg_uri(dep)
54
+		env_libs.append(name)
55
+	return env_libs
56
+
57
+# We need to ignore all non-used libs,
58
+# so if a lib folder lay forgotten in .pio/lib_deps, it
59
+# will not break compiling
60
+def force_ignore_unused_libs():
61
+	env_libs = get_all_env_libs()
62
+	known_libs = get_all_known_libs()
63
+	diff = (list(set(known_libs) - set(env_libs)))
64
+	lib_ignore = env.GetProjectOption("lib_ignore") + diff
65
+	print("Ignoring libs: ", lib_ignore)
66
+	proj = env.GetProjectConfig()
67
+	proj.set("env:" + env["PIOENV"], "lib_ignore", lib_ignore)
68
+
39 69
 def install_features_dependencies():
40 70
 	load_config()
41 71
 	for feature in FEATURE_DEPENDENCIES:
@@ -158,3 +188,4 @@ env.AddMethod(MarlinFeatureIsEnabled)
158 188
 
159 189
 # install all dependencies for features enabled in Configuration.h
160 190
 install_features_dependencies()
191
+force_ignore_unused_libs()

Laden…
Abbrechen
Speichern