earlephilhower / ESP8266Audio

Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
GNU General Public License v3.0
2.05k stars 435 forks source link

Fix PlatformIO library search mode #500

Closed maxgerhardt closed 2 years ago

maxgerhardt commented 2 years ago

When creating a PlatformIO project referencing this library with the default options

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps = earlephilhower/ESP8266Audio@^1.9.5

A simple sketch with

#include <Arduino.h>
#include "AudioGeneratorAAC.h"
#include "AudioOutputI2S.h"
#include "AudioFileSourcePROGMEM.h"
void setup() {}
void loop() {}

fails to compile with not finding ESP8266HTTPClient.h. This is because this library uses #ifdef checks to check for the target architecture, but PlatformIO's library dependency finder search mode does not evaluate these checks, and finds none of the dependencies of this library, hence failing the build.

Interestingly enough, setting deep+ or chain+ does also not solve the problem, but deep does.

This PR fixes compilations for all 3 target architectures, tested with

[env]
framework = arduino

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2

[env:esp32dev]
platform = espressif32
board = esp32dev

[env:rp2040]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
board_build.core = earlephilhower
platform_packages =
    maxgerhardt/framework-arduinopico@https://github.com/maxgerhardt/arduino-pico.git
    maxgerhardt/toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.3.1-a/x86_64-w64-mingw32.arm-none-eabi-7855b0c.210706.zip

Also increases the version by 1 minor.

As discussed in https://community.platformio.org/t/esp8266-audio-library-fails-to-compile/26070.