When I disable the src folder for my unit test environment I get warnings and fails. Here is my platformio.ini:
env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
test_ignore = test_desktop
[env:native]
platform = native
This will build both enviroments but obviously fail on the native that I only use for unit_test:
*****************************************************************
* Looking for Arduino.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:Arduino.h"
* Web > https://platformio.org/lib/search?query=header:Arduino.h
*
*****************************************************************
#include <Arduino.h>
^~~~~~~~~~~
compilation terminated.
src\main.cpp:1:10: fatal error: Arduino.h: No such file or directory
So I figured setting the src_filter in native like this
src_filter = -<*>
This fails like this:
Processing native (platform: native)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Error: Nothing to build. Please put your source code files to '...r\src' folder
================================================================================== [FAILED] Took 0.50 seconds ==================================================================================
Environment Status Duration
------------- -------- ------------
nodemcuv2 SUCCESS 00:00:18.499
native FAILED 00:00:00.496
So I finally came up with a hack that works:
targets = --version
And this gives me all green success:
Processing native (platform: native)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------SCons by Steven Knight et al.:
SCons: v4.0.1.c289977f8b34786ab6c334311e232886da7e8df1, 2020-07-17 01:50:03, by bdbaddog on ProDog2020
SCons path: ['C:\\Users\\andre\\.platformio\\packages\\tool-scons\\scons-local-4.0.1\\SCons']
Copyright (c) 2001 - 2020 The SCons Foundation
================================================================================== [SUCCESS] Took 0.17 seconds ==================================================================================
Environment Status Duration
------------- -------- ------------
nodemcuv2 SUCCESS 00:00:19.141
native SUCCESS 00:00:00.169
================================================================================== 2 succeeded in 00:00:19.310 ==================================================================================
But this is not the way targets is supposed to be used. Isn’t there a better way to skip building for a specific environment without warnings? I want to use build-all as I have different platform (not shown in this example) so i get a list of all greens so that I can tell that all platforms compiled as expected.