Skip to content

Commit

Permalink
Properly handle ARDUINO_PARTITION define in PlatformIO (espressif#6681)
Browse files Browse the repository at this point in the history
This fixes possible issues when developers specify arbitrary partition files
using relative or absolute paths.

Additionally, hyphens in filenames are replaced with underscores to
avoid compilation warnings "ISO C++11 requires whitespace after the macro name"

Resolves platformio/platform-espressif32#787
  • Loading branch information
valeros authored May 4, 2022
1 parent ce2cd11 commit 4453ca5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions tools/platformio-build-esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py

from os.path import abspath, isdir, isfile, join
from os.path import abspath, basename, isdir, isfile, join

from SCons.Script import DefaultEnvironment

Expand Down Expand Up @@ -319,7 +319,8 @@
("ARDUINO", 10812),
("ARDUINO_VARIANT", '\\"%s\\"' % env.BoardConfig().get("build.variant").replace('"', "")),
("ARDUINO_BOARD", '\\"%s\\"' % env.BoardConfig().get("name").replace('"', "")),
"ARDUINO_PARTITION_%s" % env.BoardConfig().get("build.partitions", "default.csv").replace(".csv", "")
"ARDUINO_PARTITION_%s" % basename(env.BoardConfig().get(
"build.partitions", "default.csv")).replace(".csv", "").replace("-", "_")
],

LIBSOURCE_DIRS=[
Expand Down
5 changes: 3 additions & 2 deletions tools/platformio-build-esp32c3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py

from os.path import abspath, isdir, isfile, join
from os.path import abspath, basename, isdir, isfile, join

from SCons.Script import DefaultEnvironment

Expand Down Expand Up @@ -312,7 +312,8 @@
("ARDUINO", 10812),
("ARDUINO_VARIANT", '\\"%s\\"' % env.BoardConfig().get("build.variant").replace('"', "")),
("ARDUINO_BOARD", '\\"%s\\"' % env.BoardConfig().get("name").replace('"', "")),
"ARDUINO_PARTITION_%s" % env.BoardConfig().get("build.partitions", "default.csv").replace(".csv", "")
"ARDUINO_PARTITION_%s" % basename(env.BoardConfig().get(
"build.partitions", "default.csv")).replace(".csv", "").replace("-", "_")
],

LIBSOURCE_DIRS=[
Expand Down
5 changes: 3 additions & 2 deletions tools/platformio-build-esp32s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py

from os.path import abspath, isdir, isfile, join
from os.path import abspath, basename, isdir, isfile, join

from SCons.Script import DefaultEnvironment

Expand Down Expand Up @@ -314,7 +314,8 @@
("ARDUINO", 10812),
("ARDUINO_VARIANT", '\\"%s\\"' % env.BoardConfig().get("build.variant").replace('"', "")),
("ARDUINO_BOARD", '\\"%s\\"' % env.BoardConfig().get("name").replace('"', "")),
"ARDUINO_PARTITION_%s" % env.BoardConfig().get("build.partitions", "default.csv").replace(".csv", "")
"ARDUINO_PARTITION_%s" % basename(env.BoardConfig().get(
"build.partitions", "default.csv")).replace(".csv", "").replace("-", "_")
],

LIBSOURCE_DIRS=[
Expand Down
5 changes: 3 additions & 2 deletions tools/platformio-build-esp32s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Extends: https://github.com/platformio/platform-espressif32/blob/develop/builder/main.py

from os.path import abspath, isdir, isfile, join
from os.path import abspath, basename, isdir, isfile, join

from SCons.Script import DefaultEnvironment

Expand Down Expand Up @@ -331,7 +331,8 @@
("ARDUINO", 10812),
("ARDUINO_VARIANT", '\\"%s\\"' % env.BoardConfig().get("build.variant").replace('"', "")),
("ARDUINO_BOARD", '\\"%s\\"' % env.BoardConfig().get("name").replace('"', "")),
"ARDUINO_PARTITION_%s" % env.BoardConfig().get("build.partitions", "default.csv").replace(".csv", "")
"ARDUINO_PARTITION_%s" % basename(env.BoardConfig().get(
"build.partitions", "default.csv")).replace(".csv", "").replace("-", "_")
],

LIBSOURCE_DIRS=[
Expand Down

0 comments on commit 4453ca5

Please sign in to comment.