Platformio-core: Feature request : Better integration of environments in CLion

Created on 24 Jul 2019  路  28Comments  路  Source: platformio/platformio-core

Hi. I love platformio and have been using it for two years with CLion without a hitch. Recently I have started using multiple environments but they do not integrate at all in CLion :

  • Cannot run individual environments from the IDE
  • Code completion features are based on the first environment only

Those issues forced me to add a dummy environment, write some custom CMake and have some manual setup after each pio init, even though I felt that this could be integrated in platformio.

In the process of solving this issues for my project, I found ways around them which seemed very portable and thought that they might help enhance platformio's integration with CLion.

I forked the repo, tried some things around and I managed to solve the above-mentioned issues. Should I submit a PR ?

enhancement integration

Most helpful comment

@Teo-CD great work! I like the new integration! PIO Core 4.0.3 is coming today 馃槉

All 28 comments

Started a CLion Plugin at github.com/nexoscp/PlatformIOLion. Help is welcome!

@nexoscp wow!!! Do you need any help from our side?

@Teo-CD Great work on https://github.com/platformio/platformio-core/compare/develop...Teo-CD:clion-integration?expand=1

I've just refactored a little bit ProjectGenerator (see https://github.com/platformio/platformio-core/commit/1dc15326c9d5d3e894e20d5ed2dfc89d4c9358e1) and added config to template generator.

So, you have full access to ProjectConfig via {{ config }} of config varaibles. For example, config.envs() returns avaialble environemnts. See ProjectConfig API.

Could you remove your branch and create a new one based on config? We would be happy to merge it. Thanks!

@nexoscp wow!!! Do you need any help from our side?

Help is always welcome. I'm new to PlatformIO so having a feature list to catch up withe the other IDEs would be great.
To complete the platform.ini-editor, a specification of sections, keys, type of values and default values would be also great. Also some sort of schema for the JSON-outputs generated by the platformio cli. This should also help other integration projects.

I think the first what should be implemented is PlatofrmIO Core installer. We wrote it in JS and some part of it is ported to Java by @gholdys https://github.com/platformio/platformio-eclipse-ide/tree/master/src/com/insightmachines/pio/installer

The original source code is located here https://github.com/platformio/platformio-node-helpers/tree/master/src/installer

What does this installer do? It creates a Python virtual environment using different methods and installs PIO Core. So, it means that no need to ask a user to install PIO Core manually. When user starts Eclipse/CLIon, the extension checks PIO Core installation and does everything automatically. They, the extension uses it for PIO Core calls.


The question

Sorry, I'm not Java developer. Is it possible to have something similar to platformio-node-helpers but for Java? platformio-java-helpers? So, other people can re-use these helpers for own needs. Also, this package can be used by Eclipse or CLion extension.

Thanks!

Sorry, I'm not Java developer. Is it possible to have something similar to platformio-node-helpers but for Java? platformio-java-helpers? So, other people can re-use these helpers for own needs. Also, this package can be used by Eclipse or CLion extension.

And i'm not firm with python, but that should not stop us. Will look into it the next days. For now i have to pack my stuff for CCCamp. If someone want to meet and chat ping me on @nexoscp

You don't need to know Python :) We use PlatformIO from IDE via CLI. Reading JavaScript code could help to make this platformio-java-helpers.

Had a look at platformio-eclipse-ide. Thx @gholdys !

I see two tasks here:

  • define how to interact with user. Should there be a dialog asking to install PlatformIO or a systenm similar to SDKs in Intellij-Idea or ...
  • extract a eclipse independent jar and publish it to a maven repo

addad a Gradle-Build to publish a JAR: PR

I'm glad someone will take-over the development of this plugin. @nexoscp, feel free to change the package name. I used my default one, but it probably should be something more PlatformIO oriented.

I have some draft plugin code with a view that contains a browser. I've managed to successfully open the home page of a local PlatformIO build server in this browser. I'll commit it by the end of this week.

is there already a established package name for PlatformIO on JVM? If not, is org.platformio ok?

That would be the most proper package name (at least according to the convention for Java packages)

Thanks @gholdys and @nexoscp!

Should we create a separate repository for platformio-java-helpers? So, we can keep here base functionality which later could be reused in Eclipse or CLion extensions. Such as PIO Core installation, project task manager, etc.

Good idea! +1

Thank you @ivankravets ! I really like the changes you made to ProjectGenerator, I'll create a branch based on config as soon as I have the time.

Really nice to see the start of a CLion plugin ! I hope you will succeed with this endeavour, a CLion plugin would be awesome to have! :smiley: @nexoscp

@Teo-CD great work! I like the new integration! PIO Core 4.0.3 is coming today 馃槉

@nexoscp could you contact [email protected]? I would like to discuss what can we do with better integration with CLIon.

Thank you @ivankravets , I am happy that it worked out nicely ! Really glad to have contributed :D This experience has cemented my wish to contribute more to open source projects - and to platformio if the occasion arises!

Should I update CLion's page on the documentation to document the new integration ?

Should I update CLion's page on the documentation to document the new integration ?
Yes, it will be great! https://github.com/platformio/platformio-docs/blob/develop/ide/clion.rst


Could you upgrade PIO Core to 4.0.3rc via pio upgrade --dev and re-test? Do you know how can we fix an issue when environment name contains spaces? For example, `[env:hello world]

Going to do that right now.

My guess would be to quote env names in a way that CMakes does not leave out the space. I'm going to look into it

@ivankravets Everything works as expected apart from when the env names has a space in it as you mentioned.
Changing {{ env_name }} to "{{ env_name }}" in https://github.com/platformio/platformio-core/blob/386883fbe53792c939f79c15d3eb3cb1a8a3b372/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl#L50 and {{ env }} to "{{ env }}" in https://github.com/platformio/platformio-core/blob/386883fbe53792c939f79c15d3eb3cb1a8a3b372/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl#L67 should do the trick.

Tested the modification with two envs sharing the same first word (hello world and hello planet) and it was not an issue.

Thanks! It worked!

@ivankravets Re-tested project generation for CLion from an empty project, it mainly completes but produces an error message as ide_data does not exist if there are no leftover environements :
https://github.com/platformio/platformio-core/blob/db6f98336463493bf26deed666c2134dc0aed26c/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl#L62-L64

I don't know the cleanest way to handle this but adding an else clause with ide_data = dict() fixed it. I guess defining ide_data = dict() before the if would work too.

Thanks, fixed!

@ivankravets Sorry to be slow to find the bugs, but there is another one: when there are exactly two environments, Python throws the error

File "[...]/platformio/project/helpers.py", line 220, in load_project_ide_data
    if len(envs) == 1 and envs[0] in data:
TypeError: 'set' object does not support indexing

when called from https://github.com/platformio/platformio-core/blob/db6f98336463493bf26deed666c2134dc0aed26c/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl#L63 .

This one I do not know how to fix.

4.0.3 is out https://github.com/platformio/platformio-core/releases/tag/v4.0.3 and the last bug is fixed in 4.0.4a1.

If this is a critical issue, we will release 4.0.4 next week.

Existing projects with 2 environments should be fine, but not benefit from the new integration. You cannot init at all from scratch with 2 environments though. Everything else is behaving as expected (This time, tested it all x) ).

I do not know how many people would be affected, but I suppose not that many ?

Was this page helpful?
0 / 5 - 0 ratings