mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Better removing unnecessary flags using `build_unflags
` option // Resolve #698
This commit is contained in:
@@ -7,6 +7,8 @@ PlatformIO 2.0
|
|||||||
2.10.4 (2016-06-??)
|
2.10.4 (2016-06-??)
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
* Better removing unnecessary flags using ``build_unflags`` option
|
||||||
|
(`issue #698 <https://github.com/platformio/platformio/issues/698>`_)
|
||||||
* Fixed issue with ``platformio init --ide`` command for Python 2.6
|
* Fixed issue with ``platformio init --ide`` command for Python 2.6
|
||||||
|
|
||||||
2.10.3 (2016-06-15)
|
2.10.3 (2016-06-15)
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
VERSION = (2, 10, "4.dev0")
|
VERSION = (2, 10, "4.dev1")
|
||||||
__version__ = ".".join([str(s) for s in VERSION])
|
__version__ = ".".join([str(s) for s in VERSION])
|
||||||
|
|
||||||
__title__ = "platformio"
|
__title__ = "platformio"
|
||||||
|
@@ -40,8 +40,7 @@ env.Replace(
|
|||||||
"-fdata-sections",
|
"-fdata-sections",
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-mthumb",
|
"-mthumb",
|
||||||
"-mcpu=${BOARD_OPTIONS['build']['cpu']}",
|
"-mcpu=${BOARD_OPTIONS['build']['cpu']}"
|
||||||
"-nostdlib"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
CXXFLAGS=[
|
CXXFLAGS=[
|
||||||
@@ -57,7 +56,9 @@ env.Replace(
|
|||||||
"-Os",
|
"-Os",
|
||||||
"-Wl,--gc-sections,--relax",
|
"-Wl,--gc-sections,--relax",
|
||||||
"-mthumb",
|
"-mthumb",
|
||||||
"-mcpu=${BOARD_OPTIONS['build']['cpu']}"
|
"-mcpu=${BOARD_OPTIONS['build']['cpu']}",
|
||||||
|
"-nostdlib",
|
||||||
|
"-nostartfiles"
|
||||||
],
|
],
|
||||||
|
|
||||||
LIBS=["c", "gcc", "m"],
|
LIBS=["c", "gcc", "m"],
|
||||||
|
@@ -71,8 +71,7 @@ env.Replace(
|
|||||||
"-Wpointer-arith",
|
"-Wpointer-arith",
|
||||||
"-Wno-implicit-function-declaration",
|
"-Wno-implicit-function-declaration",
|
||||||
"-Wl,-EL",
|
"-Wl,-EL",
|
||||||
"-fno-inline-functions",
|
"-fno-inline-functions"
|
||||||
"-nostdlib"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
CCFLAGS=[
|
CCFLAGS=[
|
||||||
@@ -82,8 +81,7 @@ env.Replace(
|
|||||||
"-falign-functions=4",
|
"-falign-functions=4",
|
||||||
"-U__STRICT_ANSI__",
|
"-U__STRICT_ANSI__",
|
||||||
"-ffunction-sections",
|
"-ffunction-sections",
|
||||||
"-fdata-sections",
|
"-fdata-sections"
|
||||||
"-MMD" # output dependancy info
|
|
||||||
],
|
],
|
||||||
|
|
||||||
CXXFLAGS=[
|
CXXFLAGS=[
|
||||||
|
@@ -264,13 +264,12 @@ env.Replace(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# restore external build flags
|
# restore external build flags
|
||||||
env.ProcessFlags([
|
env.ProcessFlags(
|
||||||
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags")
|
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags"))
|
||||||
])
|
|
||||||
# remove base flags
|
# remove base flags
|
||||||
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
|
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
|
||||||
# apply user flags
|
# apply user flags
|
||||||
env.ProcessFlags([env.get("BUILD_FLAGS")])
|
env.ProcessFlags(env.get("BUILD_FLAGS"))
|
||||||
|
|
||||||
# Hook for K64F and K22F
|
# Hook for K64F and K22F
|
||||||
if board_type in ("frdm_k22f", "frdm_k64f"):
|
if board_type in ("frdm_k22f", "frdm_k64f"):
|
||||||
|
@@ -66,11 +66,6 @@ env.Append(
|
|||||||
],
|
],
|
||||||
|
|
||||||
LIBS=["stdc++", "nosys"],
|
LIBS=["stdc++", "nosys"],
|
||||||
|
|
||||||
LINKFLAGS=[
|
|
||||||
"-nostartfiles",
|
|
||||||
"-nostdlib"
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -31,13 +31,6 @@ env.Replace(
|
|||||||
UPLOADCMD='"$UPLOADER" $SOURCES'
|
UPLOADCMD='"$UPLOADER" $SOURCES'
|
||||||
)
|
)
|
||||||
|
|
||||||
env.Append(
|
|
||||||
LINKFLAGS=[
|
|
||||||
"-nostartfiles",
|
|
||||||
"-nostdlib"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
@@ -53,13 +53,12 @@ def BuildProgram(env):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# process extra flags from board
|
# process extra flags from board
|
||||||
env.ProcessFlags([
|
env.ProcessFlags(
|
||||||
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags")
|
env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags"))
|
||||||
])
|
|
||||||
# remove base flags
|
# remove base flags
|
||||||
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
|
env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
|
||||||
# apply user flags
|
# apply user flags
|
||||||
env.ProcessFlags([env.get("BUILD_FLAGS")])
|
env.ProcessFlags(env.get("BUILD_FLAGS"))
|
||||||
|
|
||||||
if env.get("FRAMEWORK"):
|
if env.get("FRAMEWORK"):
|
||||||
env.BuildFrameworks([
|
env.BuildFrameworks([
|
||||||
@@ -88,7 +87,7 @@ def BuildProgram(env):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Handle SRC_BUILD_FLAGS
|
# Handle SRC_BUILD_FLAGS
|
||||||
env.ProcessFlags([env.get("SRC_BUILD_FLAGS", None)])
|
env.ProcessFlags(env.get("SRC_BUILD_FLAGS"))
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
CPPPATH=["$PROJECTSRC_DIR"],
|
CPPPATH=["$PROJECTSRC_DIR"],
|
||||||
@@ -117,18 +116,17 @@ def BuildProgram(env):
|
|||||||
|
|
||||||
|
|
||||||
def ProcessFlags(env, flags):
|
def ProcessFlags(env, flags):
|
||||||
for f in flags:
|
if not flags:
|
||||||
if not f:
|
return
|
||||||
|
parsed_flags = env.ParseFlags(str(flags))
|
||||||
|
for flag in parsed_flags.pop("CPPDEFINES"):
|
||||||
|
if not isinstance(flag, list):
|
||||||
|
env.Append(CPPDEFINES=flag)
|
||||||
continue
|
continue
|
||||||
parsed_flags = env.ParseFlags(str(f))
|
if '\"' in flag[1]:
|
||||||
for flag in parsed_flags.pop("CPPDEFINES"):
|
flag[1] = flag[1].replace('\"', '\\\"')
|
||||||
if not isinstance(flag, list):
|
env.Append(CPPDEFINES=[flag])
|
||||||
env.Append(CPPDEFINES=flag)
|
env.Append(**parsed_flags)
|
||||||
continue
|
|
||||||
if '\"' in flag[1]:
|
|
||||||
flag[1] = flag[1].replace('\"', '\\\"')
|
|
||||||
env.Append(CPPDEFINES=[flag])
|
|
||||||
env.Append(**parsed_flags)
|
|
||||||
|
|
||||||
# fix relative CPPPATH & LIBPATH
|
# fix relative CPPPATH & LIBPATH
|
||||||
for k in ("CPPPATH", "LIBPATH"):
|
for k in ("CPPPATH", "LIBPATH"):
|
||||||
@@ -153,10 +151,17 @@ def ProcessFlags(env, flags):
|
|||||||
def ProcessUnFlags(env, flags):
|
def ProcessUnFlags(env, flags):
|
||||||
if not flags:
|
if not flags:
|
||||||
return
|
return
|
||||||
for var, values in env.ParseFlags(flags).items():
|
parsed_flags = env.ParseFlags(flags)
|
||||||
for v in values:
|
all_flags = []
|
||||||
if v in env[var]:
|
for items in parsed_flags.values():
|
||||||
env[var].remove(v)
|
all_flags.extend(items)
|
||||||
|
all_flags = set(all_flags)
|
||||||
|
|
||||||
|
for key in parsed_flags.keys():
|
||||||
|
cur_flags = set(env.get(key, []))
|
||||||
|
common = cur_flags & all_flags
|
||||||
|
for item in common:
|
||||||
|
env[key].remove(item)
|
||||||
|
|
||||||
|
|
||||||
def IsFileWithExt(env, file_, ext): # pylint: disable=W0613
|
def IsFileWithExt(env, file_, ext): # pylint: disable=W0613
|
||||||
|
Reference in New Issue
Block a user