Skip to content

Commit 2c6fe45

Browse files
committed
🔨 Update 'pio vscode init' detection
1 parent fed72e4 commit 2c6fe45

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

buildroot/share/PlatformIO/scripts/common-dependencies.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
# common-dependencies.py
33
# Convenience script to check dependencies and add libs and sources for Marlin Enabled Features
44
#
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)
611

712
PIO_VERSION_MIN = (5, 0, 3)
813
try:
@@ -31,8 +36,6 @@
3136
from platformio.package.meta import PackageSpec
3237
from platformio.project.config import ProjectConfig
3338

34-
Import("env")
35-
3639
#print(env.Dump())
3740

3841
try:

buildroot/share/PlatformIO/scripts/download_mks_assets.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33
# Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
44
#
55
Import("env")
6-
import os,requests,zipfile,tempfile,shutil
6+
import os,requests,zipfile,tempfile,shutil,pioutil
77

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")
1015
assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets")
1116

1217
def download_mks_assets():
1318
print("Downloading MKS Assets")
1419
r = requests.get(url, stream=True)
1520
# the user may have a very clean workspace,
1621
# 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)
1924
with open(zip_path, 'wb') as fd:
2025
for chunk in r.iter_content(chunk_size=128):
2126
fd.write(chunk)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

buildroot/share/PlatformIO/scripts/preflight-checks.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
# preflight-checks.py
33
# Check for common issues prior to compiling
44
#
5-
import os,re,sys
5+
import os,re,sys,pioutil
66
Import("env")
77

8+
# Detect that 'vscode init' is running
9+
if pioutil.is_vscode_init():
10+
env.Exit(0)
11+
812
def get_envs_for_board(board):
913
with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:
1014

@@ -94,7 +98,4 @@ def sanity_check_target():
9498
err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin)
9599
raise SystemExit(err)
96100

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()

0 commit comments

Comments
 (0)