From c91451d215506b3c3977b9ae4b146c98b48acdeb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 19 Oct 2021 02:49:35 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Update=20'pio=20vscode=20init'?= =?UTF-8?q?=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformIO/scripts/common-dependencies.py | 9 ++++++--- .../PlatformIO/scripts/download_mks_assets.py | 15 ++++++++++----- buildroot/share/PlatformIO/scripts/pioutil.py | 8 ++++++++ .../share/PlatformIO/scripts/preflight-checks.py | 11 ++++++----- 4 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 buildroot/share/PlatformIO/scripts/pioutil.py diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 83dfeca879..f523b12069 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -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: @@ -31,8 +36,6 @@ except: from platformio.package.meta import PackageSpec from platformio.project.config import ProjectConfig -Import("env") - #print(env.Dump()) try: diff --git a/buildroot/share/PlatformIO/scripts/download_mks_assets.py b/buildroot/share/PlatformIO/scripts/download_mks_assets.py index e922fed2be..251a74a4cc 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -3,10 +3,15 @@ # 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(): @@ -14,8 +19,8 @@ def download_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) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py new file mode 100644 index 0000000000..f0c021fca7 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -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 diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index b949df97c8..0dab3e4b1f 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -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: @@ -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()