Skip to content

Commit

Permalink
Fixed an issue with improper processing of source files added via mul…
Browse files Browse the repository at this point in the history
…tiple Build Middlewares // Resolve #3531
  • Loading branch information
ivankravets committed Jun 23, 2020
1 parent 9fb4cde commit 82735dd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions platformio/builder/tools/platformio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from SCons import Builder, Util # pylint: disable=import-error
from SCons.Node import FS # pylint: disable=import-error
from SCons.Node import NodeList # pylint: disable=import-error
from SCons.Script import COMMAND_LINE_TARGETS # pylint: disable=import-error
from SCons.Script import AlwaysBuild # pylint: disable=import-error
from SCons.Script import DefaultEnvironment # pylint: disable=import-error
Expand Down Expand Up @@ -283,20 +282,21 @@ def CollectBuildFiles(
if fs.path_endswith_ext(item, SRC_BUILD_EXT):
sources.append(env.File(os.path.join(_var_dir, os.path.basename(item))))

for callback, pattern in env.get("__PIO_BUILD_MIDDLEWARES", []):
tmp = []
for node in sources:
if isinstance(node, NodeList):
node = node[0]
middlewares = env.get("__PIO_BUILD_MIDDLEWARES")
if not middlewares:
return sources

new_sources = []
for node in sources:
new_node = node
for callback, pattern in middlewares:
if pattern and not fnmatch.fnmatch(node.srcnode().get_path(), pattern):
tmp.append(node)
continue
n = callback(node)
if n:
tmp.append(n)
sources = tmp
new_node = callback(new_node)
if new_node:
new_sources.append(new_node)

return sources
return new_sources


def AddBuildMiddleware(env, callback, pattern=None):
Expand Down

0 comments on commit 82735dd

Please sign in to comment.