Skip to content

Commit

Permalink
Fix relative include path for preprocessor using "build_flags" // Res…
Browse files Browse the repository at this point in the history
…olve #271
  • Loading branch information
ivankravets committed Nov 27, 2015
1 parent 304339e commit 221b7ed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PlatformIO 2.0
* Fixed configuration for LowPowerLab MoteinoMEGA board
(`issue #335 <https://github.com/platformio/platformio/issues/335>`_)
* 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)
~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion platformio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
32 changes: 18 additions & 14 deletions platformio/builder/tools/platformio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 221b7ed

Please sign in to comment.