mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 14:38:10 +01:00
unified way how all platforms handle copy_files (#7614)
Some checks are pending
CI / Test split components (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
Some checks are pending
CI / Test split components (push) Blocked by required conditions
CI / Check flake8 (push) Blocked by required conditions
CI / Create common environment (push) Waiting to run
CI / Check black (push) Blocked by required conditions
CI / Check pylint (push) Blocked by required conditions
CI / Check pyupgrade (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (push) Blocked by required conditions
CI / Check clang-format (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / list-components (push) Blocked by required conditions
CI / Component test (push) Blocked by required conditions
CI / Split components for testing into 20 groups maximum (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
YAML lint / yamllint (push) Waiting to run
Co-authored-by: Tomasz Duda <tomaszduda23@gmai.com>
This commit is contained in:
parent
bff0e81ed3
commit
9acc21e81a
2 changed files with 13 additions and 21 deletions
|
@ -17,7 +17,7 @@ from esphome.const import (
|
|||
PLATFORM_RP2040,
|
||||
)
|
||||
from esphome.core import CORE, EsphomeError, coroutine_with_priority
|
||||
from esphome.helpers import copy_file_if_changed, mkdir_p, write_file
|
||||
from esphome.helpers import copy_file_if_changed, mkdir_p, write_file, read_file
|
||||
|
||||
from .const import KEY_BOARD, KEY_PIO_FILES, KEY_RP2040, rp2040_ns
|
||||
|
||||
|
@ -230,11 +230,14 @@ def generate_pio_files() -> bool:
|
|||
|
||||
|
||||
# Called by writer.py
|
||||
def copy_files() -> bool:
|
||||
def copy_files():
|
||||
dir = os.path.dirname(__file__)
|
||||
post_build_file = os.path.join(dir, "post_build.py.script")
|
||||
copy_file_if_changed(
|
||||
post_build_file,
|
||||
CORE.relative_build_path("post_build.py"),
|
||||
)
|
||||
return generate_pio_files()
|
||||
if generate_pio_files():
|
||||
path = CORE.relative_src_path("esphome.h")
|
||||
content = read_file(path).rstrip("\n")
|
||||
write_file(path, content + '\n#include "pio_includes.h"\n')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import importlib
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
@ -299,25 +300,13 @@ def copy_src_tree():
|
|||
CORE.relative_src_path("esphome", "core", "version.h"), generate_version_h()
|
||||
)
|
||||
|
||||
if CORE.is_esp32:
|
||||
from esphome.components.esp32 import copy_files
|
||||
|
||||
platform = "esphome.components." + CORE.target_platform
|
||||
try:
|
||||
module = importlib.import_module(platform)
|
||||
copy_files = getattr(module, "copy_files")
|
||||
copy_files()
|
||||
|
||||
elif CORE.is_esp8266:
|
||||
from esphome.components.esp8266 import copy_files
|
||||
|
||||
copy_files()
|
||||
|
||||
elif CORE.is_rp2040:
|
||||
from esphome.components.rp2040 import copy_files
|
||||
|
||||
(pio) = copy_files()
|
||||
if pio:
|
||||
write_file_if_changed(
|
||||
CORE.relative_src_path("esphome.h"),
|
||||
ESPHOME_H_FORMAT.format(include_s + '\n#include "pio_includes.h"'),
|
||||
)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
def generate_defines_h():
|
||||
|
|
Loading…
Reference in a new issue