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

Loading…
Cancel
Save