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

Add Clion code insight features for PIO "lib_extra_dirs" option #3460

Closed
Copper-Bot opened this issue Apr 17, 2020 · 7 comments · Fixed by #3463
Closed

Add Clion code insight features for PIO "lib_extra_dirs" option #3460

Copper-Bot opened this issue Apr 17, 2020 · 7 comments · Fixed by #3463
Assignees
Labels
Milestone

Comments

@Copper-Bot
Copy link

Configuration

Operating system: Windows 10 64bits

PlatformIO Version (platformio --version): 4.3.1

Clion Version: 2019.3.5

Description of the bug/request

Hi !

When "lib_extra_dirs" option is used on platformio.ini, and when the project is init for Clion, PIO does not add the additional lib path at the end of the CMakeListsPrivate.txt (the path is missing in the "FILE(GLOB_RECURSE SRC_LIST .... )" command).

PIO work fine, but Clion does not activate code insight features for any source files in the additional lib path, unless it is manually added to the CMakeListsPrivate.txt.

Would it be please possible to add this to PIO Clion project files generation ?

@valeros
Copy link
Member

valeros commented Apr 17, 2020

Hi @Copper-Bot ! Strange, but I cannot reproduce the issue. I added a new folder to lib_extra_dirs and all libraries from that folder are added to CMakeListsPrivate.txt. Am I missing something?

@Copper-Bot
Copy link
Author

Hi @valeros ! Hum, don't you have a warning when opening any .c/.cpp library source file with clion, that they are not part of the project ? Or maybe it is because I am using multiple environments with different "lib_extra_dirs" for each ?

Here is an example: test_folder.zip

If you init the project with Clion, any headers from "lib_extra_dirs" will be part of the clion project (code insight ok), but not their associated .c/.cpp files.

@Copper-Bot
Copy link
Author

Hi again,

First thanks you for the PR ! I just switch to the dev version of PIO (4.3.2a2) and re-init my project and ... it doesn't work completely for me haha

It works fine for the first environment, but not the second. It seems that the CMakeListsPrivate.txt does the glob_recurse only for the first env but not the others.

Using the same test_folder.zip project above, I edit the end of the new generated CMakeListsPrivate.txt like this to make it lib_extra_dirs "environment dependent" when calling FILE (GLOB_RECURSE ...) :

...

FILE(GLOB_RECURSE SRC_LIST
    ${CMAKE_CURRENT_LIST_DIR}/src/*.*
    ${CMAKE_CURRENT_LIST_DIR}/lib/*.*
)

if (CMAKE_BUILD_TYPE MATCHES "test_boardone")
    FILE(GLOB_RECURSE SRC_LIST_test_boardone
        ${CMAKE_CURRENT_LIST_DIR}/ext_lib/boardOne/*.*
        ${CMAKE_CURRENT_LIST_DIR}/.pio/libdeps/test_boardone/*.*
    )
    SET(SRC_LIST ${SRC_LIST} ${SRC_LIST_test_boardone})
endif()
if (CMAKE_BUILD_TYPE MATCHES "test_boardtwo")
    FILE(GLOB_RECURSE SRC_LIST_test_boardtwo
        ${CMAKE_CURRENT_LIST_DIR}/ext_lib/boardTwo/*.*
        ${CMAKE_CURRENT_LIST_DIR}/.pio/libdeps/test_boardtwo/*.*
    )
    SET(SRC_LIST ${SRC_LIST} ${SRC_LIST_test_boardtwo})
endif()

I don't know very well Cmake so I don't know if it is a viable solution or not, but it seems to work for Clion.

@valeros
Copy link
Member

valeros commented Apr 21, 2020

Strange, but I cannot reproduce the issue with the latest platformio-core. It works fine for both environments. Could you please elaborate on It doesn't work completely for me ?
Intellisense doesn't work or CLion complains that files don't belong to the project?

@Copper-Bot
Copy link
Author

Clion complains for the .cpp file of the lib (not the header) :
image

This occurs only if the 'lib_extra_dirs' is not the same as the first environment.

valeros added a commit that referenced this issue Apr 21, 2020
#3460

This will allow to dynamically populate list of sources depending on
selected environment. At the same time "src" and "lib" folders remain
common for all environments
@valeros
Copy link
Member

valeros commented Apr 21, 2020

OK, now I see what you mean, I just pushed a small fix, could you please update PlatformIO to the latest from development branch and try again?

@Copper-Bot
Copy link
Author

It works like a charm ! Thank you very much !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants