|
@@ -2,14 +2,8 @@
|
2
|
2
|
# preflight-checks.py
|
3
|
3
|
# Check for common issues prior to compiling
|
4
|
4
|
#
|
5
|
|
-Import("env")
|
6
|
|
-
|
7
|
|
-# Detect that 'vscode init' is running
|
8
|
|
-from SCons.Script import COMMAND_LINE_TARGETS
|
9
|
|
-if "idedata" in COMMAND_LINE_TARGETS:
|
10
|
|
- env.Exit(0)
|
11
|
|
-
|
12
|
5
|
import os,re,sys
|
|
6
|
+Import("env")
|
13
|
7
|
|
14
|
8
|
def get_envs_for_board(board):
|
15
|
9
|
with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:
|
|
@@ -50,44 +44,50 @@ def check_envs(build_env, board_envs, config):
|
50
|
44
|
return True
|
51
|
45
|
return False
|
52
|
46
|
|
53
|
|
-# Sanity checks:
|
54
|
|
-if 'PIOENV' not in env:
|
55
|
|
- raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
|
|
47
|
+def sanity_check_target():
|
|
48
|
+ # Sanity checks:
|
|
49
|
+ if 'PIOENV' not in env:
|
|
50
|
+ raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
|
56
|
51
|
|
57
|
|
-if 'MARLIN_FEATURES' not in env:
|
58
|
|
- raise SystemExit("Error: this script should be used after common Marlin scripts")
|
|
52
|
+ if 'MARLIN_FEATURES' not in env:
|
|
53
|
+ raise SystemExit("Error: this script should be used after common Marlin scripts")
|
59
|
54
|
|
60
|
|
-if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
|
61
|
|
- raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
|
|
55
|
+ if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
|
|
56
|
+ raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
|
62
|
57
|
|
63
|
|
-build_env = env['PIOENV']
|
64
|
|
-motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
|
65
|
|
-board_envs = get_envs_for_board(motherboard)
|
66
|
|
-config = env.GetProjectConfig()
|
67
|
|
-result = check_envs("env:"+build_env, board_envs, config)
|
|
58
|
+ build_env = env['PIOENV']
|
|
59
|
+ motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
|
|
60
|
+ board_envs = get_envs_for_board(motherboard)
|
|
61
|
+ config = env.GetProjectConfig()
|
|
62
|
+ result = check_envs("env:"+build_env, board_envs, config)
|
68
|
63
|
|
69
|
|
-if not result:
|
70
|
|
- err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
|
71
|
|
- ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
|
72
|
|
- raise SystemExit(err)
|
|
64
|
+ if not result:
|
|
65
|
+ err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
|
|
66
|
+ ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) )
|
|
67
|
+ raise SystemExit(err)
|
73
|
68
|
|
74
|
|
-#
|
75
|
|
-# Check for Config files in two common incorrect places
|
76
|
|
-#
|
77
|
|
-for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
|
78
|
|
- for f in [ "Configuration.h", "Configuration_adv.h" ]:
|
79
|
|
- if os.path.isfile(os.path.join(p, f)):
|
80
|
|
- err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
|
81
|
|
- raise SystemExit(err)
|
|
69
|
+ #
|
|
70
|
+ # Check for Config files in two common incorrect places
|
|
71
|
+ #
|
|
72
|
+ for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
|
|
73
|
+ for f in [ "Configuration.h", "Configuration_adv.h" ]:
|
|
74
|
+ if os.path.isfile(os.path.join(p, f)):
|
|
75
|
+ err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
|
|
76
|
+ raise SystemExit(err)
|
82
|
77
|
|
83
|
|
-#
|
84
|
|
-# Check for old files indicating an entangled Marlin (mixing old and new code)
|
85
|
|
-#
|
86
|
|
-mixedin = []
|
87
|
|
-for p in [ os.path.join(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") ]:
|
88
|
|
- for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
|
89
|
|
- if os.path.isfile(os.path.join(p, f)):
|
90
|
|
- mixedin += [ f ]
|
91
|
|
-if mixedin:
|
92
|
|
- err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
|
93
|
|
- raise SystemExit(err)
|
|
78
|
+ #
|
|
79
|
+ # Check for old files indicating an entangled Marlin (mixing old and new code)
|
|
80
|
+ #
|
|
81
|
+ mixedin = []
|
|
82
|
+ for p in [ os.path.join(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") ]:
|
|
83
|
+ for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]:
|
|
84
|
+ if os.path.isfile(os.path.join(p, f)):
|
|
85
|
+ mixedin += [ f ]
|
|
86
|
+ if mixedin:
|
|
87
|
+ err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
|
|
88
|
+ raise SystemExit(err)
|
|
89
|
+
|
|
90
|
+# Detect that 'vscode init' is running
|
|
91
|
+from SCons.Script import COMMAND_LINE_TARGETS
|
|
92
|
+if "idedata" not in COMMAND_LINE_TARGETS:
|
|
93
|
+ sanity_check_target()
|