mirror of
https://github.com/esphome/esphome.git
synced 2026-08-23 06:36:23 +00:00
Merge branch 'esp8266-native-build-surgery' into esp8266-native-toolchain-plumbing
This commit is contained in:
@@ -96,14 +96,17 @@ def generate_cmakelists_txt(component: IDFComponent) -> str:
|
||||
# flag and its argument (e.g. "-include cp_custom_alloc.h"); bare
|
||||
# -I/-L/-l tokens re-glue to their argument ("-I foo" -> "-Ifoo") so the
|
||||
# prefix classifiers below still route them.
|
||||
build_flags = join_flag_args(
|
||||
(
|
||||
token
|
||||
for entry in build_flags
|
||||
for token in split_flag_entry(entry, f"library {component.name}")
|
||||
),
|
||||
f"library {component.name}",
|
||||
)
|
||||
# Joined per entry, as SCons's ParseFlags lexes each string
|
||||
# independently: a dangling -I ending one entry must warn, not absorb
|
||||
# the next entry's first token.
|
||||
build_flags = [
|
||||
token
|
||||
for entry in build_flags
|
||||
for token in join_flag_args(
|
||||
split_flag_entry(entry, f"library {component.name}"),
|
||||
f"library {component.name}",
|
||||
)
|
||||
]
|
||||
|
||||
# List all sources files
|
||||
build_src_files = collect_filtered_files(
|
||||
|
||||
@@ -49,7 +49,10 @@ DEFAULT_BUILD_SRC_DIRS = "src"
|
||||
DEFAULT_BUILD_INCLUDE_DIR = "include"
|
||||
DEFAULT_BUILD_FLAGS = []
|
||||
# Source suffix -> compiler kind, PlatformIO's CSUFFIXES/CXXSUFFIXES/ASSUFFIXES
|
||||
# split. Native build generators map the kind to their compile rules.
|
||||
# split. Native build generators map the kind to their compile rules. "asm"
|
||||
# deliberately merges SCons's AS (.s/.asm) and ASPP (.S/.spp/.sx) sets: the
|
||||
# ninja rules compile all of them as assembler-with-cpp, whose asm-mode
|
||||
# preprocessor passes non-directive text through unchanged.
|
||||
SOURCE_KIND_FOR_SUFFIX: dict[str, str] = {
|
||||
".c": "c",
|
||||
".cpp": "cxx",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# pylint: disable=protected-access
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
@@ -290,9 +291,10 @@ def test_parse_entry_recovers_from_unconfigured_launcher(
|
||||
f"{ABS}build/src/esphome/core/application.cpp",
|
||||
"/opt/homebrew/bin/ccache /tools/xtensa-lx106-elf-g++ -c a.cpp -o a.o",
|
||||
)
|
||||
caplog.set_level(logging.DEBUG)
|
||||
cxx_path, _, _, _ = idedata.parse_entry(entry)
|
||||
assert cxx_path == "/tools/xtensa-lx106-elf-g++"
|
||||
assert "WARNING" not in caplog.text
|
||||
assert "Stripping unconfigured launcher" in caplog.text
|
||||
|
||||
|
||||
def test_parse_entry_keeps_launcher_without_program() -> None:
|
||||
|
||||
@@ -1084,3 +1084,18 @@ def test_emit_idf_component_wires_esp32_target(tmp_path, monkeypatch):
|
||||
c.data = {"build": {"extraScript": "extra.py"}}
|
||||
_emit_idf_component(c)
|
||||
assert c.data["build"]["flags"] == ["-lesp32"]
|
||||
|
||||
|
||||
def test_build_flags_dangling_flag_does_not_cross_entries(
|
||||
tmp_path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Each entry is lexed independently, as ParseFlags does: a dangling -I ending one
|
||||
entry warns instead of absorbing the next entry's first token."""
|
||||
(tmp_path / "src").mkdir()
|
||||
c = IDFComponent("owner/name", "1.0", source=URLSource("http://dummy"))
|
||||
c.path = tmp_path
|
||||
c.data = {"build": {"flags": ["-Wall -I", "-DFOO=1"]}}
|
||||
content = generate_cmakelists_txt(c)
|
||||
assert "FOO=1" in content
|
||||
assert "-I-DFOO" not in content
|
||||
assert "Ignoring trailing '-I'" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user