mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
Add core config option to limit compile process count (#3952)
This commit is contained in:
parent
991fc54994
commit
85faecb2fd
3 changed files with 11 additions and 2 deletions
|
@ -116,6 +116,7 @@ CONF_COMMAND_RETAIN = "command_retain"
|
|||
CONF_COMMAND_TOPIC = "command_topic"
|
||||
CONF_COMMENT = "comment"
|
||||
CONF_COMMIT = "commit"
|
||||
CONF_COMPILE_PROCESS_LIMIT = "compile_process_limit"
|
||||
CONF_COMPONENT_ID = "component_id"
|
||||
CONF_COMPONENTS = "components"
|
||||
CONF_CONDITION = "condition"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import multiprocessing
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -11,6 +12,7 @@ from esphome.const import (
|
|||
CONF_BOARD_FLASH_MODE,
|
||||
CONF_BUILD_PATH,
|
||||
CONF_COMMENT,
|
||||
CONF_COMPILE_PROCESS_LIMIT,
|
||||
CONF_ESPHOME,
|
||||
CONF_FRAMEWORK,
|
||||
CONF_INCLUDES,
|
||||
|
@ -151,6 +153,9 @@ CONFIG_SCHEMA = cv.All(
|
|||
cv.Optional(CONF_MIN_VERSION, default=ESPHOME_VERSION): cv.All(
|
||||
cv.version_number, validate_version
|
||||
),
|
||||
cv.Optional(CONF_COMPILE_PROCESS_LIMIT): cv.int_range(
|
||||
min=1, max=multiprocessing.cpu_count()
|
||||
),
|
||||
}
|
||||
),
|
||||
validate_hostname,
|
||||
|
|
|
@ -8,7 +8,7 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
|
||||
from esphome.const import KEY_CORE
|
||||
from esphome.const import CONF_COMPILE_PROCESS_LIMIT, CONF_ESPHOME, KEY_CORE
|
||||
from esphome.core import CORE, EsphomeError
|
||||
from esphome.util import run_external_command, run_external_process
|
||||
|
||||
|
@ -103,7 +103,10 @@ def run_platformio_cli_run(config, verbose, *args, **kwargs) -> Union[str, int]:
|
|||
|
||||
|
||||
def run_compile(config, verbose):
|
||||
return run_platformio_cli_run(config, verbose)
|
||||
args = []
|
||||
if CONF_COMPILE_PROCESS_LIMIT in config[CONF_ESPHOME]:
|
||||
args += [f"-j{config[CONF_ESPHOME][CONF_COMPILE_PROCESS_LIMIT]}"]
|
||||
return run_platformio_cli_run(config, verbose, *args)
|
||||
|
||||
|
||||
def _run_idedata(config):
|
||||
|
|
Loading…
Reference in a new issue