Fix relative include path for preprocessor using "build_flags" // Resolve #271

This commit is contained in:
Ivan Kravets
2015-11-27 21:15:09 +02:00
parent 304339e309
commit 221b7ed188
3 changed files with 21 additions and 15 deletions

View File

@ -18,6 +18,8 @@ PlatformIO 2.0
* Fixed configuration for LowPowerLab MoteinoMEGA board * Fixed configuration for LowPowerLab MoteinoMEGA board
(`issue #335 <https://github.com/platformio/platformio/issues/335>`_) (`issue #335 <https://github.com/platformio/platformio/issues/335>`_)
* Fixed "LockFailed: failed to create appstate.json.lock" error for Windows * Fixed "LockFailed: failed to create appstate.json.lock" error for Windows
* Fixed relative include path for preprocessor using ``build_flags``
(`issue #271 <https://github.com/platformio/platformio/issues/271>`_)
2.3.5 (2015-11-18) 2.3.5 (2015-11-18)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
VERSION = (2, 3, "6.dev1") VERSION = (2, 3, "6.dev2")
__version__ = ".".join([str(s) for s in VERSION]) __version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio" __title__ = "platformio"

View File

@ -15,7 +15,7 @@
import re import re
from glob import glob from glob import glob
from os import getenv, listdir, sep, walk from os import getenv, listdir, sep, walk
from os.path import basename, dirname, isdir, isfile, join, normpath from os.path import basename, dirname, isdir, isfile, join, normpath, realpath
from SCons.Script import (COMMAND_LINE_TARGETS, DefaultEnvironment, Exit, from SCons.Script import (COMMAND_LINE_TARGETS, DefaultEnvironment, Exit,
SConscript) SConscript)
@ -39,7 +39,11 @@ def BuildProgram(env):
ASCOM="$ASPPCOM" ASCOM="$ASPPCOM"
) )
env.ProcessFlags() env.ProcessFlags([
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags", None),
env.get("BUILD_FLAGS"),
getenv("PLATFORMIO_BUILD_FLAGS", None),
])
env.BuildFramework() env.BuildFramework()
# build dependent libs # build dependent libs
@ -62,10 +66,10 @@ def BuildProgram(env):
) )
# Handle SRC_BUILD_FLAGS # Handle SRC_BUILD_FLAGS
if getenv("PLATFORMIO_SRC_BUILD_FLAGS", None): env.ProcessFlags([
env.MergeFlags(getenv("PLATFORMIO_SRC_BUILD_FLAGS")) env.get("SRC_BUILD_FLAGS"),
if "SRC_BUILD_FLAGS" in env: getenv("PLATFORMIO_SRC_BUILD_FLAGS", None),
env.MergeFlags(env['SRC_BUILD_FLAGS']) ])
env.Append( env.Append(
CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format(
@ -83,15 +87,15 @@ def BuildProgram(env):
) )
def ProcessFlags(env): def ProcessFlags(env, flags):
if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}): for f in flags:
env.MergeFlags(env.subst("${BOARD_OPTIONS['build']['extra_flags']}")) if f:
env.MergeFlags(f)
# Handle BUILD_FLAGS # fix relative CPPPATH
if getenv("PLATFORMIO_BUILD_FLAGS", None): for i, p in enumerate(env.get("CPPPATH", [])):
env.MergeFlags(getenv("PLATFORMIO_BUILD_FLAGS")) if isdir(p):
if "BUILD_FLAGS" in env: env['CPPPATH'][i] = realpath(p)
env.MergeFlags(env['BUILD_FLAGS'])
# Cancel any previous definition of name, either built in or # Cancel any previous definition of name, either built in or
# provided with a -D option // Issue #191 # provided with a -D option // Issue #191