Browse Source

🔨 Minor build script changes

Scott Lahteine 1 year ago
parent
commit
edeea5a6fb

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

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

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

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

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

@@ -40,7 +40,10 @@ def run_preprocessor(env, fn=None):
40 40
 	depcmd = cmd + [ filename ]
41 41
 	cmd = ' '.join(depcmd)
42 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 47
 	preprocessor_cache[filename] = define_list
45 48
 	return define_list
46 49
 

+ 2
- 2
docs/ConfigEmbedding.md View File

@@ -1,9 +1,9 @@
1 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 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 8
 ## Extracting configurations from a Marlin binary
9 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