When I build in my native_test
environment (device independent unit tests), I use a different list of libraries in lib_deps
. (Lots of libs aren’t easy/appropriate to run in the mocked Arduino environment I use for native build.)
Despite not being in lib_deps
, PIO attempts to build all the libraries. I noticed because Adafruit Arduino Zero ASF Core Library won’t even build under native, because not SAM.
=========================================================================== [test::*] Building... (1/2) ===========================================================================
Please wait...
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/gclk.c:47:
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/gclk.h:55:
.piolibdeps/Adafruit Arduino Zero ASF Core Library/compiler.h:50:10: fatal error: 'sam.h' file not found
#include <sam.h>
^~~~~~~
1 error generated.
*** [.pioenvs/native_test/lib4fc/Adafruit Arduino Zero ASF Core Library/gclk.o] Error 1
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/i2s.c:47:
In file included from .piolibdeps/Adafruit Arduino Zero ASF Core Library/i2s.h:334:
.piolibdeps/Adafruit Arduino Zero ASF Core Library/compiler.h:50:10: fatal error: 'sam.h' file not found
#include <sam.h>
^~~~~~~
1 error generated.
*** [.pioenvs/native_test/lib4fc/Adafruit Arduino Zero ASF Core Library/i2s.o] Error 1
If I delete the library from .piolibdeps
I can build and run my unit tests. Next time I build for the device, PIO seamlessly downloads the library and that works without intervention.
Am I doing something wrong? Can I give PIO more information to do the right thing or is this a bug?
Thanks.
I still have problems with this often. I regularly run rm -rf .pioenvs .piolibdeps
when I switch to building a different env with different dependencies (usually building tests - native and embedded).
I just noticed the build_dir
configuration parameter. @ivankravets Any chance of specifying that at the env level -
[env:a]
build_dir = .pio_build_a
[env:b]
build_dir = .pio_build_b
or, alternatively, parameterize the name using the env of the current operation
[platformio]
build_dir = .pio_build_${env_name}
Thanks!
We plan to continue a work on PlatformIO Core 4.0 soon. So, this issue should help
opened 09:30PM - 20 Jun 18 UTC
closed 09:23PM - 22 May 19 UTC
enhancement
ldf
### Configuration
PIO 3.5 with ATOM on MAC 10.12.6
### Description of proble… m
When defining multiple environments on a project as [env:nodemcuv2] and [env:esp32]
I need to include different libraries for each of the environment, so I use lib_deps var to define for each environment the needed libraries.
The problem I face is that if I compile a single environment using default_env var, there is not problem, the includes work fine for each one of the environment,
If I do not specify de env to use, both are built and I need to explicitly exclude some library on ESP8266 env that are included in esp32.
What I believe is happening is that the library dependency folder is common for both environements so ALL included libraries for both environment are copied to that .piolibdeps folder so I need in each environment exclude the libs included in the other environment that do not apply.
Some libraries are not compatible with both environments raising error during compilation, even if they are no #include in the code.
A second effect (I believe may come from same root cause is that in case I use compile directive that exclude some lib #include, the lib is still compiled and not being compatible with the platform, will raise error.
#### Steps to Reproduce
1.
2.
3.
### Actual Results
with code used bellow the second effect is visible and I do not have currently code example prepared fro first symptom.
So result for second is that error code is generated when
`env_default=moteinomega`
because TFT_eSPI lib is not compatible with moteinoMega
but copiles ok with
`env_default=nodemcuv2`
> Indexing .pioenvs/moteinomega/libe97/libdisplay.a
Archiving .pioenvs/moteinomega/lib4e9/libAdafruit_GFX_Library.a
/Users/pedroalbuquerque/documents/googledrive/projects/libraries/TFT_eSPI/TFT_eSPI.cpp:4147:2
5: fatal error: soc/spi_reg.h: No such file or directory
#include "soc/spi_reg.h"
^
compilation terminated.
Archiving .pioenvs/moteinomega/lib135/libAdafruit_PCD8544.a
*** [.pioenvs/moteinomega/lib7bb/TFT_eSPI/TFT_eSPI.cpp.o] Error 1
Indexing .pioenvs/moteinomega/lib4e9/libAdafruit_GFX_Library.a
>Indexing .pioenvs/moteinomega/lib135/libAdafruit_PCD8544.a
========================== [ERROR] Took 2.90 seconds ==========================
### Expected Results
I would expect that due to the fact that macro ESP32 is not defined,
everything after ` #if defined(ESP32)`
would not be compiled avoiding the error.
Better said, the library referenced on an #include after that #if would not be compiled.
Actually I believe the include does not take place, and the object instance using that lib is not compiled, but the lib itself is compiled anyway.
When using arduino IDE to compile both with platform MoteinoMega as well with nodemcuv2, it compiles ok with no error.
### If problems with PlatformIO Build System:
**The content of `platformio.ini`:**
```
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[platformio]
env_default=moteinomega
src_dir=./
lib_dir=~/documents/googledrive/projects/libraries
lib_extra_dirs =/Users/pedroalbuquerque/Documents/GoogleDrive/Projects/Lib_dev
[common]
build_flags = -g
-DECHO_PORT=Serial
-DDEBUG_PORT=Serial
-DMQTT_MAX_PACKET_SIZE=400
-Wcomment
lib_ignore = ESP32WebServer
RFM69_OTA
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
build_flags = ${common.build_flags}
[env:moteinomega]
platform = atmelavr
board = moteinomega
framework = arduino
;upload_port=/dev/cu.usbserial-DN00Z51U
;upload_port=/dev/cu.usbserial-DA01I8AV
;upload_speed=115200
build_flags = ${common.build_flags}
; -D__AVR_ATmega1284P__
lib_ignore = ${common.lib_ignore}, TFT_eSPI
```
**Source file to reproduce issue:**
"Main file":
```#include <libT.h>
#include <libT2.h>
//#include <adafruit
#include <displayGeneric.h>
TTf f;
void setup(){
Serial.begin(115200);
}
void loop(){
uint8_t myint = 20;
uint16_t myint16 = 11111;
float myfloat = 12.3;
struct {
int i = -10;
char str[10]="hello!";
} mystruct;
f.bugger();
f.myf(myint);
f.myf(myint16);
f.myf(myfloat);
//f.myf(myfloat);
delay(1000);
}
```
Lib file that exclude another lib with compile directives
```
#ifndef DISPLAY_H
#define DISPLAY_H
#define DISPLAY_LCD
//#define DISPLAY_ST7735 //uncomment to select this display type/model
#include <Adafruit_GFX.h> // Core graphics library
#if defined(DISPLAY_LCD)
#include <Adafruit_PCD8544.h> //Required for the Nokia 5110 LCD display
// Initiate the display instance - Software SPI (slower updates, more flexible pin options):
// pin 24/A0 - Serial clock out (SCLK)
// pin 25/A1 - Serial data out (DIN)
// pin 26/A2 - Data/Command select (D/C)
// pin 27/A3 - LCD chip select (CS)
// pin 28/A4 - LCD reset (RST)
#if defined(ESP32)
// pins defined @ User_Setup.h on TFT_eSPI folder
/*
#include <Adafruit_ST7735.h> //Required for OLED LCD
#define RST 26 //13 //1 //A5 //18
#define RS 27 //12 //0 //A4 //19
#define SDA 14 // A2 //20
#define SCL 12 //27 // A0 //21
#define CS 13 //26 //3 //A3 //22
Adafruit_ST7735 display = Adafruit_ST7735(CS, RS, SDA, SCL, RST); //, RST);
*/
#include <TFT_eSPI.h> //Required for OLED LCD
TFT_eSPI display = TFT_eSPI();
#else //defined(ESP8266)
//D2 (GPIO4) 0 RST Output from ESP to reset display
//D1 (GPIO5) 1 CE Output from ESP to chip select/enable display
//D6 (GPIO12) 2 DC Output from display data/command to ESP
//D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input
//D5 (GPIO14) 4 Clk Output from ESP SPI clock
//3V3 5 Vcc 3.3V from ESP to display
//D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM
//G (GND) 7 Gnd Ground
#define RST 4 //A5 //18 // RST pin on LCD
#define RS 10 //A4 //19 // DC pin on LCD
#define SDA MISO //20 // DIN pin on LCD
#define SCL 6 //21 // CLK pin on LCD
#define CS 9 // CE pin o LCD
Adafruit_PCD8544 display = Adafruit_PCD8544(SCL, SDA, CS, RS, RST);
#define PIN_LCD_LIGHT 5 //Backlight pin for NOKIA LCD (LIGHT pin on LCD)
#endif
// character size from Adafruit_GXF lib
#define CHARWIDTH 6
#define CHARHEIGHT 8
#define SCRROTATION 0 // 0 rotation
#define CHARSCALE 1
#define SCRPIXELX 240
#define SCRPIXELY 320
#define SCRLINES 6 // 6 lines
#define SCRCHARS 14 // 14 characters
/// #define BOXSIZE 120
#endif
```
### Additional info
1 Like