-
Notifications
You must be signed in to change notification settings - Fork 75
Description
PROBLEM DESCRIPTION
The path shortening code in the Arduino framework breaks the build if a middleware is used to set build flags on a per-source-file basis, as per the PlatformIO middleware example. This seems to be because it does not handle build sources that have already been promoted to SCons Object objects.
TO REPRODUCE
I have uploaded a minimal example based on the PlatformIO middleware documentation to https://github.com/willmmiles/MiddlewareExample
The example has two environments: one that uses the upstream platform-espressif32 and one that uses this repo.
Attempting to build the 'pioarduino' environment in the example produces:
*** While building `['C:\\Users\\Will\\Projects\\MiddlewareExample\\.pio\\build\\espressif_pioardunio\\src\\http_file.cpp.o']' from `['C:\\Users\\Will\\Projects\\MiddlewareExample\\.pio\\build\\espressif_pioardunio\\src\\http_file.cpp.o']': Don't know how to build from a source file with suffix `.o'. Expected a suffix in this list: ['.c', '.m', '.C', '.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm', '.s', '.asm', '.ASM', '.spp', '.SPP', '.sx', '.S'].
File "C:\Users\Will\.platformio\platforms\espressif32\builder\frameworks\arduino.py", line 806, in apply_include_shortening
EXPECTED BEHAVIOUR
The MRE should build successfully in the pioarduino env on Windows.
ADDITIONAL CONTEXT
My original use case for file-specific build flags was to pass release metadata only to a single source file, so as to avoid breaking build caching for the entire tree when the metadata was updated. I had originally intended to use a layered system with multiple scripts each handling individual tags, but I could not find a way to add flags to a single file from multiple independent middlewares. The only way I found to supply custom flags to exactly one file was to explicitly call env.Object() on that file; and once that was done, I wasn't able to figure out how to update them further in a second middleware call. In the end, I was forced to do all the metadata handling in one place to work around this.
If you have any ideas on how to approach allowing multiple middlewares to do per-file env changes, I'd be very interested in hearing them!
(Please, remember to close the issue when the problem has been addressed)