Parsing of #ifdef's done wrong

I am not sure if this is not already causing other issues the last few days, but it looks to be a change in the last week.

In short, the handling of #ifdef and #if checks in the (Arduino) ESPxxx code is done wrong.
When building code for ESP8266, I get build errors about ESP32 specific code.
But that code is set in #ifdef ESP32 checks, so this should not be a problem.

Even when I change the surrounding checks to #if false
it returns compiler errors about this ESP32 specific code.
So when converting the code to a .cpp file, the #ifdef parts are not processed correctly.

Has there been any change recently that could be related to this?
All PlatformIO related packages are up-to-date (Home: 0.9.6 and Core: 3.6.0a5)

See Travis build errors here. (so it isn’t related to my Windows environment at home)

I’ve been looking into this for the last 2 evenings and I really can’t find what’s causing this.
And I guess this really should be fixed, since I also have a number of other issues, which may or may not be related to including the wrong code when the #ifdef checks are not working like they should.

Set lib_ldf_mode = chain+. See Library Dependency Finder (LDF) — PlatformIO latest documentation

I tried that, but then it cannot find a lot of libraries.
So I will have to take a look at it, to see what’s wrong there.

In the mean time, I found the “ESP32” is no longer defined, so as a work-around I defined it myself in the project.
I was defined before, so maybe something has changed to make it no longer appear as defined?

It should be defined. See platform-espressif32/builder/main.py at develop · platformio/platform-espressif32 · GitHub

You can check it with pio run -v.