mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Refactor CORELIBS per platform
This commit is contained in:
@ -217,6 +217,8 @@ base template of ``test-builder.py``.
|
|||||||
|
|
||||||
CPPDEFINES=["DEFINE_1", "DEFINE=2", "DEFINE_N"],
|
CPPDEFINES=["DEFINE_1", "DEFINE=2", "DEFINE_N"],
|
||||||
|
|
||||||
|
LIBS=["additional", "libs", "here"],
|
||||||
|
|
||||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-bar", "uploader"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "tool-bar", "uploader"),
|
||||||
UPLOADCMD="$UPLOADER $SOURCES"
|
UPLOADCMD="$UPLOADER $SOURCES"
|
||||||
)
|
)
|
||||||
@ -238,12 +240,10 @@ base template of ``test-builder.py``.
|
|||||||
# The source code of "platformio-build-tool" is here
|
# The source code of "platformio-build-tool" is here
|
||||||
# https://github.com/ivankravets/platformio/blob/develop/platformio/builder/tools/platformio.py
|
# https://github.com/ivankravets/platformio/blob/develop/platformio/builder/tools/platformio.py
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
target_elf = env.BuildFirmware(CORELIBS + ["additional", "libs", "here"])
|
target_elf = env.BuildFirmware()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build the .bin file
|
# Target: Build the .bin file
|
||||||
|
@ -82,13 +82,11 @@ else:
|
|||||||
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
target_elf = env.BuildFirmware()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Extract EEPROM data (from EEMEM directive) to .eep file
|
# Target: Extract EEPROM data (from EEMEM directive) to .eep file
|
||||||
|
@ -68,13 +68,11 @@ env.Append(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
target_elf = env.BuildFirmware(["m", "gcc"] + CORELIBS)
|
target_elf = env.BuildFirmware()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build the .bin file
|
# Target: Build the .bin file
|
||||||
|
@ -50,16 +50,15 @@ env.Replace(
|
|||||||
"-mcpu=${BOARD_OPTIONS['build']['cpu']}"
|
"-mcpu=${BOARD_OPTIONS['build']['cpu']}"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
LIBS=["c", "gcc", "m"],
|
||||||
|
|
||||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
|
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
|
||||||
)
|
)
|
||||||
|
|
||||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu", "")[-2:] == "m4":
|
if env.get("BOARD_OPTIONS", {}).get("build", {}).get(
|
||||||
|
"cpu", "")[-2:] == "m4" and env.get("BOARD") != "frdm_k20d50m":
|
||||||
env.Append(
|
env.Append(
|
||||||
ASFLAGS=[
|
CPPFLAGS=[
|
||||||
"-mfloat-abi=hard",
|
|
||||||
"-mfpu=fpv4-sp-d16"
|
|
||||||
],
|
|
||||||
CCFLAGS=[
|
|
||||||
"-mfloat-abi=hard",
|
"-mfloat-abi=hard",
|
||||||
"-mfpu=fpv4-sp-d16",
|
"-mfpu=fpv4-sp-d16",
|
||||||
"-fsingle-precision-constant"
|
"-fsingle-precision-constant"
|
||||||
|
@ -47,6 +47,8 @@ env.Replace(
|
|||||||
"-Wl,--gc-sections"
|
"-Wl,--gc-sections"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
LIBS=["m"],
|
||||||
|
|
||||||
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
|
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
from os import listdir, walk
|
from os import listdir, walk
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment, Return
|
from SCons.Script import DefaultEnvironment
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -178,4 +178,4 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam":
|
|||||||
join("$PLATFORMFW_DIR", "system", "libsam", "source")
|
join("$PLATFORMFW_DIR", "system", "libsam", "source")
|
||||||
))
|
))
|
||||||
|
|
||||||
Return("libs")
|
env.Append(LIBS=libs)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment, Return
|
from SCons.Script import DefaultEnvironment
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -39,4 +39,4 @@ libs.append(envsafe.BuildLibrary(
|
|||||||
join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}")
|
join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}")
|
||||||
))
|
))
|
||||||
|
|
||||||
Return("libs")
|
env.Append(LIBS=libs)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment, Return
|
from SCons.Script import DefaultEnvironment
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -52,4 +52,4 @@ libs.append(env.BuildLibrary(
|
|||||||
join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}")
|
join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}")
|
||||||
))
|
))
|
||||||
|
|
||||||
Return("libs")
|
env.Append(LIBS=libs)
|
||||||
|
@ -9,7 +9,7 @@ import re
|
|||||||
from os import listdir, sep, walk
|
from os import listdir, sep, walk
|
||||||
from os.path import isfile, join, normpath
|
from os.path import isfile, join, normpath
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment, Return
|
from SCons.Script import DefaultEnvironment
|
||||||
|
|
||||||
from platformio.util import exec_command
|
from platformio.util import exec_command
|
||||||
|
|
||||||
@ -168,4 +168,4 @@ libs.append(env.Library(
|
|||||||
get_source_files(root_dir)
|
get_source_files(root_dir)
|
||||||
))
|
))
|
||||||
|
|
||||||
Return("libs")
|
env.Append(LIBS=libs)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import DefaultEnvironment, Return
|
from SCons.Script import DefaultEnvironment
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -61,4 +61,4 @@ libs.append(envsafe.BuildLibrary(
|
|||||||
ignore_files
|
ignore_files
|
||||||
))
|
))
|
||||||
|
|
||||||
Return("libs")
|
env.Append(LIBS=libs)
|
||||||
|
@ -53,13 +53,11 @@ else:
|
|||||||
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS'
|
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS'
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
target_elf = env.BuildFirmware()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build the firmware file
|
# Target: Build the firmware file
|
||||||
|
@ -48,6 +48,8 @@ env.Replace(
|
|||||||
"-Wl,-gc-sections,-u,main"
|
"-Wl,-gc-sections,-u,main"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
LIBS=["m"],
|
||||||
|
|
||||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
|
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
|
||||||
|
|
||||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-mspdebug", "mspdebug"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "tool-mspdebug", "mspdebug"),
|
||||||
@ -74,13 +76,11 @@ env.Append(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
target_elf = env.BuildFirmware()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build the .hex
|
# Target: Build the .hex
|
||||||
|
@ -27,13 +27,11 @@ env.Append(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
target_elf = env.BuildFirmware(["c", "gcc", "m"] + CORELIBS)
|
target_elf = env.BuildFirmware()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build the .bin file
|
# Target: Build the .bin file
|
||||||
|
@ -10,7 +10,7 @@ from SCons.Script import SConscript, SConscriptChdir
|
|||||||
from SCons.Util import case_sensitive_suffixes
|
from SCons.Util import case_sensitive_suffixes
|
||||||
|
|
||||||
|
|
||||||
def ProcessGeneral(env):
|
def BuildFirmware(env):
|
||||||
# fix ASM handling under non-casitive OS
|
# fix ASM handling under non-casitive OS
|
||||||
if not case_sensitive_suffixes('.s', '.S'):
|
if not case_sensitive_suffixes('.s', '.S'):
|
||||||
env.Replace(
|
env.Replace(
|
||||||
@ -24,20 +24,8 @@ def ProcessGeneral(env):
|
|||||||
if "BUILD_FLAGS" in env:
|
if "BUILD_FLAGS" in env:
|
||||||
env.MergeFlags(env['BUILD_FLAGS'])
|
env.MergeFlags(env['BUILD_FLAGS'])
|
||||||
|
|
||||||
corelibs = []
|
env.BuildFramework()
|
||||||
if "FRAMEWORK" in env:
|
|
||||||
if env['FRAMEWORK'] in ("arduino", "energia"):
|
|
||||||
env.ConvertInoToCpp()
|
|
||||||
for f in env['FRAMEWORK'].split(","):
|
|
||||||
SConscriptChdir(0)
|
|
||||||
corelibs += SConscript(
|
|
||||||
env.subst(join("$PIOBUILDER_DIR", "scripts", "frameworks",
|
|
||||||
"%s.py" % f.strip().lower()))
|
|
||||||
)
|
|
||||||
return corelibs
|
|
||||||
|
|
||||||
|
|
||||||
def BuildFirmware(env, corelibs):
|
|
||||||
firmenv = env.Clone()
|
firmenv = env.Clone()
|
||||||
vdirs = firmenv.VariantDirRecursive(
|
vdirs = firmenv.VariantDirRecursive(
|
||||||
join("$BUILD_DIR", "src"), "$PROJECTSRC_DIR")
|
join("$BUILD_DIR", "src"), "$PROJECTSRC_DIR")
|
||||||
@ -59,12 +47,15 @@ def BuildFirmware(env, corelibs):
|
|||||||
_LIBFLAGS=" -Wl,--end-group"
|
_LIBFLAGS=" -Wl,--end-group"
|
||||||
)
|
)
|
||||||
|
|
||||||
firmenv.MergeFlags(getenv("PLATFORMIO_SRCBUILD_FLAGS", "$SRCBUILD_FLAGS"))
|
_srcbuild_flags = getenv("PLATFORMIO_SRCBUILD_FLAGS",
|
||||||
|
env.subst("$SRCBUILD_FLAGS"))
|
||||||
|
if _srcbuild_flags:
|
||||||
|
firmenv.MergeFlags(_srcbuild_flags)
|
||||||
|
|
||||||
return firmenv.Program(
|
return firmenv.Program(
|
||||||
join("$BUILD_DIR", "firmware"),
|
join("$BUILD_DIR", "firmware"),
|
||||||
[firmenv.GlobCXXFiles(vdir) for vdir in vdirs],
|
[firmenv.GlobCXXFiles(vdir) for vdir in vdirs],
|
||||||
LIBS=corelibs + deplibs,
|
LIBS=env.get("LIBS") + deplibs,
|
||||||
LIBPATH="$BUILD_DIR",
|
LIBPATH="$BUILD_DIR",
|
||||||
PROGSUFFIX=".elf"
|
PROGSUFFIX=".elf"
|
||||||
)
|
)
|
||||||
@ -95,6 +86,21 @@ def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True,
|
|||||||
return variants
|
return variants
|
||||||
|
|
||||||
|
|
||||||
|
def BuildFramework(env):
|
||||||
|
if "FRAMEWORK" not in env:
|
||||||
|
return
|
||||||
|
|
||||||
|
if env['FRAMEWORK'].lower() in ("arduino", "energia"):
|
||||||
|
env.ConvertInoToCpp()
|
||||||
|
|
||||||
|
for f in env['FRAMEWORK'].split(","):
|
||||||
|
SConscriptChdir(0)
|
||||||
|
SConscript(
|
||||||
|
env.subst(join("$PIOBUILDER_DIR", "scripts", "frameworks",
|
||||||
|
"%s.py" % f.strip().lower()))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def BuildLibrary(env, variant_dir, library_dir, ignore_files=None):
|
def BuildLibrary(env, variant_dir, library_dir, ignore_files=None):
|
||||||
lib = env.Clone()
|
lib = env.Clone()
|
||||||
vdirs = lib.VariantDirRecursive(
|
vdirs = lib.VariantDirRecursive(
|
||||||
@ -303,10 +309,10 @@ def exists(_):
|
|||||||
|
|
||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
env.AddMethod(ProcessGeneral)
|
|
||||||
env.AddMethod(BuildFirmware)
|
env.AddMethod(BuildFirmware)
|
||||||
env.AddMethod(GlobCXXFiles)
|
env.AddMethod(GlobCXXFiles)
|
||||||
env.AddMethod(VariantDirRecursive)
|
env.AddMethod(VariantDirRecursive)
|
||||||
|
env.AddMethod(BuildFramework)
|
||||||
env.AddMethod(BuildLibrary)
|
env.AddMethod(BuildLibrary)
|
||||||
env.AddMethod(BuildDependentLibraries)
|
env.AddMethod(BuildDependentLibraries)
|
||||||
env.AddMethod(ConvertInoToCpp)
|
env.AddMethod(ConvertInoToCpp)
|
||||||
|
Reference in New Issue
Block a user