Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library without includeDir unpredictable #3887

Closed
1 task done
dzarda opened this issue Mar 17, 2021 · 5 comments
Closed
1 task done

Library without includeDir unpredictable #3887

dzarda opened this issue Mar 17, 2021 · 5 comments
Assignees
Labels
bug build system LDF Library Dependency Finder
Milestone

Comments

@dzarda
Copy link

dzarda commented Mar 17, 2021

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.

Configuration

Operating system: Windows 10

PlatformIO Version version 5.1.1b1

Description of problem

Referencing CNL (not containing library.json) causes contents of include/cnl/ to be placed in .pio\libdeps\penboard\cnl. The includeDir is also aimed at that directory (-I.pio\libdeps\penboard\cnl). This breaks the intended library usage with #include "cnl/....h". AFAIK this is in contrast with includeDir documentation that talks about library/include being the default. Same behaviour is seen both with library.json missing or just includeDir missing.

Actual Results

The subdirectory include/cnl is extracted to libdeps/cnl, making the cnl/...h include invalid.

Expected Results

cnl/...h include should be the right option.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:bla]
platform = native
lib_deps = https://github.com/johnmcfarlane/cnl/archive/v1.x.zip

Source file to reproduce issue:

#define CHAR_BIT 8
#include "cnl/all.h"

int main()
{
}

Additional info

I probably understand the logic behind the behaviour, but I think there;s still an inconsistency with the docs.

  • Either fix the docs to document the behaviour with looking for directories containing .h files
  • Or always add the library/include path as per docs ... if it's there, I suppose :) (preferred)
@ivankravets
Copy link
Member

See https://docs.platformio.org/en/latest/librarymanager/config.html#includedir

It seems you need "includedir": "."

@dzarda
Copy link
Author

dzarda commented Mar 17, 2021

@ivankravets I don't think you understand. This is about the behaviour when I'm trying to use a foreign library without library.json in it

@ivankravets ivankravets reopened this Mar 17, 2021
@ivankravets ivankravets added LDF Library Dependency Finder help wanted build system and removed help wanted labels Mar 17, 2021
@maxgerhardt
Copy link
Contributor

Maybe partly related to https://community.platformio.org/t/platformio-downloads-subfolder/20154. In general, the behavior on how PlatformIO downloads a library is sometimes very wrong -- in the linked topic you can e.g. see that for the repo https://github.com/digint/tinyfsm, when using it in lib_deps, downloads only the content of the first subfolder of the examples folder (https://github.com/digint/tinyfsm/tree/master/examples/api).

Maybe something in general can be done here to improve the logic in which subfolder of a package is actually used, in case no library.json or library.properties is present.

Regarding the original problem: I've forked the CNL library and added the library.json to it. You can use it per

[env:native]
platform = native
lib_deps = https://github.com/maxgerhardt/cnl.git#v1.1.7-pio
build_flags = -std=c++17

(I've only added it to this branch since I couldn't get the 2.0.0-dev branch working, seems to need C++20)

@dzarda
Copy link
Author

dzarda commented Mar 21, 2021

I think we need a way of injecting metadata to a foreign raw dependency (Conan allows this).

Maybe there's a way with extra_scripts, but that's entirely unobvious to me.

@ivankravets
Copy link
Member

Thanks for the report! Please re-test with pio -upgrade --dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug build system LDF Library Dependency Finder
Projects
None yet
Development

No branches or pull requests

3 participants