mirror of
https://github.com/esphome/esphome.git
synced 2026-09-01 18:46:02 +00:00
[rp2] Rename rp2040 platform to rp2 (#17145)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
co-authored by
Jonathan Swoboda
parent
9caf431740
commit
cdd334284e
@@ -785,6 +785,29 @@ def build_schema():
|
||||
# bundle core inside esphome
|
||||
data["esphome"]["core"] = data.pop("core")["core"]
|
||||
|
||||
# Surface deprecated component aliases (declared via ``ALIASES = [...]``
|
||||
# on the canonical component) so language servers / dashboard
|
||||
# autocomplete still accept legacy top-level keys instead of flagging
|
||||
# them as unknown. Each alias gets its own bundle that mirrors the
|
||||
# canonical schema; ``alias_of`` and the optional ``removal_version``
|
||||
# metadata let consumers render a deprecation hint and point users at
|
||||
# the canonical name. Without this, configs migrated only at runtime
|
||||
# (via the ``_resolve_component_aliases`` pre-pass) would still light
|
||||
# up as errors in the editor.
|
||||
for domain, manifest in components.items():
|
||||
aliases = manifest.aliases
|
||||
if not aliases or domain not in data:
|
||||
continue
|
||||
canonical_bundle = data[domain].get(domain)
|
||||
if canonical_bundle is None:
|
||||
continue
|
||||
for alias in aliases:
|
||||
alias_entry = dict(canonical_bundle)
|
||||
alias_entry["alias_of"] = domain
|
||||
if manifest.alias_removal_version is not None:
|
||||
alias_entry["removal_version"] = manifest.alias_removal_version
|
||||
data[alias] = {alias: alias_entry}
|
||||
|
||||
if GENERATED_ID_TYPES:
|
||||
print(
|
||||
"Unconsumed id_type matchers:",
|
||||
|
||||
+5
-2
@@ -621,6 +621,9 @@ def convert_path_to_relative(abspath, current):
|
||||
"esphome/components/web_server/__init__.py",
|
||||
# const.py has absolute import in docstring example for external components
|
||||
"esphome/components/esp8266/const.py",
|
||||
# rp2040/__init__.py is the deprecation shim that documents the canonical
|
||||
# rp2 module path and its own legacy import paths in docstrings/comments.
|
||||
"esphome/components/rp2040/__init__.py",
|
||||
],
|
||||
)
|
||||
def lint_relative_py_import(fname: Path, line, col, content):
|
||||
@@ -650,13 +653,13 @@ def lint_relative_py_import(fname: Path, line, col, content):
|
||||
"esphome/components/async_tcp/async_tcp.h",
|
||||
"esphome/components/esp32/core.cpp",
|
||||
"esphome/components/esp8266/core.cpp",
|
||||
"esphome/components/rp2040/core.cpp",
|
||||
"esphome/components/rp2/core.cpp",
|
||||
"esphome/components/libretiny/core.cpp",
|
||||
"esphome/components/host/core.cpp",
|
||||
"esphome/components/zephyr/core.cpp",
|
||||
"esphome/components/esp32/helpers.cpp",
|
||||
"esphome/components/esp8266/helpers.cpp",
|
||||
"esphome/components/rp2040/helpers.cpp",
|
||||
"esphome/components/rp2/helpers.cpp",
|
||||
"esphome/components/libretiny/helpers.cpp",
|
||||
"esphome/components/host/helpers.cpp",
|
||||
"esphome/components/zephyr/helpers.cpp",
|
||||
|
||||
@@ -160,7 +160,8 @@ class Platform(StrEnum):
|
||||
BK72XX_ARD = "bk72xx-ard" # LibreTiny BK7231N
|
||||
RTL87XX_ARD = "rtl87xx-ard" # LibreTiny RTL8720x
|
||||
LN882X_ARD = "ln882x-ard" # LibreTiny LN882x
|
||||
RP2040_ARD = "rp2040-ard" # Raspberry Pi Pico
|
||||
RP2040_ARD = "rp2040-ard" # RP2 family, RP2040 chip (Pico / Pico W)
|
||||
RP2350_ARD = "rp2350-ard" # RP2 family, RP2350 chip (Pico 2 / Pico 2 W)
|
||||
NRF52_ZEPHYR = "nrf52-adafruit" # Nordic nRF52 (Zephyr)
|
||||
|
||||
|
||||
@@ -190,7 +191,8 @@ MEMORY_IMPACT_PLATFORM_PREFERENCE = [
|
||||
Platform.BK72XX_ARD, # LibreTiny BK7231N
|
||||
Platform.RTL87XX_ARD, # LibreTiny RTL8720x
|
||||
Platform.LN882X_ARD, # LibreTiny LN882x
|
||||
Platform.RP2040_ARD, # Raspberry Pi Pico
|
||||
Platform.RP2040_ARD, # Raspberry Pi Pico (RP2040)
|
||||
Platform.RP2350_ARD, # Raspberry Pi Pico 2 (RP2350)
|
||||
Platform.NRF52_ZEPHYR, # Nordic nRF52 (Zephyr)
|
||||
]
|
||||
|
||||
@@ -859,7 +861,8 @@ def _detect_platform_hint_from_filename(filename: str) -> Platform | None:
|
||||
- *_libretiny.cpp, *_bk72*.* -> BK72XX (LibreTiny)
|
||||
- *_rtl87*.* -> RTL87XX (LibreTiny Realtek)
|
||||
- *_ln882*.* -> LN882X (LibreTiny Lightning)
|
||||
- *_pico.cpp, *_rp2040.* -> RP2040_ARD
|
||||
- *_rp2350*.*, *_pico2*.* -> RP2350_ARD (RP2 family, RP2350 chip)
|
||||
- *_rp2040*.*, *_pico*.* -> RP2040_ARD (RP2 family, RP2040 chip)
|
||||
|
||||
Args:
|
||||
filename: File path to check
|
||||
@@ -901,8 +904,14 @@ def _detect_platform_hint_from_filename(filename: str) -> Platform | None:
|
||||
if "libretiny" in filename_lower or "bk72" in filename_lower:
|
||||
return Platform.BK72XX_ARD
|
||||
|
||||
# RP2040 / Raspberry Pi Pico
|
||||
if "pico" in filename_lower or "rp2040" in filename_lower:
|
||||
# RP2 family (Raspberry Pi Pico): explicit chip names only. Family-
|
||||
# wide files (named ``_rp2.*``) are shared between RP2040 and RP2350
|
||||
# and intentionally don't preferentially route to either chip.
|
||||
# Check the RP2350 patterns first since ``pico2`` substring-matches
|
||||
# ``pico``.
|
||||
if "rp2350" in filename_lower or "pico2" in filename_lower:
|
||||
return Platform.RP2350_ARD
|
||||
if "rp2040" in filename_lower or "pico" in filename_lower:
|
||||
return Platform.RP2040_ARD
|
||||
|
||||
# nRF52 / Zephyr
|
||||
|
||||
@@ -8,14 +8,14 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from esphome.components.rp2040 import RECOMMENDED_ARDUINO_FRAMEWORK_VERSION
|
||||
from esphome.components.rp2040.generate_boards import generate
|
||||
from esphome.components.rp2 import RECOMMENDED_ARDUINO_FRAMEWORK_VERSION
|
||||
from esphome.components.rp2.generate_boards import generate
|
||||
from esphome.helpers import write_file_if_changed
|
||||
|
||||
ver = RECOMMENDED_ARDUINO_FRAMEWORK_VERSION
|
||||
version_tag: str = f"{ver.major}.{ver.minor}.{ver.patch}"
|
||||
root: Path = Path(__file__).parent.parent
|
||||
boards_file_path: Path = root / "esphome" / "components" / "rp2040" / "boards.py"
|
||||
boards_file_path: Path = root / "esphome" / "components" / "rp2" / "boards.py"
|
||||
|
||||
|
||||
def main(check: bool) -> None:
|
||||
@@ -42,10 +42,10 @@ def main(check: bool) -> None:
|
||||
if check:
|
||||
existing_content: str = boards_file_path.read_text(encoding="utf-8")
|
||||
if existing_content != content:
|
||||
print("esphome/components/rp2040/boards.py is not up to date.")
|
||||
print("Please run `script/generate-rp2040-boards.py`")
|
||||
print("esphome/components/rp2/boards.py is not up to date.")
|
||||
print("Please run `script/generate-rp2-boards.py`")
|
||||
sys.exit(1)
|
||||
print("esphome/components/rp2040/boards.py is up to date")
|
||||
print("esphome/components/rp2/boards.py is up to date")
|
||||
elif write_file_if_changed(boards_file_path, content):
|
||||
print("RP2040 boards updated successfully.")
|
||||
|
||||
Reference in New Issue
Block a user