platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.99k stars 800 forks source link

"build_src_filter" not being respected when checking files to build main() #4412

Closed 424778940z closed 2 years ago

424778940z commented 2 years ago

What kind of issue is this?

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Windows 10

PlatformIO Version (platformio --version): 6.1.4

Description of problem

I'm trying to move a project from C to C++. I have main.c and main.cpp in Src folder, both of them contains int main(). I understand this will result in an error when linking since we have to instance of different int main(). As following platformio.ini configured, I told the build system to ignore Src/main.c and Src/gpio.c. Which did not work, the build system still trys to build Src/main.c. I tested with Src/gpio.c only, this works, it seems something else checking what to build for main() do not respect build_src_filter.

If I simplely rename main.c to main_old.c and ignore it with -<Src/main_old.c> then it works fine.

The content of platformio.ini:

[env:nucleo_f767zi]
platform = ststm32
board = nucleo_f767zi
framework = stm32cube
board_build.stm32cube.custom_config_header = yes
build_src_filter = 
    +<*> -<.git/> -<.svn/> 
    -<Src/gpio.c> -<Inc/gpio.h>
    -<Src/main.c> -<Inc/main.h>

[platformio]
include_dir = Inc
src_dir = Src

Error Message

*** Multiple ways to build the same target were specified for: C:\_projects\_playgrounds\stm32cube\pioBased\.pio\build\nucleo_f767zi\src\main.o  (from ['C:\\_projects\\_playgrounds\\stm32cube\\pioBased\\Src\\main.c'] and from ['C:\\_projects\\_playgrounds\\stm32cube\\pioBased\\Src\\main.cpp'])
File "C:\Users\localadmin\.platformio\penv\lib\site-packages\platformio\builder\tools\piobuild.py", line 355, in <listcomp>
424778940z commented 2 years ago

Nevermind, it was my bad, the ini not in utf-8 seems caused the issue