mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Use env.Flatten to manipulate with CPPDEFINES
This commit is contained in:
@ -122,8 +122,8 @@ def ConvertInoToCpp(env):
|
|||||||
remove(file_)
|
remove(file_)
|
||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
if isfile(file_):
|
if isfile(file_):
|
||||||
print ("Warning: Could not remove temporary file '%s'. "
|
print("Warning: Could not remove temporary file '%s'. "
|
||||||
"Please remove it manually." % file_)
|
"Please remove it manually." % file_)
|
||||||
|
|
||||||
ino_nodes = (env.Glob(join("$PROJECTSRC_DIR", "*.ino")) +
|
ino_nodes = (env.Glob(join("$PROJECTSRC_DIR", "*.ino")) +
|
||||||
env.Glob(join("$PROJECTSRC_DIR", "*.pde")))
|
env.Glob(join("$PROJECTSRC_DIR", "*.pde")))
|
||||||
@ -202,9 +202,7 @@ def DumpIDEData(env):
|
|||||||
def get_defines(env_):
|
def get_defines(env_):
|
||||||
defines = []
|
defines = []
|
||||||
# global symbols
|
# global symbols
|
||||||
for item in env_.get("CPPDEFINES", []):
|
for item in env.Flatten(env_.get("CPPDEFINES", [])):
|
||||||
if isinstance(item, list):
|
|
||||||
item = "=".join(item)
|
|
||||||
defines.append(env_.subst(item).replace('\\"', '"'))
|
defines.append(env_.subst(item).replace('\\"', '"'))
|
||||||
|
|
||||||
# special symbol for Atmel AVR MCU
|
# special symbol for Atmel AVR MCU
|
||||||
@ -232,9 +230,7 @@ def DumpIDEData(env):
|
|||||||
|
|
||||||
# https://github.com/platformio/platformio-atom-ide/issues/34
|
# https://github.com/platformio/platformio-atom-ide/issues/34
|
||||||
_new_defines = []
|
_new_defines = []
|
||||||
for item in env_.get("CPPDEFINES", []):
|
for item in env.Flatten(env_.get("CPPDEFINES", [])):
|
||||||
if isinstance(item, list):
|
|
||||||
item = "=".join(item)
|
|
||||||
item = item.replace('\\"', '"')
|
item = item.replace('\\"', '"')
|
||||||
if " " in item:
|
if " " in item:
|
||||||
_new_defines.append(item.replace(" ", "\\\\ "))
|
_new_defines.append(item.replace(" ", "\\\\ "))
|
||||||
|
@ -36,12 +36,9 @@ SRC_DEFAULT_FILTER = " ".join([
|
|||||||
def BuildProgram(env):
|
def BuildProgram(env):
|
||||||
|
|
||||||
def _append_pio_macros():
|
def _append_pio_macros():
|
||||||
if any(["PLATFORMIO=" in str(d) for d in env.get("CPPDEFINES", [])]):
|
env.AppendUnique(
|
||||||
return
|
|
||||||
env.Append(
|
|
||||||
CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format(
|
CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format(
|
||||||
*pioversion_to_intstr())],
|
*pioversion_to_intstr())])
|
||||||
)
|
|
||||||
|
|
||||||
_append_pio_macros()
|
_append_pio_macros()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user