Browse Source

🔨 Minor build script changes

Scott Lahteine 2 years ago
parent
commit
edeea5a6fb

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

70
 					feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
70
 					feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep]
71
 					blab("[%s] lib_deps = %s" % (feature, dep), 3)
71
 					blab("[%s] lib_deps = %s" % (feature, dep), 3)
72
 
72
 
73
-	def load_config():
73
+	def load_features():
74
 		blab("========== Gather [features] entries...")
74
 		blab("========== Gather [features] entries...")
75
-		items = ProjectConfig().items('features')
76
-		for key in items:
75
+		for key in ProjectConfig().items('features'):
77
 			feature = key[0].upper()
76
 			feature = key[0].upper()
78
 			if not feature in FEATURE_CONFIG:
77
 			if not feature in FEATURE_CONFIG:
79
 				FEATURE_CONFIG[feature] = { 'lib_deps': [] }
78
 				FEATURE_CONFIG[feature] = { 'lib_deps': [] }
81
 
80
 
82
 		# Add options matching custom_marlin.MY_OPTION to the pile
81
 		# Add options matching custom_marlin.MY_OPTION to the pile
83
 		blab("========== Gather custom_marlin entries...")
82
 		blab("========== Gather custom_marlin entries...")
84
-		all_opts = env.GetProjectOptions()
85
-		for n in all_opts:
83
+		for n in env.GetProjectOptions():
86
 			key = n[0]
84
 			key = n[0]
87
 			mat = re.match(r'custom_marlin\.(.+)', key)
85
 			mat = re.match(r'custom_marlin\.(.+)', key)
88
 			if mat:
86
 			if mat:
127
 		set_env_field('lib_ignore', lib_ignore)
125
 		set_env_field('lib_ignore', lib_ignore)
128
 
126
 
129
 	def apply_features_config():
127
 	def apply_features_config():
130
-		load_config()
128
+		load_features()
131
 		blab("========== Apply enabled features...")
129
 		blab("========== Apply enabled features...")
132
 		for feature in FEATURE_CONFIG:
130
 		for feature in FEATURE_CONFIG:
133
-			if not env.MarlinFeatureIsEnabled(feature):
131
+			if not env.MarlinHas(feature):
134
 				continue
132
 				continue
135
 
133
 
136
 			feat = FEATURE_CONFIG[feature]
134
 			feat = FEATURE_CONFIG[feature]
212
 	#
210
 	#
213
 	# Return True if a matching feature is enabled
211
 	# Return True if a matching feature is enabled
214
 	#
212
 	#
215
-	def MarlinFeatureIsEnabled(env, feature):
213
+	def MarlinHas(env, feature):
216
 		load_marlin_features()
214
 		load_marlin_features()
217
 		r = re.compile('^' + feature + '$')
215
 		r = re.compile('^' + feature + '$')
218
 		found = list(filter(r.match, env['MARLIN_FEATURES']))
216
 		found = list(filter(r.match, env['MARLIN_FEATURES']))
225
 				if val in [ '', '1', 'true' ]:
223
 				if val in [ '', '1', 'true' ]:
226
 					some_on = True
224
 					some_on = True
227
 				elif val in env['MARLIN_FEATURES']:
225
 				elif val in env['MARLIN_FEATURES']:
228
-					some_on = env.MarlinFeatureIsEnabled(val)
226
+					some_on = env.MarlinHas(val)
229
 
227
 
230
 		return some_on
228
 		return some_on
231
 
229
 
239
 	#
237
 	#
240
 	# Add a method for other PIO scripts to query enabled features
238
 	# Add a method for other PIO scripts to query enabled features
241
 	#
239
 	#
242
-	env.AddMethod(MarlinFeatureIsEnabled)
240
+	env.AddMethod(MarlinHas)
243
 
241
 
244
 	#
242
 	#
245
 	# Add dependencies for enabled Marlin features
243
 	# Add dependencies for enabled Marlin features

+ 1
- 1
buildroot/share/PlatformIO/scripts/fix_framework_weakness.py View File

10
 
10
 
11
 	Import("env")
11
 	Import("env")
12
 
12
 
13
-	if env.MarlinFeatureIsEnabled("POSTMORTEM_DEBUGGING"):
13
+	if env.MarlinHas("POSTMORTEM_DEBUGGING"):
14
 		FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
14
 		FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple")
15
 		patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")
15
 		patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done")
16
 
16
 

+ 4
- 1
buildroot/share/PlatformIO/scripts/preprocessor.py View File

40
 	depcmd = cmd + [ filename ]
40
 	depcmd = cmd + [ filename ]
41
 	cmd = ' '.join(depcmd)
41
 	cmd = ' '.join(depcmd)
42
 	blab(cmd)
42
 	blab(cmd)
43
-	define_list = subprocess.check_output(cmd, shell=True).splitlines()
43
+	try:
44
+		define_list = subprocess.check_output(cmd, shell=True).splitlines()
45
+	except:
46
+		define_list = {}
44
 	preprocessor_cache[filename] = define_list
47
 	preprocessor_cache[filename] = define_list
45
 	return define_list
48
 	return define_list
46
 
49
 

+ 2
- 2
docs/ConfigEmbedding.md View File

1
 # Configuration Embedding
1
 # Configuration Embedding
2
 
2
 
3
-Starting with version 2.0.9.3, Marlin automatically extracts the configuration used to generate the firmware and stores it in the firmware binary. This is enabled by defining `CONFIGURATION_EMBEDDING` in `Configuration_adv.h`.
3
+Starting with version 2.0.9.3, Marlin can automatically extract the configuration used to generate the firmware and store it in the firmware binary. This is enabled by defining `CONFIGURATION_EMBEDDING` in `Configuration_adv.h`.
4
 
4
 
5
 ## How it's done
5
 ## How it's done
6
-To create the embedded configuration, we do a compiler pass to process the Configuration files and extract all active options. The active options are parsed into key/value pairs, serialized to JSON format, and stored in a file called `marlin_config.json`, which also includes specific build information (like the git revision, the build date, and some version information. The JSON file is then compressed in a ZIP archive called `.pio/build/mc.zip` which is converted into a C array and stored in a C++ file called `mc.h` which is included in the build.
6
+At the start of the PlatformIO build process, we create an embedded configuration by extracting all active options from the Configuration files and writing them out as JSON to `marlin_config.json`, which also includes specific build information (like the git revision, the build date, and some version information. The JSON file is then compressed in a ZIP archive called `.pio/build/mc.zip` which is converted into a C array and stored in a C++ file called `mc.h` which is included in the build.
7
 
7
 
8
 ## Extracting configurations from a Marlin binary
8
 ## Extracting configurations from a Marlin binary
9
 To get the configuration out of a binary firmware, you'll need a non-write-protected SD card inserted into the printer while running the firmware.
9
 To get the configuration out of a binary firmware, you'll need a non-write-protected SD card inserted into the printer while running the firmware.

Loading…
Cancel
Save