Browse Source

🔨 Update 'pio vscode init' detection

Scott Lahteine 3 years ago
parent
commit
c91451d215

+ 6
- 3
buildroot/share/PlatformIO/scripts/common-dependencies.py View File

@@ -2,7 +2,12 @@
2 2
 # common-dependencies.py
3 3
 # Convenience script to check dependencies and add libs and sources for Marlin Enabled Features
4 4
 #
5
-import subprocess,os,re
5
+import subprocess,os,re,pioutil
6
+Import("env")
7
+
8
+# Detect that 'vscode init' is running
9
+if pioutil.is_vscode_init():
10
+	env.Exit(0)
6 11
 
7 12
 PIO_VERSION_MIN = (5, 0, 3)
8 13
 try:
@@ -31,8 +36,6 @@ except:
31 36
 from platformio.package.meta import PackageSpec
32 37
 from platformio.project.config import ProjectConfig
33 38
 
34
-Import("env")
35
-
36 39
 #print(env.Dump())
37 40
 
38 41
 try:

+ 10
- 5
buildroot/share/PlatformIO/scripts/download_mks_assets.py View File

@@ -3,10 +3,15 @@
3 3
 # Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
4 4
 #
5 5
 Import("env")
6
-import os,requests,zipfile,tempfile,shutil
6
+import os,requests,zipfile,tempfile,shutil,pioutil
7 7
 
8
-url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/master.zip"
9
-zip_path = os.path.join(env.Dictionary("PROJECT_LIBDEPS_DIR"), "mks-assets.zip")
8
+# Detect that 'vscode init' is running
9
+if pioutil.is_vscode_init():
10
+	env.Exit(0)
11
+
12
+url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
13
+deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR")
14
+zip_path = os.path.join(deps_path, "mks-assets.zip")
10 15
 assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets")
11 16
 
12 17
 def download_mks_assets():
@@ -14,8 +19,8 @@ def download_mks_assets():
14 19
 	r = requests.get(url, stream=True)
15 20
 	# the user may have a very clean workspace,
16 21
 	# so create the PROJECT_LIBDEPS_DIR directory if not exits
17
-	if os.path.exists(env.Dictionary("PROJECT_LIBDEPS_DIR")) == False:
18
-		os.mkdir(env.Dictionary("PROJECT_LIBDEPS_DIR"))
22
+	if os.path.exists(deps_path) == False:
23
+		os.mkdir(deps_path)
19 24
 	with open(zip_path, 'wb') as fd:
20 25
 		for chunk in r.iter_content(chunk_size=128):
21 26
 			fd.write(chunk)

+ 8
- 0
buildroot/share/PlatformIO/scripts/pioutil.py View File

@@ -0,0 +1,8 @@
1
+#
2
+# buildroot/share/PlatformIO/scripts/pioutil.py
3
+#
4
+
5
+# Detect that 'vscode init' is running
6
+def is_vscode_init():
7
+	from SCons.Script import COMMAND_LINE_TARGETS
8
+	return "idedata" in COMMAND_LINE_TARGETS or "_idedata" in COMMAND_LINE_TARGETS

+ 6
- 5
buildroot/share/PlatformIO/scripts/preflight-checks.py View File

@@ -2,9 +2,13 @@
2 2
 # preflight-checks.py
3 3
 # Check for common issues prior to compiling
4 4
 #
5
-import os,re,sys
5
+import os,re,sys,pioutil
6 6
 Import("env")
7 7
 
8
+# Detect that 'vscode init' is running
9
+if pioutil.is_vscode_init():
10
+	env.Exit(0)
11
+
8 12
 def get_envs_for_board(board):
9 13
 	with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:
10 14
 
@@ -94,7 +98,4 @@ def sanity_check_target():
94 98
 		err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
95 99
 		raise SystemExit(err)
96 100
 
97
-# Detect that 'vscode init' is running
98
-from SCons.Script import COMMAND_LINE_TARGETS
99
-if "idedata" not in COMMAND_LINE_TARGETS:
100
-	sanity_check_target()
101
+sanity_check_target()

Loading…
Cancel
Save