mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-26 04:33:47 +00:00 
			
		
		
		
	Allow global setting of compile process limit (#4081)
This commit is contained in:
		| @@ -22,6 +22,14 @@ if bashio::config.has_value 'relative_url'; then | ||||
|     export ESPHOME_DASHBOARD_RELATIVE_URL=$(bashio::config 'relative_url') | ||||
| fi | ||||
|  | ||||
| if bashio::config.has_value 'default_compile_process_limit'; then | ||||
|     export ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT=$(bashio::config 'default_compile_process_limit') | ||||
| else | ||||
|     if grep -q 'Raspberry Pi 3' /proc/cpuinfo; then | ||||
|         export ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT=1; | ||||
|     fi | ||||
| fi | ||||
|  | ||||
| pio_cache_base=/data/cache/platformio | ||||
| # we can't set core_dir, because the settings file is stored in `core_dir/appstate.json` | ||||
| # setting `core_dir` would therefore prevent pio from accessing | ||||
|   | ||||
| @@ -110,6 +110,15 @@ def validate_version(value: str): | ||||
|     return value | ||||
|  | ||||
|  | ||||
| if "ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT" in os.environ: | ||||
|     _compile_process_limit_default = min( | ||||
|         int(os.environ["ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT"]), | ||||
|         multiprocessing.cpu_count(), | ||||
|     ) | ||||
| else: | ||||
|     _compile_process_limit_default = cv.UNDEFINED | ||||
|  | ||||
|  | ||||
| CONF_ESP8266_RESTORE_FROM_FLASH = "esp8266_restore_from_flash" | ||||
| CONFIG_SCHEMA = cv.All( | ||||
|     cv.Schema( | ||||
| @@ -153,9 +162,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() | ||||
|             ), | ||||
|             cv.Optional( | ||||
|                 CONF_COMPILE_PROCESS_LIMIT, default=_compile_process_limit_default | ||||
|             ): cv.int_range(min=1, max=multiprocessing.cpu_count()), | ||||
|         } | ||||
|     ), | ||||
|     validate_hostname, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user