mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Fix handling of build flags passed via environment vars // Resolve #526
This commit is contained in:
@ -77,6 +77,20 @@ Building
|
||||
|
||||
Allows to set :ref:`projectconf` option :ref:`projectconf_build_flags`.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Unix:
|
||||
export PLATFORMIO_BUILD_FLAGS=-DFOO
|
||||
export PLATFORMIO_BUILD_FLAGS="-DFOO -DBAR=1 -DFLOAT_VALUE=1.23457e+07"
|
||||
export PLATFORMIO_BUILD_FLAGS="'-DWIFI_PASS=\"My password\"' '-DWIFI_SSID=\"My ssid name\"'"
|
||||
|
||||
# Windows:
|
||||
SET PLATFORMIO_BUILD_FLAGS=-DFOO
|
||||
SET PLATFORMIO_BUILD_FLAGS=-DFOO -DBAR=1 -DFLOAT_VALUE=1.23457e+07
|
||||
SET PLATFORMIO_BUILD_FLAGS='-DWIFI_PASS="My password"' '-DWIFI_SSID="My ssid name"'
|
||||
|
||||
.. envvar:: PLATFORMIO_SRC_BUILD_FLAGS
|
||||
|
||||
Allows to set :ref:`projectconf` option :ref:`projectconf_src_build_flags`.
|
||||
|
@ -301,7 +301,10 @@ Example:
|
||||
.. code-block:: ini
|
||||
|
||||
[env:specific_defines]
|
||||
build_flags = -Dfoo -Dbar=1
|
||||
build_flags = -DFOO -DBAR=1 -DFLOAT_VALUE=1.23457e+07
|
||||
|
||||
[env:string_defines]
|
||||
build_flags = '-DHELLO="World!"' '-DWIFI_PASS="My password"'
|
||||
|
||||
[env:specific_inclibs]
|
||||
build_flags = -I/opt/include -L/opt/lib -lfoo
|
||||
|
@ -96,17 +96,19 @@ def BuildProgram(env):
|
||||
|
||||
|
||||
def ProcessFlags(env, flags):
|
||||
parsed_flags = env.ParseFlags(flags)
|
||||
for flag in parsed_flags.pop("CPPDEFINES"):
|
||||
if isinstance(flag, list):
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
'-D%s=\\"%s\\"' % (flag[0], flag[1])
|
||||
]
|
||||
)
|
||||
else:
|
||||
env.Append(CPPDEFINES=flag)
|
||||
env.Append(**parsed_flags)
|
||||
for f in flags:
|
||||
if not f:
|
||||
continue
|
||||
parsed_flags = env.ParseFlags(str(f))
|
||||
print parsed_flags
|
||||
for flag in parsed_flags.pop("CPPDEFINES"):
|
||||
if not isinstance(flag, list):
|
||||
env.Append(CPPDEFINES=flag)
|
||||
continue
|
||||
if '\"' in flag[1]:
|
||||
flag[1] = flag[1].replace('\"', '\\\"')
|
||||
env.Append(CPPDEFINES=[flag])
|
||||
env.Append(**parsed_flags)
|
||||
|
||||
# fix relative CPPPATH
|
||||
for i, p in enumerate(env.get("CPPPATH", [])):
|
||||
|
Reference in New Issue
Block a user