[Implemented] Multitarget refinement, when developing for many boards at once

I enjoy the env targeting paradigm that platformio current presents

Sometimes I develop for multiple targets, i.e. test on the Uno, try it out on a Pro Micro then end up moving it to an attiny later.

What I’ve been doing is symbolic linking platformio.ini to a platformio.uno.ini or a platformio.promicro.ini, so that I can switch what the “default” target platformio run and platformio upload command executes.

if I have all my env’s in one platformio.ini, then it tries to upload them all at once when I do a platformio upload!

What would be neat is if something like this was built in; like a platformio.default.ini acting as a king of soft symbolic link (so that it can be .gitignored).

Do you mean platformio run -e?

It’s very similar. For my use case, having “platform run” default to a particular env (instead of default to all envs) is useful, rather than explicitly specify it.

I suppose I could have said just that above, instead of the big paragraph huh? =)

Do you use PlatformIO IDE or PlatformIO CLI?

I don’t see any objections to add something

[env]
platform = ...
board = ...
default = true

If there are no defined default envs, then build all, otherwise build only default = true for platformio run.

The problem here that people complain of a complexity of PlatformIO behaviour and platformio.ini.

Do you have better ideas instead default = true?

I see what you mean, I definitely don’t want to contribute to too much complexity.

For this scenario, I use the old atom platformio plugin that came before your IDE (don’t shoot me please!). I really like your IDE but it doesn’t work for all my scenarios.

Idea#1:

Do exactly what you’ve suggested. Being that “default” is an optional parameter, this implies that if someone doesn’t know about it, they won’t be impacted - suggesting it doesn’t add (much) complexity

Idea#2:

Externalize outside of platformio.ini. Make like a .piodefaults file or something. This has a downside of being potentially more complicated, but the upside is that:

a) it can be .gitignored
b) it doesn’t add complexity to platformio.ini itself

Idea#3:

Hang defaults off of an environment variable like PIO_ENV_DEFAULT or something. This particular one would be not quite as ideal for me, but still satisfy the requirement.

Please in details form this point… :sunglasses: Why it doesn’t work?

hehe I don’t want to complain!! My usage scenario is one root folder containing many subprojects (lets say 20 for example)

+ root folder
  - PlatformIO folder
     - proj1
        - lib
        - src
     - ...
     - proj20
        - lib
        - src

atom points at “root folder”. In this case, official PlatformIO IDE only seems to compile against root folder , which fails since it’s not actually a project folder

Why don’t open these projects as separate items? PlatformIO IDE highlights active project in which you work. It is very useful.

Ok, please open an issue and make reference to this topic.

Thanks.

Excellent will do. And I will try out your suggestion. Thing is I have so many projects, instructing Atom each as a project folder is overwhelming -

This is not good argument. I don’t want to force you to use our IDE. If you take a look at a few professional IDEs you will see that they have deal with PROJECT where the only one business logic reflected in it. Ok, I’ll try explain you why we can’t propose user to use “one opened folder” for multiple projects. Having 1 projected opened within PlatformIO IDE:

  1. Allows to integrate Code Linter and Code Completion. If you have multiple “virtual projects” under real project, these instruments will not work properly.
  2. You always see the current active project when edit multiple files form the different opened projects.
  3. You have ability to re-run the latest target from build panel
  4. PlatformIO Terminal opens with CWD from the current project. It allows to use PlatformIO CLI /IDE in the same place with the all functionality.
  5. And … and … and…

Please try it, I hope you will like it.

No argument! For the record, I am absolutely not requesting that atom behavior. Only the default environment behavior – I only brought it up 'cause you asked … ! =)

1 Like

I’ve just wanted to understand which problems with PlatformIO IDE has our valuable customer :blush:

1 Like

I seem to understand what the author wants to tell you.
In the Java development world, there are some analogue of the make utility. It is called Apache Maven
https://maven.apache.org/

At the root of each project is pom.xml file
The parent directory can have a pom.xml file. ordering of the modules listed in this file.

There are several similar systems in Ruby and other languages.

The most important thing in maven - a repository of the collected components.
In the project file, we indicate dependence on another project. Maven takes from his vault with the library, based versions.

PlatformIO Arduino IDE and have a system of external libraries.
Maven is a project build system and library catalog management system.

During assembly, you can specify the name of the current profile. You can specify a set of variables and specific libraries in the profile.

Sorry if I misunderstood the author’s idea.

You can can explain PlatformIO what it should build. You can have multiple environments with the different libraries dependencies. PlatformIO CLI allows to run specific environments. However, author requested feature to have influence on default platformio run command because it process all envs by default.

We have opened issue Default env target for multi-environment situations · Issue #576 · platformio/platformio-core · GitHub and you will be able to change behaviour of pio run.

If some functionality is missed in PlatformIO don’t hesitate to write here. I’m open for discussion and are interested to make PlatformIO really professional ecosystem.

1 Like

It would be very convenient to have functionality of registration of the project as a library.
It is necessary, make changes to the project. Further, the command is sent project to library directory.

In this regard, there is in the maven project structure

<group>mycompany.app</group>
<artifact>my-project</artifact>
<version>1.0</version>

It is not a mandatory reference to the parent project.

<parent>
  <group>mycompany.app</group>
  <artifact>my-root-project</artifact>
  <version>1.0</version>
</parent>

Here the main feature of the approach.
The parent can specify the working environment. Affiliated projects will use these settings.

I do not propose to use XML syntax. Other projects use different designs.

Where do you want to store this “project as a library”? In the PlatformIO Library Registry?

“project as a library” seems like:

a) an interesting idea
b) something to be moved to a different thread =)

1 Like

@alexey-su let’s move this discussion about Maven and Java workflow to separate subject. I’m new to Java & Maven.

Implemented in PlatformIO 2.9.0 Redirecting...

1 Like