diff --git a/HISTORY.rst b/HISTORY.rst index cee52cd5da..46545814d5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,8 @@ PlatformIO 2.0 * Fixed configuration for LowPowerLab MoteinoMEGA board (`issue #335 `_) * Fixed "LockFailed: failed to create appstate.json.lock" error for Windows +* Fixed relative include path for preprocessor using ``build_flags`` + (`issue #271 `_) 2.3.5 (2015-11-18) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__init__.py b/platformio/__init__.py index 452e9841ef..7b30378b07 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (2, 3, "6.dev1") +VERSION = (2, 3, "6.dev2") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index c74ce530fc..ec98e587ec 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -15,7 +15,7 @@ import re from glob import glob 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, SConscript) @@ -39,7 +39,11 @@ def BuildProgram(env): 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() # build dependent libs @@ -62,10 +66,10 @@ def BuildProgram(env): ) # Handle SRC_BUILD_FLAGS - if getenv("PLATFORMIO_SRC_BUILD_FLAGS", None): - env.MergeFlags(getenv("PLATFORMIO_SRC_BUILD_FLAGS")) - if "SRC_BUILD_FLAGS" in env: - env.MergeFlags(env['SRC_BUILD_FLAGS']) + env.ProcessFlags([ + env.get("SRC_BUILD_FLAGS"), + getenv("PLATFORMIO_SRC_BUILD_FLAGS", None), + ]) env.Append( CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( @@ -83,15 +87,15 @@ def BuildProgram(env): ) -def ProcessFlags(env): - if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}): - env.MergeFlags(env.subst("${BOARD_OPTIONS['build']['extra_flags']}")) +def ProcessFlags(env, flags): + for f in flags: + if f: + env.MergeFlags(f) - # Handle BUILD_FLAGS - if getenv("PLATFORMIO_BUILD_FLAGS", None): - env.MergeFlags(getenv("PLATFORMIO_BUILD_FLAGS")) - if "BUILD_FLAGS" in env: - env.MergeFlags(env['BUILD_FLAGS']) + # fix relative CPPPATH + for i, p in enumerate(env.get("CPPPATH", [])): + if isdir(p): + env['CPPPATH'][i] = realpath(p) # Cancel any previous definition of name, either built in or # provided with a -D option // Issue #191