Skip to content

Commit

Permalink
🔨 Update 'pio vscode init' detection
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 19, 2021
1 parent 3a77894 commit c91451d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
9 changes: 6 additions & 3 deletions buildroot/share/PlatformIO/scripts/common-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
# common-dependencies.py
# Convenience script to check dependencies and add libs and sources for Marlin Enabled Features
#
import subprocess,os,re
import subprocess,os,re,pioutil
Import("env")

# Detect that 'vscode init' is running
if pioutil.is_vscode_init():
env.Exit(0)

PIO_VERSION_MIN = (5, 0, 3)
try:
Expand Down Expand Up @@ -31,8 +36,6 @@
from platformio.package.meta import PackageSpec
from platformio.project.config import ProjectConfig

Import("env")

#print(env.Dump())

try:
Expand Down
15 changes: 10 additions & 5 deletions buildroot/share/PlatformIO/scripts/download_mks_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
# Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
#
Import("env")
import os,requests,zipfile,tempfile,shutil
import os,requests,zipfile,tempfile,shutil,pioutil

url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/master.zip"
zip_path = os.path.join(env.Dictionary("PROJECT_LIBDEPS_DIR"), "mks-assets.zip")
# Detect that 'vscode init' is running
if pioutil.is_vscode_init():
env.Exit(0)

url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR")
zip_path = os.path.join(deps_path, "mks-assets.zip")
assets_path = os.path.join(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets")

def download_mks_assets():
print("Downloading MKS Assets")
r = requests.get(url, stream=True)
# the user may have a very clean workspace,
# so create the PROJECT_LIBDEPS_DIR directory if not exits
if os.path.exists(env.Dictionary("PROJECT_LIBDEPS_DIR")) == False:
os.mkdir(env.Dictionary("PROJECT_LIBDEPS_DIR"))
if os.path.exists(deps_path) == False:
os.mkdir(deps_path)
with open(zip_path, 'wb') as fd:
for chunk in r.iter_content(chunk_size=128):
fd.write(chunk)
Expand Down
8 changes: 8 additions & 0 deletions buildroot/share/PlatformIO/scripts/pioutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# buildroot/share/PlatformIO/scripts/pioutil.py
#

# Detect that 'vscode init' is running
def is_vscode_init():
from SCons.Script import COMMAND_LINE_TARGETS
return "idedata" in COMMAND_LINE_TARGETS or "_idedata" in COMMAND_LINE_TARGETS
11 changes: 6 additions & 5 deletions buildroot/share/PlatformIO/scripts/preflight-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
# preflight-checks.py
# Check for common issues prior to compiling
#
import os,re,sys
import os,re,sys,pioutil
Import("env")

# Detect that 'vscode init' is running
if pioutil.is_vscode_init():
env.Exit(0)

def get_envs_for_board(board):
with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:

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

# Detect that 'vscode init' is running
from SCons.Script import COMMAND_LINE_TARGETS
if "idedata" not in COMMAND_LINE_TARGETS:
sanity_check_target()
sanity_check_target()

0 comments on commit c91451d

Please sign in to comment.