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

Apply BuildDependentLibraries to src_filter dirs #696

Closed
wants to merge 1 commit into from
Closed

Apply BuildDependentLibraries to src_filter dirs #696

wants to merge 1 commit into from

Conversation

davidgraeff
Copy link

At the moment BuildDependentLibraries (scanning source files for lib
includes) is only executed for the src directory, even if src_filter
brings in other directories. This few lines of code changes apply the
scanning to all additional dirs mentioned in src_filter with a "+".

Use cases

Have targets in your platformio.ini which references additional source directories via the src_filter.

  1. In my case i want to target an arduino and an esp8266 board. The core logic
    of my library is platform independant but some few files are board specific, so I need
    to pull them in via src_filter (which works great). This pull request allows mentioned
    libraries in those additional files to be handled like if the source files reside in "src/".

  2. If you provide some examples with a library, at the moment it is difficult to provide the user
    a simple way to build an example. With this pull request the user just builds one of the
    targets in the platformio.ini which lists the example source files via src_filter. E.g.:

`[platformio]
src_dir = src/

[env:nodemcuv2lib]
platform = espressif
framework = arduino
board = nodemcuv2

[env:nodemcuv2Example1]
platform = espressif
framework = arduino
board = nodemcuv2
src_filter = +<> +<../examples/example1/src/>`

At the moment BuildDependentLibraries (scanning source files for lib
includes) is only executed for the src directory, even if src_filter
brings in other directories. This few lines of code changes apply the
scanning to all additional dirs mentioned in src_filter.
@ivankravets
Copy link
Member

Thank you for this pull request.

  1. You can write multiplatform code using different macros. PlatformIO passes these defines by default. For example, -DESP8266, -DARDUINO_ARCH_AVR and then #ifdef... #endif.
  2. Take a look at platformio ci command. You have the ability to run library example and pass the source code of library to build process.
  3. We have a separate issue with extra options for the Library Builder. See Handle specific extra build flags from library.json #289

@davidgraeff
Copy link
Author

@ivankravets Thanks for the fast response.

  1. Handle specific extra build flags from library.json #289 is good thing indeed, will it be pio2 or be part of pio3?

  2. platformio ci with the "-l" options is what I was looking for. On linux I made a symlink, that wasn't possible on windows machines. Is there already support in the atom based IDE for this workflow?

  3. I still thing that "src" may either be an array with directories or src_filter added directories are handled
    in a similar fashion to the "src" dir.
    Sometimes the directory structure cannot be that simple. In my case one "platform" directory is a git submodule and I cannot easily add #ifdefs to the files, but the src_filter option would allow me to use this workflow.

@ivankravets
Copy link
Member

  1. Handle specific extra build flags from library.json #289 is a part of PlatformIO 3.0.
  2. I don't recommend to mix "program source code" with "library source code". The aim of PlatformIO 3.0 is to make these components maximum isolated. As a result, we will introduce additional leverages to control build process for the libraries.

I propose to wait for the first PlatformIO 3.0beta and then we will discuss it.

In any case, thanks a lot for the PR and I'll not close it till final PlatformIO 3.0.

@davidgraeff
Copy link
Author

@ivankravets ok then. i can live with my patched version of pio2 until pio3 is out

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

Successfully merging this pull request may close these issues.

None yet

2 participants