Skip to content

esp: converge Arduino-vs-native dispatch on capability detection (FL_HAS_INCLUDE of IDF driver headers), not #ifdef ARDUINO #3722

Closed

Description

@zackees

Part of #3715.

Problem

The ESP tree currently selects Arduino-vs-native implementations three different ways:

  1. #if defined(ARDUINO) — 32/core/fastspi_esp32.h:34, 32/memory_esp32.hpp:11/32/61, 32/platform_time_esp32.cpp.hpp:11.
  2. FL_HAS_INCLUDE(<Arduino.h>) — 32/io_esp.cpp.hpp:16-26.
  3. Capability detection on IDF headers — 32/pin_esp32_native.hpp: FL_HAS_INCLUDE("driver/gpio.h") && FL_HAS_INCLUDE("driver/ledc.h") → native impl, else warning stub.

Mechanism 3 is the right model: it asks "is the Espressif driver available?" instead of "is Arduino present?", so the native path is taken even under Arduino (the IDF drivers ship inside every Arduino-ESP32 install), and bare-IDF builds need no special-casing. Mechanisms 1 and 2 invert the priority — they make Arduino the default whenever it exists, which is exactly the dependency direction #3715 removes.

Fix

Pure refactor, no behavior change intended on IDF-capable toolchains:

  1. Define the convention in one place (e.g. a short section in src/platforms/esp/32/ARCHITECTURE.md + a FL_ESP_HAS_IDF_DRIVERS-style umbrella macro if useful): dispatch on presence of the Espressif driver header, never on ARDUINO.
  2. Convert the mechanism-1/2 sites as their sub-issues land (SPI, serial IO, memory, timing all reference this convention). This issue tracks the convention doc + any remaining stragglers after those merge.
  3. Legit remaining uses of ARDUINO after this: platform identification in is_esp.h (ARDUINO_ARCH_ESP32/ESP8266), and genuinely Arduino-only opt-in features (e.g. io_arduino.hpp opt-in). Document both as the allowed exceptions.

Acceptance criteria

  • grep -rn "defined(ARDUINO)" src/platforms/esp/ hits only the documented exceptions list.
  • Convention documented in ARCHITECTURE.md and referenced from agents/docs/cpp-standards.md if appropriate.
  • No behavior change on any CI leg (this is a dispatch-mechanism refactor, not a backend change).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreplatform: esp32platform: esp8266type: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions