Browse Source

Extra dependency script logging

Scott Lahteine 3 years ago
parent
commit
d87a71bd04
1 changed files with 22 additions and 15 deletions
  1. 22
    15
      buildroot/share/PlatformIO/scripts/common-dependencies.py

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

@@ -40,9 +40,9 @@ try:
40 40
 except:
41 41
 	verbose = 0
42 42
 
43
-def blab(str):
44
-	if verbose:
45
-		print(str)
43
+def blab(str,level=1):
44
+	if verbose >= level:
45
+		print("[deps] %s" % str)
46 46
 
47 47
 FEATURE_CONFIG = {}
48 48
 
@@ -65,13 +65,16 @@ def add_to_feat_cnf(feature, flines):
65 65
 		name = parts.pop(0)
66 66
 		if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
67 67
 			feat[name] = '='.join(parts)
68
+			blab("[%s] %s=%s" % (feature, name, feat[name]), 3)
68 69
 		else:
69
-			for dep in line.split(','):
70
+			for dep in re.split(r",\s*", line):
70 71
 				lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0)
71 72
 				lib_re = re.compile('(?!^' + lib_name + '\\b)')
72 73
 				feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
74
+				blab("[%s] lib_deps = %s" % (feature, dep), 3)
73 75
 
74 76
 def load_config():
77
+	blab("========== Gather [features] entries...")
75 78
 	items = ProjectConfig().items('features')
76 79
 	for key in items:
77 80
 		feature = key[0].upper()
@@ -80,16 +83,20 @@ def load_config():
80 83
 		add_to_feat_cnf(feature, key[1])
81 84
 
82 85
 	# Add options matching custom_marlin.MY_OPTION to the pile
86
+	blab("========== Gather custom_marlin entries...")
83 87
 	all_opts = env.GetProjectOptions()
84 88
 	for n in all_opts:
85
-		mat = re.match(r'custom_marlin\.(.+)', n[0])
89
+		key = n[0]
90
+		mat = re.match(r'custom_marlin\.(.+)', key)
86 91
 		if mat:
87 92
 			try:
88
-				val = env.GetProjectOption(n[0])
93
+				val = env.GetProjectOption(key)
89 94
 			except:
90 95
 				val = None
91 96
 			if val:
92
-				add_to_feat_cnf(mat.group(1).upper(), val)
97
+				opt = mat.group(1).upper()
98
+				blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val ))
99
+				add_to_feat_cnf(opt, val)
93 100
 
94 101
 def get_all_known_libs():
95 102
 	known_libs = []
@@ -124,6 +131,7 @@ def force_ignore_unused_libs():
124 131
 
125 132
 def apply_features_config():
126 133
 	load_config()
134
+	blab("========== Apply enabled features...")
127 135
 	for feature in FEATURE_CONFIG:
128 136
 		if not env.MarlinFeatureIsEnabled(feature):
129 137
 			continue
@@ -131,12 +139,13 @@ def apply_features_config():
131 139
 		feat = FEATURE_CONFIG[feature]
132 140
 
133 141
 		if 'lib_deps' in feat and len(feat['lib_deps']):
134
-			blab("Adding lib_deps for %s... " % feature)
142
+			blab("========== Adding lib_deps for %s... " % feature, 2)
135 143
 
136 144
 			# feat to add
137 145
 			deps_to_add = {}
138 146
 			for dep in feat['lib_deps']:
139 147
 				deps_to_add[PackageSpec(dep).name] = dep
148
+				blab("==================== %s... " % dep, 2)
140 149
 
141 150
 			# Does the env already have the dependency?
142 151
 			deps = env.GetProjectOption('lib_deps')
@@ -159,16 +168,16 @@ def apply_features_config():
159 168
 
160 169
 		if 'build_flags' in feat:
161 170
 			f = feat['build_flags']
162
-			blab("Adding build_flags for %s: %s" % (feature, f))
171
+			blab("========== Adding build_flags for %s: %s" % (feature, f), 2)
163 172
 			new_flags = env.GetProjectOption('build_flags') + [ f ]
164 173
 			env.Replace(BUILD_FLAGS=new_flags)
165 174
 
166 175
 		if 'extra_scripts' in feat:
167
-			blab("Running extra_scripts for %s... " % feature)
176
+			blab("Running extra_scripts for %s... " % feature, 2)
168 177
 			env.SConscript(feat['extra_scripts'], exports="env")
169 178
 
170 179
 		if 'src_filter' in feat:
171
-			blab("Adding src_filter for %s... " % feature)
180
+			blab("========== Adding src_filter for %s... " % feature, 2)
172 181
 			src_filter = ' '.join(env.GetProjectOption('src_filter'))
173 182
 			# first we need to remove the references to the same folder
174 183
 			my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter'])
@@ -182,7 +191,7 @@ def apply_features_config():
182 191
 			env.Replace(SRC_FILTER=src_filter)
183 192
 
184 193
 		if 'lib_ignore' in feat:
185
-			blab("Adding lib_ignore for %s... " % feature)
194
+			blab("========== Adding lib_ignore for %s... " % feature, 2)
186 195
 			lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
187 196
 			set_env_field('lib_ignore', lib_ignore)
188 197
 
@@ -200,7 +209,6 @@ def search_compiler():
200 209
 		pass
201 210
 
202 211
 	if os.path.exists(GCC_PATH_CACHE):
203
-		blab("Getting g++ path from cache")
204 212
 		with open(GCC_PATH_CACHE, 'r') as f:
205 213
 			return f.read()
206 214
 
@@ -227,7 +235,6 @@ def search_compiler():
227 235
 			filepath = os.path.sep.join([pathdir, filepath])
228 236
 			# Cache the g++ path to no search always
229 237
 			if os.path.exists(ENV_BUILD_PATH):
230
-				blab("Caching g++ for current env")
231 238
 				with open(GCC_PATH_CACHE, 'w+') as f:
232 239
 					f.write(filepath)
233 240
 
@@ -262,7 +269,7 @@ def load_marlin_features():
262 269
 
263 270
 	cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h']
264 271
 	cmd = ' '.join(cmd)
265
-	blab(cmd)
272
+	blab(cmd, 4)
266 273
 	define_list = subprocess.check_output(cmd, shell=True).splitlines()
267 274
 	marlin_features = {}
268 275
 	for define in define_list:

Loading…
Cancel
Save