Skip to content

Commit

Permalink
pio_extra_script_helper.py: reusing platformio API to fetch a config …
Browse files Browse the repository at this point in the history
  • Loading branch information
MacDada committed Jun 19, 2023
1 parent c4ac22d commit aa6d2c3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/pio_extra_script_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from SCons.Script.SConscript import SConsEnvironment
from pathlib import Path
from platformio.platform.base import PlatformBase
from platformio.project.config import ProjectConfigBase
from utils import partition


Expand Down Expand Up @@ -34,19 +35,17 @@ def __init__(self, script_globals: dict):
def get_config_value_as_list(self, name: str) -> list[str]:
"""
https://docs.platformio.org/en/latest/scripting/examples/platformio_ini_custom_options.html
https://community.platformio.org/t/custom-platformio-ini-options-as-list-str-not-str/34380/2
todo: why `env.GetProjectOption()` sometimes returns `str` instead of `list[str]`?
for example `build_src_flags` returns a list,
while my `custom_system_packages` is a string…
https://community.platformio.org/t/custom-platformio-ini-options-as-list-str-not-str/34380
"""

return [
value
for value
in self.get_config_value(name).split('\n')
if value != ''
]
return self.get_project_config().parse_multi_values(
self.get_config_value(name)
)

def get_config_value(self, name: str, default: str = ''):
"""
Expand All @@ -55,6 +54,9 @@ def get_config_value(self, name: str, default: str = ''):

return self.env.GetProjectOption(name, default=default)

def get_project_config(self) -> ProjectConfigBase:
return self.env.GetProjectConfig()

def get_platform(self) -> PlatformBase:
"""
The platform is the same for all the envs.
Expand Down

0 comments on commit aa6d2c3

Please sign in to comment.