Selaa lähdekoodia

Preflight checks for PlatformIO builds (#21068)

Co-authored-by: Alexander D. Kanevskiy <alexander.kanevskiy@intel.com>
ellensp 3 vuotta sitten
vanhempi
commit
bb1039d4c9
No account linked to committer's email address

+ 3
- 3
Marlin/src/pins/pins.h Näytä tiedosto

@@ -481,9 +481,9 @@
481 481
 #elif MB(MKS_ROBIN_MINI)
482 482
   #include "stm32f1/pins_MKS_ROBIN_MINI.h"      // STM32F1                                env:mks_robin_mini
483 483
 #elif MB(MKS_ROBIN_NANO)
484
-  #include "stm32f1/pins_MKS_ROBIN_NANO.h"      // STM32F1                                env:mks_robin_nano35
484
+  #include "stm32f1/pins_MKS_ROBIN_NANO.h"      // STM32F1                                env:mks_robin_nano35 env:mks_robin_nano35_stm32
485 485
 #elif MB(MKS_ROBIN_NANO_V2)
486
-  #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h"   // STM32F1                                env:mks_robin_nano35
486
+  #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h"   // STM32F1                                env:mks_robin_nano35 env:mks_robin_nano35_stm32
487 487
 #elif MB(MKS_ROBIN_LITE)
488 488
   #include "stm32f1/pins_MKS_ROBIN_LITE.h"      // STM32F1                                env:mks_robin_lite
489 489
 #elif MB(MKS_ROBIN_LITE3)
@@ -513,7 +513,7 @@
513 513
 #elif MB(BTT_SKR_E3_DIP)
514 514
   #include "stm32f1/pins_BTT_SKR_E3_DIP.h"      // STM32F1                                env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
515 515
 #elif MB(BTT_SKR_CR6)
516
-  #include "stm32f1/pins_BTT_SKR_CR6.h"         // STM32F1                                env:STM32F103RC_btt_512K_USB
516
+  #include "stm32f1/pins_BTT_SKR_CR6.h"         // STM32F1                                env:STM32F103RE_btt env:STM32F103RE_btt_USB
517 517
 #elif MB(JGAURORA_A5S_A1)
518 518
   #include "stm32f1/pins_JGAURORA_A5S_A1.h"     // STM32F1                                env:jgaurora_a5s_a1
519 519
 #elif MB(FYSETC_AIO_II)

+ 1
- 0
Marlin/src/pins/ramps/pins_ZRIB_V52.h Näytä tiedosto

@@ -46,6 +46,7 @@
46 46
 #define E2_STEP_PIN                            4
47 47
 #define E2_DIR_PIN                             5
48 48
 #define E2_ENABLE_PIN                         22
49
+#define HEATER_1_PIN                           7
49 50
 
50 51
 #include "pins_MKS_BASE_common.h"
51 52
 

+ 0
- 11
buildroot/share/PlatformIO/scripts/common-dependencies.py Näytä tiedosto

@@ -313,16 +313,6 @@ def MarlinFeatureIsEnabled(env, feature):
313 313
 	return some_on
314 314
 
315 315
 #
316
-# Check for Configfiles in two common incorrect places
317
-#
318
-def check_configfile_locations():
319
-	for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
320
-		for f in [ "Configuration.h", "Configuration_adv.h" ]:
321
-			if os.path.isfile(os.path.join(p, f)):
322
-				err = 'ERROR: Config files found in directory ' + str(p) + '. Please move them into the Marlin subdirectory.'
323
-				raise SystemExit(err)
324
-
325
-#
326 316
 # Add a method for other PIO scripts to query enabled features
327 317
 #
328 318
 env.AddMethod(MarlinFeatureIsEnabled)
@@ -330,6 +320,5 @@ env.AddMethod(MarlinFeatureIsEnabled)
330 320
 #
331 321
 # Add dependencies for enabled Marlin features
332 322
 #
333
-check_configfile_locations()
334 323
 apply_features_config()
335 324
 force_ignore_unused_libs()

+ 62
- 0
buildroot/share/PlatformIO/scripts/preflight-checks.py Näytä tiedosto

@@ -0,0 +1,62 @@
1
+#
2
+# preflight-checks.py
3
+# Script to check for common issues prior to compiling
4
+#
5
+import os
6
+import re
7
+Import("env")
8
+
9
+def get_envs_for_board(board):
10
+    if board.startswith("BOARD_"):
11
+        board = board[6:]
12
+    with open(os.path.join("Marlin", "src", "pins", "pins.h"),"r") as f:
13
+        board_found = ""
14
+        r=re.compile(r"if\s+MB\((.+)\)")
15
+        for line in f.readlines():
16
+            mbs = r.findall(line)
17
+            if mbs:
18
+                board_found = board if board in re.split(r",\s*", mbs[0]) else ""
19
+            if board_found and "#include " in line and "env:" in line:
20
+                return re.findall(r"env:\w+", line)
21
+    return []
22
+
23
+def check_envs(build_env, base_envs, config):
24
+    if build_env in base_envs:
25
+        return True
26
+    ext = config.get(build_env, 'extends', default=None)
27
+    if ext:
28
+        for ext_env in ext:
29
+            if check_envs(ext_env, base_envs, config):
30
+                return True
31
+    return False
32
+
33
+# Sanity checks:
34
+if 'PIOENV' not in env:
35
+    raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
36
+
37
+if 'MARLIN_FEATURES' not in env:
38
+    raise SystemExit("Error: this script should be used after common Marlin scripts")
39
+
40
+if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
41
+    raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
42
+
43
+build_env = env['PIOENV']
44
+motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
45
+base_envs = get_envs_for_board(motherboard)
46
+config = env.GetProjectConfig()
47
+result = check_envs("env:"+build_env, base_envs, config)
48
+
49
+if not result:
50
+    err = "Error: your selected build environment '%s' is not compatible with MOTHERBOARD=%s in Configuration.h. " \
51
+          "Please use one of compatible build environments for this board: %s" % \
52
+          (build_env, motherboard, ",".join([e[4:] for e in base_envs if e.startswith("env:")]))
53
+    raise SystemExit(err)
54
+
55
+#
56
+# Check for Config files in two common incorrect places
57
+#
58
+for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
59
+	for f in [ "Configuration.h", "Configuration_adv.h" ]:
60
+		if os.path.isfile(os.path.join(p, f)):
61
+			err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
62
+			raise SystemExit(err)

+ 2
- 2
buildroot/tests/mega1280-tests Näytä tiedosto

@@ -33,13 +33,13 @@ exec_test $1 $2 "Spindle, MESH_BED_LEVELING, closed loop, Power Monitor, and LCD
33 33
 # Test DUAL_X_CARRIAGE
34 34
 #
35 35
 restore_configs
36
-opt_set MOTHERBOARD BOARD_TT_OSCAR
36
+opt_set MOTHERBOARD BOARD_ZRIB_V52
37 37
 opt_set LCD_LANGUAGE pt
38 38
 opt_set EXTRUDERS 2
39 39
 opt_set TEMP_SENSOR_1 1
40 40
 opt_enable USE_XMAX_PLUG DUAL_X_CARRIAGE REPRAPWORLD_KEYPAD
41 41
 opt_set REPRAPWORLD_KEYPAD_MOVE_STEP 10.0
42
-exec_test $1 $2 "TT Oscar | DUAL_X_CARRIAGE" "$3"
42
+exec_test $1 $2 "ZRIB_V52 | DUAL_X_CARRIAGE" "$3"
43 43
 
44 44
 #
45 45
 # Delta Config (generic) + Probeless

+ 1
- 0
platformio.ini Näytä tiedosto

@@ -212,6 +212,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
212 212
 extra_scripts      =
213 213
   pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
214 214
   pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
215
+  pre:buildroot/share/PlatformIO/scripts/preflight-checks.py
215 216
   post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
216 217
 build_flags        = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants
217 218
 lib_deps           =

Loading…
Peruuta
Tallenna