🔨 Fix IntelliSense / PIO conflicts (#23058)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
Robby Candra 2021-11-04 17:28:42 +07:00 committed by Scott Lahteine
parent f97635de36
commit fc2020c6ec
37 changed files with 1075 additions and 1041 deletions

View File

@ -4,7 +4,8 @@
# Windows: bossac.exe # Windows: bossac.exe
# Other: leave unchanged # Other: leave unchanged
# #
import pioutil
if pioutil.is_pio_build():
import platform import platform
current_OS = platform.system() current_OS = platform.system()

View File

@ -1,10 +1,14 @@
# #
# sets output_port # upload_extra_script.py
# set the output_port
# if target_filename is found then that drive is used # if target_filename is found then that drive is used
# else if target_drive is found then that drive is used # else if target_drive is found then that drive is used
# #
from __future__ import print_function from __future__ import print_function
import pioutil
if pioutil.is_pio_build():
target_filename = "FIRMWARE.CUR" target_filename = "FIRMWARE.CUR"
target_drive = "REARM" target_drive = "REARM"

View File

@ -30,6 +30,8 @@ if __name__ == "__main__":
# extra script for linker options # extra script for linker options
else: else:
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment from SCons.Script import DefaultEnvironment
env = DefaultEnvironment() env = DefaultEnvironment()
env.Append( env.Append(

View File

@ -2,6 +2,8 @@
# SAMD51_grandcentral_m4.py # SAMD51_grandcentral_m4.py
# Customizations for env:SAMD51_grandcentral_m4 # Customizations for env:SAMD51_grandcentral_m4
# #
import pioutil
if pioutil.is_pio_build():
from os.path import join, isfile from os.path import join, isfile
import shutil import shutil
from pprint import pprint from pprint import pprint

View File

@ -1,6 +1,9 @@
# #
# buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py # STM32F103RC_MEEB_3DP.py
# #
import pioutil
if pioutil.is_pio_build():
try: try:
import configparser import configparser
except ImportError: except ImportError:

View File

@ -1,6 +1,9 @@
# #
# buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py # STM32F103RC_fysetc.py
# #
import pioutil
if pioutil.is_pio_build():
import os
from os.path import join from os.path import join
from os.path import expandvars from os.path import expandvars
Import("env") Import("env")

View File

@ -1,6 +1,8 @@
# #
# STM32F1_create_variant.py # STM32F1_create_variant.py
# #
import pioutil
if pioutil.is_pio_build():
import os,shutil,marlin import os,shutil,marlin
from SCons.Script import DefaultEnvironment from SCons.Script import DefaultEnvironment
from platformio import util from platformio import util

View File

@ -2,4 +2,5 @@
# add_nanolib.py # add_nanolib.py
# #
Import("env") Import("env")
env.Append(LINKFLAGS=["--specs=nano.specs"]) env.Append(LINKFLAGS=["--specs=nano.specs"])

View File

@ -1,9 +1,10 @@
# #
# buildroot/share/PlatformIO/scripts/chitu_crypt.py # chitu_crypt.py
# Customizations for Chitu boards # Customizations for Chitu boards
# #
import pioutil
if pioutil.is_pio_build():
import os,random,struct,uuid,marlin import os,random,struct,uuid,marlin
# Relocate firmware from 0x08000000 to 0x08008800 # Relocate firmware from 0x08000000 to 0x08008800
marlin.relocate_firmware("0x08008800") marlin.relocate_firmware("0x08008800")

View File

@ -2,6 +2,8 @@
# common-cxxflags.py # common-cxxflags.py
# Convenience script to apply customizations to CPP flags # Convenience script to apply customizations to CPP flags
# #
import pioutil
if pioutil.is_pio_build():
Import("env") Import("env")
cxxflags = [ cxxflags = [

View File

@ -1,10 +1,10 @@
# #
# common-dependencies-post.py # post:common-dependencies-post.py
# Convenience script to add build flags for Marlin Enabled Features # Convenience script to add build flags for Marlin Enabled Features
# #
import pioutil
Import("env") if pioutil.is_pio_build():
Import("projenv") Import("env", "projenv")
def apply_board_build_flags(): def apply_board_build_flags():
if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']: if not 'BOARD_CUSTOM_BUILD_FLAGS' in env['MARLIN_FEATURES']:

View File

@ -2,13 +2,19 @@
# common-dependencies.py # common-dependencies.py
# Convenience script to check dependencies and add libs and sources for Marlin Enabled Features # Convenience script to check dependencies and add libs and sources for Marlin Enabled Features
# #
import subprocess,os,re,pioutil import pioutil
if pioutil.is_pio_build():
import subprocess,os,re
Import("env") Import("env")
# Detect that 'vscode init' is running from platformio.package.meta import PackageSpec
if pioutil.is_vscode_init(): from platformio.project.config import ProjectConfig
env.Exit(0)
verbose = 0
FEATURE_CONFIG = {}
def validate_pio():
PIO_VERSION_MIN = (5, 0, 3) PIO_VERSION_MIN = (5, 0, 3)
try: try:
from platformio import VERSION as PIO_VERSION from platformio import VERSION as PIO_VERSION
@ -33,22 +39,10 @@ except SystemExit:
except: except:
print("Can't detect PlatformIO Version") print("Can't detect PlatformIO Version")
from platformio.package.meta import PackageSpec
from platformio.project.config import ProjectConfig
#print(env.Dump())
try:
verbose = int(env.GetProjectOption('custom_verbose'))
except:
verbose = 0
def blab(str,level=1): def blab(str,level=1):
if verbose >= level: if verbose >= level:
print("[deps] %s" % str) print("[deps] %s" % str)
FEATURE_CONFIG = {}
def add_to_feat_cnf(feature, flines): def add_to_feat_cnf(feature, flines):
try: try:
@ -309,13 +303,16 @@ def MarlinFeatureIsEnabled(env, feature):
return some_on return some_on
# validate_pio()
try:
verbose = int(env.GetProjectOption('custom_verbose'))
except:
pass
# Add a method for other PIO scripts to query enabled features # Add a method for other PIO scripts to query enabled features
#
env.AddMethod(MarlinFeatureIsEnabled) env.AddMethod(MarlinFeatureIsEnabled)
#
# Add dependencies for enabled Marlin features # Add dependencies for enabled Marlin features
#
apply_features_config() apply_features_config()
force_ignore_unused_libs() force_ignore_unused_libs()

View File

@ -1,9 +1,11 @@
# #
# buildroot/share/PlatformIO/scripts/custom_board.py # custom_board.py
# #
# - For build.address replace VECT_TAB_ADDR to relocate the firmware # - For build.address replace VECT_TAB_ADDR to relocate the firmware
# - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts # - For build.ldscript use one of the linker scripts in buildroot/share/PlatformIO/ldscripts
# #
import pioutil
if pioutil.is_pio_build():
import marlin import marlin
board = marlin.env.BoardConfig() board = marlin.env.BoardConfig()

View File

@ -1,13 +1,11 @@
# #
# buildroot/share/PlatformIO/scripts/download_mks_assets.py # download_mks_assets.py
# Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo # Added by HAS_TFT_LVGL_UI to download assets from Makerbase repo
# #
import pioutil
if pioutil.is_pio_build():
Import("env") Import("env")
import os,requests,zipfile,tempfile,shutil,pioutil import os,requests,zipfile,tempfile,shutil
# 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" url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR") deps_path = env.Dictionary("PROJECT_LIBDEPS_DIR")

View File

@ -1,8 +1,11 @@
# #
# fix_framework_weakness.py # fix_framework_weakness.py
# #
from os.path import join, isfile import pioutil
if pioutil.is_pio_build():
import shutil import shutil
from os.path import join, isfile
from pprint import pprint from pprint import pprint
Import("env") Import("env")

View File

@ -5,6 +5,8 @@
# the appropriate framework variants folder, so that its contents # the appropriate framework variants folder, so that its contents
# will be picked up by PlatformIO just like any other variant. # will be picked up by PlatformIO just like any other variant.
# #
import pioutil
if pioutil.is_pio_build():
import os,shutil,marlin import os,shutil,marlin
from SCons.Script import DefaultEnvironment from SCons.Script import DefaultEnvironment
from platformio import util from platformio import util

View File

@ -1,9 +1,10 @@
# #
# buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py # jgaurora_a5s_a1_with_bootloader.py
# Customizations for env:jgaurora_a5s_a1 # Customizations for env:jgaurora_a5s_a1
# #
import pioutil
if pioutil.is_pio_build():
import os,marlin import os,marlin
# Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin'
def addboot(source, target, env): def addboot(source, target, env):
firmware = open(target[0].path, "rb") firmware = open(target[0].path, "rb")

View File

@ -1,10 +1,12 @@
# #
# buildroot/share/PlatformIO/scripts/lerdge.py # lerdge.py
# Customizations for Lerdge build environments: # Customizations for Lerdge build environments:
# env:LERDGEX env:LERDGEX_usb_flash_drive # env:LERDGEX env:LERDGEX_usb_flash_drive
# env:LERDGES env:LERDGES_usb_flash_drive # env:LERDGES env:LERDGES_usb_flash_drive
# env:LERDGEK env:LERDGEK_usb_flash_drive # env:LERDGEK env:LERDGEK_usb_flash_drive
# #
import pioutil
if pioutil.is_pio_build():
import os,marlin import os,marlin
Import("env") Import("env")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/marlin.py # marlin.py
# Helper module with some commonly-used functions # Helper module with some commonly-used functions
# #
import os,shutil import os,shutil

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin.py # mks_robin.py
# #
import robin import robin
robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin") robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_e3.py # mks_robin_e3.py
# #
import robin import robin
robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_e3p.py # mks_robin_e3p.py
# #
import robin import robin
robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_lite.py # mks_robin_lite.py
# #
import robin import robin
robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin") robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_lite3.py # mks_robin_lite3.py
# #
import robin import robin
robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_mini.py # mks_robin_mini.py
# #
import robin import robin
robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_nano.py # mks_robin_nano.py
# #
import robin import robin
robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_nano35.py # mks_robin_nano35.py
# #
import robin import robin
robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin")

View File

@ -1,5 +1,5 @@
# #
# buildroot/share/PlatformIO/scripts/mks_robin_pro.py # mks_robin_pro.py
# #
import robin import robin
robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin")

View File

@ -8,6 +8,8 @@
# #
# - For 'board_build.rename' add a post-action to rename the firmware file. # - For 'board_build.rename' add a post-action to rename the firmware file.
# #
import pioutil
if pioutil.is_pio_build():
import os,sys,marlin import os,sys,marlin
Import("env") Import("env")

View File

@ -1,6 +1,8 @@
# #
# Convert the ELF to an SREC file suitable for some bootloaders # Convert the ELF to an SREC file suitable for some bootloaders
# #
import pioutil
if pioutil.is_pio_build():
import os,sys import os,sys
from os.path import join from os.path import join

View File

@ -1,8 +1,8 @@
# #
# buildroot/share/PlatformIO/scripts/pioutil.py # pioutil.py
# #
# Detect that 'vscode init' is running # Make sure 'vscode init' is not the current command
def is_vscode_init(): def is_pio_build():
from SCons.Script import COMMAND_LINE_TARGETS from SCons.Script import COMMAND_LINE_TARGETS
return "idedata" in COMMAND_LINE_TARGETS or "_idedata" in COMMAND_LINE_TARGETS return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS

View File

@ -2,12 +2,11 @@
# preflight-checks.py # preflight-checks.py
# Check for common issues prior to compiling # Check for common issues prior to compiling
# #
import os,re,sys,pioutil import pioutil
Import("env") if pioutil.is_pio_build():
# Detect that 'vscode init' is running import os,re,sys
if pioutil.is_vscode_init(): Import("env")
env.Exit(0)
def get_envs_for_board(board): def get_envs_for_board(board):
with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file: with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") as file:

View File

@ -2,8 +2,8 @@
# random-bin.py # random-bin.py
# Set a unique firmware name based on current date and time # Set a unique firmware name based on current date and time
# #
Import("env") import pioutil
if pioutil.is_pio_build():
from datetime import datetime from datetime import datetime
Import("env")
env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S")

View File

@ -1,10 +1,12 @@
# #
# buildroot/share/PlatformIO/scripts/robin.py # robin.py
# #
import marlin
# Apply customizations for a MKS Robin # Apply customizations for a MKS Robin
def prepare(address, ldname, fwname): def prepare(address, ldname, fwname):
import pioutil
if pioutil.is_pio_build():
import marlin
def encrypt(source, target, env): def encrypt(source, target, env):
marlin.encrypt_mks(source, target, env, fwname) marlin.encrypt_mks(source, target, env, fwname)
marlin.relocate_firmware(address) marlin.relocate_firmware(address)

View File

@ -1,7 +1,9 @@
# #
# simulator.py
# PlatformIO pre: script for simulator builds # PlatformIO pre: script for simulator builds
# #
import pioutil
if pioutil.is_pio_build():
# Get the environment thus far for the build # Get the environment thus far for the build
Import("env") Import("env")

View File

@ -1,26 +1,10 @@
# #
# stm32_serialbuffer.py # stm32_serialbuffer.py
# #
import pioutil
if pioutil.is_pio_build():
Import("env") Import("env")
# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to
# configure buffer sizes for receiving \ transmitting serial data.
# Stm32duino uses another set of defines for the same purpose, so this
# script gets the values from the configuration and uses them to define
# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build
# flags so they are available for use by the platform.
#
# The script will set the value as the default one (64 bytes)
# or the user-configured one, whichever is higher.
#
# Marlin's default buffer sizes are 128 for RX and 32 for TX.
# The highest value is taken (128/64).
#
# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are
# defined, the first of these values will be used as the minimum.
build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"]
mf = env["MARLIN_FEATURES"]
# Get a build flag's value or None # Get a build flag's value or None
def getBuildFlagValue(name): def getBuildFlagValue(name):
for flag in build_flags: for flag in build_flags:
@ -48,6 +32,24 @@ def tryAddFlag(name, value):
if getBuildFlagValue(name) is None: if getBuildFlagValue(name) is None:
env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) env.Append(BUILD_FLAGS=[f"-D{name}={value}"])
# Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to
# configure buffer sizes for receiving \ transmitting serial data.
# Stm32duino uses another set of defines for the same purpose, so this
# script gets the values from the configuration and uses them to define
# `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build
# flags so they are available for use by the platform.
#
# The script will set the value as the default one (64 bytes)
# or the user-configured one, whichever is higher.
#
# Marlin's default buffer sizes are 128 for RX and 32 for TX.
# The highest value is taken (128/64).
#
# If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are
# defined, the first of these values will be used as the minimum.
build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"]
mf = env["MARLIN_FEATURES"]
# Get the largest defined buffer sizes for RX or TX, using defaults for undefined # Get the largest defined buffer sizes for RX or TX, using defaults for undefined
rxBuf = getBufferSize("RX", 128) rxBuf = getBufferSize("RX", 128)
txBuf = getBufferSize("TX", 64) txBuf = getBufferSize("TX", 64)

View File

@ -326,7 +326,6 @@ platform = ${common_stm32f1.platform}
extends = common_stm32f1 extends = common_stm32f1
board = marlin_CHITU_F103 board = marlin_CHITU_F103
extra_scripts = ${common_stm32f1.extra_scripts} extra_scripts = ${common_stm32f1.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
buildroot/share/PlatformIO/scripts/chitu_crypt.py buildroot/share/PlatformIO/scripts/chitu_crypt.py
build_flags = ${common_stm32f1.build_flags} build_flags = ${common_stm32f1.build_flags}