mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Fix deprecation of board_flash_mode parameter (#41)
* Fix deprecation of board_flash_mode parameter Fixes `Warning! `board_flash_mode` option is deprecated and will be removed in the next release! Please use `board_build.flash_mode` instead.` * Don't break flashing for older installations.
This commit is contained in:
		
				
					committed by
					
						 Otto Winter
						Otto Winter
					
				
			
			
				
	
			
			
			
						parent
						
							a04438e924
						
					
				
				
					commit
					d7699c93d6
				
			| @@ -82,6 +82,7 @@ def get_build_flags(config, key): | |||||||
|  |  | ||||||
|  |  | ||||||
| def get_ini_content(config): | def get_ini_content(config): | ||||||
|  |     version_specific_settings = determine_platformio_version_settings() | ||||||
|     platform = config[CONF_ESPHOMEYAML][CONF_PLATFORM] |     platform = config[CONF_ESPHOMEYAML][CONF_PLATFORM] | ||||||
|     if platform in PLATFORM_TO_PLATFORMIO: |     if platform in PLATFORM_TO_PLATFORMIO: | ||||||
|         platform = PLATFORM_TO_PLATFORMIO[platform] |         platform = PLATFORM_TO_PLATFORMIO[platform] | ||||||
| @@ -119,8 +120,9 @@ def get_ini_content(config): | |||||||
|  |  | ||||||
|     content = INI_CONTENT_FORMAT.format(**options) |     content = INI_CONTENT_FORMAT.format(**options) | ||||||
|     if CONF_BOARD_FLASH_MODE in config[CONF_ESPHOMEYAML]: |     if CONF_BOARD_FLASH_MODE in config[CONF_ESPHOMEYAML]: | ||||||
|  |         flash_mode_key = version_specific_settings['flash_mode_key'] | ||||||
|         flash_mode = config[CONF_ESPHOMEYAML][CONF_BOARD_FLASH_MODE] |         flash_mode = config[CONF_ESPHOMEYAML][CONF_BOARD_FLASH_MODE] | ||||||
|         content += "board_flash_mode = {}\n".format(flash_mode) |         content += "{} = {}\n".format(flash_mode_key, flash_mode) | ||||||
|     return content |     return content | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -194,3 +196,16 @@ def write_cpp(code_s, path): | |||||||
|         return |         return | ||||||
|     with codecs.open(path, 'w+', encoding='utf-8') as f_handle: |     with codecs.open(path, 'w+', encoding='utf-8') as f_handle: | ||||||
|         f_handle.write(full_file) |         f_handle.write(full_file) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def determine_platformio_version_settings(): | ||||||
|  |     import platformio | ||||||
|  |  | ||||||
|  |     settings = {} | ||||||
|  |  | ||||||
|  |     if platformio.VERSION < (3, 5, 3): | ||||||
|  |         settings['flash_mode_key'] = 'board_flash_mode' | ||||||
|  |     else: | ||||||
|  |         settings['flash_mode_key'] = 'board_build.flash_mode' | ||||||
|  |  | ||||||
|  |     return settings | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user