mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 06:58:11 +01:00
Fix platformio monkey patch (#768)
This commit is contained in:
parent
aed7b3fbb2
commit
b78b28ea0e
1 changed files with 5 additions and 16 deletions
|
@ -12,27 +12,18 @@ from esphome.util import run_external_command, run_external_process
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_platformio4():
|
||||
from platformio import VERSION
|
||||
return VERSION[0] >= 4
|
||||
|
||||
|
||||
def patch_structhash():
|
||||
# Patch platformio's structhash to not recompile the entire project when files are
|
||||
# removed/added. This might have unintended consequences, but this improves compile
|
||||
# times greatly when adding/removing components and a simple clean build solves
|
||||
# all issues
|
||||
# pylint: disable=no-member,no-name-in-module,import-error
|
||||
from platformio.commands import run
|
||||
from platformio import util
|
||||
if is_platformio4():
|
||||
from platformio.project.helpers import get_project_dir
|
||||
else:
|
||||
from platformio.util import get_project_dir
|
||||
from platformio.commands.run import helpers, command
|
||||
from os.path import join, isdir, getmtime
|
||||
from os import makedirs
|
||||
|
||||
def patched_clean_build_dir(build_dir, *args):
|
||||
from platformio import util
|
||||
from platformio.project.helpers import get_project_dir
|
||||
platformio_ini = join(get_project_dir(), "platformio.ini")
|
||||
|
||||
# if project's config is modified
|
||||
|
@ -43,10 +34,8 @@ def patch_structhash():
|
|||
makedirs(build_dir)
|
||||
|
||||
# pylint: disable=protected-access
|
||||
if is_platformio4():
|
||||
run.helpers.clean_build_dir = patched_clean_build_dir
|
||||
else:
|
||||
run._clean_build_dir = patched_clean_build_dir
|
||||
helpers.clean_build_dir = patched_clean_build_dir
|
||||
command.clean_build_dir = patched_clean_build_dir
|
||||
|
||||
|
||||
def run_platformio_cli(*args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue