Merge build flags from platformio_options (#1651)

This commit is contained in:
Trevor North 2021-07-26 07:59:18 +01:00 committed by GitHub
parent 3749c11f21
commit 1f5cbca509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,9 +72,7 @@ upload_flags =
""", """,
) )
UPLOAD_SPEED_OVERRIDE = { UPLOAD_SPEED_OVERRIDE = {"esp210": 57600}
"esp210": 57600,
}
def get_flags(key): def get_flags(key):
@ -210,11 +208,12 @@ def gather_lib_deps():
return [x.as_lib_dep for x in CORE.libraries] return [x.as_lib_dep for x in CORE.libraries]
def gather_build_flags(): def gather_build_flags(overrides):
build_flags = CORE.build_flags build_flags = list(CORE.build_flags)
build_flags += [overrides] if isinstance(overrides, str) else overrides
# avoid changing build flags order # avoid changing build flags order
return list(sorted(list(build_flags))) return list(sorted(build_flags))
ESP32_LARGE_PARTITIONS_CSV = """\ ESP32_LARGE_PARTITIONS_CSV = """\
@ -228,8 +227,10 @@ spiffs, data, spiffs, 0x391000, 0x00F000
def get_ini_content(): def get_ini_content():
overrides = CORE.config[CONF_ESPHOME].get(CONF_PLATFORMIO_OPTIONS, {})
lib_deps = gather_lib_deps() lib_deps = gather_lib_deps()
build_flags = gather_build_flags() build_flags = gather_build_flags(overrides.pop("build_flags", []))
data = { data = {
"platform": CORE.arduino_version, "platform": CORE.arduino_version,
@ -275,7 +276,7 @@ def get_ini_content():
# Ignore libraries that are not explicitly used, but may # Ignore libraries that are not explicitly used, but may
# be added by LDF # be added by LDF
# data['lib_ldf_mode'] = 'chain' # data['lib_ldf_mode'] = 'chain'
data.update(CORE.config[CONF_ESPHOME].get(CONF_PLATFORMIO_OPTIONS, {})) data.update(overrides)
content = f"[env:{CORE.name}]\n" content = f"[env:{CORE.name}]\n"
content += format_ini(data) content += format_ini(data)