Closed Pedroalbuquerque closed 5 years ago
I think PlatformIO should install libraries to %projectdepsdir%/%env%/
. In this case, we will not have conflict.
Possible issues:
libdeps_dir
platformio.ini
should lead to removing of libdeps_dir
@ivankravets I think this issue was recently introduced by 3.5.3 or 3.5.4. In my opinion, breaking projects that used to compile should qualify as a bug, not an enhancement.
With platformio 3.5.2 my project with multi environments compiles fine with 3.5.2 and now with 3.5.4 it does not build anymore.
@ivankravets Is there a solution for this in the works? I seem to be able to work around the issue with
lib_ldf_mode = chain+
lib_compat_mode = strict
but it more than doubles our Travis test times, it is more of a dev issue than end user as they tend to just build one env but it still causes problems.
@p3p you can manually control LDF with lib_deps
and lib_ignore
options instead of lib_ldf_mode = chain+
Indeed I can specify everything myself or just disable the ldf as I have needed to in the past, but the issue of building incompatible libraries for envs that don't need them if they have already been installed by another env seems to be something that should be fixed?
but the issue of building incompatible libraries for platforms that don't need them if they have already been installed by another env seems to be something that should be fixed?
Yes, this should be fixed with this feature request.
Indeed I can specify everything myself or just disable the ldf
lib_ldf_mode = chain+
lib_ignore
lib_deps
.All these options put into specific env.
We already do a lot of cherry picking libraries over at Marlin we support a lot of environments, I was just going to report the bug and found this issue with a changing milestone so thought I'd make sure it was still in the works ;)
It's not an old issue :) We plan to start a work on PlatformIO Core 4.0 soon.
Didn't mean to imply you were sitting on your hands, sometimes issues can just fly under the radar, as you say it's not a major issue as I can work around it.
even if this is not completely related to this issue: note that one of the problem of the LDF is that it should include the right library based on the architecture/platform example: https://platformio.org/lib/show/870/WiFi as you can see from the platform on the right it is wrong since that library is only for Arduino WiFi Shield but it has the same name of the ESP32 version. The same happens, i guess, for the other platform
Edit: I will try to propose a way to do it: platformio should compute the priority of two libraries using the library.properties
file especially the architectures
field, a function like: computePriorities(library x, library y, used_platform)
could be made that gives higher priority to the library which has the same architecture to the used_platform. Also built-in libraries (like in this case) should be preferred instead of external one
I ran across this while attempting to make Embedded Template Library Arduino compatible with PlatformIO. I've got to the point that espressif8266
and espressif32
platforms seem to work but supporting atmelavr
(without specifically documenting it) would require setting the library to depend on ArduinoSTL
. This causes build to fail on other platforms even when ArduinoSTL.h
is not included.
If I define lib_compat_mode = strict
in platformio.ini
everything works great. So I thought maybe if in library.json
I define:
"build": {
"libCompatMode": "strict"
... it will do the same but it doesn't. When I run pio run -e d1_mini -v
I see a message indicating the unsupported library would be skipped but it is still included in the compiler parameters:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 79 compatible libraries
Scanning dependencies...
Skip platform incompatible dependency {u'frameworks': [u'arduino'], u'version': u'>=1.1.0', u'name': u'ArduinoSTL', u'platforms': [u'atmelavr']}
In PlatformIO library index ArduinoSTL seems to also be defined only for atmelavr
and atmelsam
.
I also noticed the library.json documentation instructs libCompatMode
should be defined as Integer
but the referred documentation uses String
. I tried giving it numeric values 2
and 3
but it ddn't seem to make a difference.
Please re-test with pio upgrade --dev
. Updated docs => http://docs.platformio.org/en/latest/userguide/lib/index.html
pio lib --help
Based on OP issue, isn't it better to make libdeps dir name based on platform+framework+(+board?) instead of env name? If multiple environments have the same lib_deps variable and the same platform,framework, libs are installed each time.
@mcspr and we will back to the same problem which we had before. For example, some envs can have different lib_deps
and platform+framework+(+board?)
ID will lead to a conflict issue.
The only solution is to provide isolated build environment for project configuration. This is actually what PlatformIO Core 4.0 will do.
Please note that we don't do multiple downloads of project dependencies. We cache them. Normally, the size of a library is 50-300Kb.
Yes, I did miss possibility of different library versions.
However, I think it still force downloads github repos? For example
lib_deps =
ArduinoJson@5.13.4
https://github.com/me-no-dev/ESPAsyncTCP#7e9ed22
https://github.com/xoseperez/NtpClient.git#0942ebc
Fixed version works fine with platformio registry, but next github repo is one picking specific commit mid versions, second one is forked library. Both will be git-cloned. Or some other method should be used, like using branch / commit archive zips?(e.g replace the first link with https://github.com/me-no-dev/ESPAsyncTCP/archive/7e9ed22ed0078097f895dfee6ebcec90046b81b9.zip)
I think I found a bug (warrants another issue to track?)
Caching is evidently broken: #2559
@mcspr thank you so much for the issue https://github.com/platformio/platformio-core/issues/2559
I'll investigate!
Configuration
PIO 3.5 with ATOM on MAC 10.12.6
Description of problem
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 moteinoMegabut copiles ok with
env_default=nodemcuv2
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
:Source file to reproduce issue: "Main file":
Lib file that exclude another lib with compile directives
Additional info