forked from platformio/platformio-core
Implemented especially for SmartAnthill "$ platformio run -t uploadlazy" target (no dependencies to framework libs, ELF and etc.)
This commit is contained in:
@ -8,8 +8,10 @@
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||
DefaultEnvironment, Exit, SConscript,
|
||||
SConscriptChdir)
|
||||
DefaultEnvironment, Exit)
|
||||
|
||||
from platformio.util import reset_serialport
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
@ -66,9 +68,6 @@ env.Replace(
|
||||
UPLOADEEPCMD="$UPLOADER $UPLOADERFLAGS -U eeprom:w:$SOURCES:i"
|
||||
)
|
||||
|
||||
if "BUILD_FLAGS" in env:
|
||||
env.MergeFlags(env['BUILD_FLAGS'])
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToEep=Builder(
|
||||
@ -101,23 +100,7 @@ env.Append(
|
||||
)
|
||||
)
|
||||
|
||||
env.PrependENVPath(
|
||||
"PATH",
|
||||
join(env.subst("$PLATFORMTOOLS_DIR"), "toolchain", "bin")
|
||||
)
|
||||
|
||||
BUILT_LIBS = []
|
||||
|
||||
#
|
||||
# Process framework script
|
||||
#
|
||||
|
||||
if "FRAMEWORK" in env:
|
||||
SConscriptChdir(0)
|
||||
flibs = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts",
|
||||
"frameworks", "${FRAMEWORK}.py")),
|
||||
exports="env")
|
||||
BUILT_LIBS += flibs
|
||||
BUILT_LIBS = env.ProcessGeneral()
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
@ -129,39 +112,48 @@ target_elf = env.BuildFirmware(BUILT_LIBS + ["m"])
|
||||
# Target: Extract EEPROM data (from EEMEM directive) to .eep file
|
||||
#
|
||||
|
||||
target_eep = env.ElfToEep(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
target_eep = env.Alias("eep", env.ElfToEep(join("$BUILD_DIR", "firmware"),
|
||||
target_elf))
|
||||
|
||||
#
|
||||
# Target: Build the .hex file
|
||||
#
|
||||
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Upload by default .hex file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, [
|
||||
lambda target, source, env: reset_serialport(env.subst("$UPLOAD_PORT")),
|
||||
"$UPLOADHEXCMD"])
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Upload .eep file
|
||||
#
|
||||
|
||||
eep = env.Alias("eep", target_eep, [
|
||||
lambda target, source, env: env.ResetDevice(), "$UPLOADEEPCMD"])
|
||||
AlwaysBuild(eep)
|
||||
uploadeep = env.Alias("uploadeep", target_eep, [
|
||||
lambda target, source, env: reset_serialport(env.subst("$UPLOAD_PORT")),
|
||||
"$UPLOADEEPCMD"])
|
||||
AlwaysBuild(uploadeep)
|
||||
|
||||
#
|
||||
# Target: Upload .hex file
|
||||
# Check for $UPLOAD_PORT variable
|
||||
#
|
||||
|
||||
upload = env.Alias("upload", target_hex, [
|
||||
lambda target, source, env: env.ResetDevice(), "$UPLOADHEXCMD"])
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
env.Alias("build-eep", [target_eep])
|
||||
Default([target_elf, target_hex])
|
||||
|
||||
# check for $UPLOAD_PORT variable
|
||||
is_uptarget = ("eep" in COMMAND_LINE_TARGETS or "upload" in
|
||||
COMMAND_LINE_TARGETS)
|
||||
is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) &
|
||||
set(COMMAND_LINE_TARGETS))
|
||||
if is_uptarget and not env.subst("$UPLOAD_PORT"):
|
||||
Exit("Please specify 'upload_port'")
|
||||
Exit("Please specify environment 'upload_port' or use global "
|
||||
"--upload-port option.")
|
||||
|
||||
#
|
||||
# Setup default targets
|
||||
#
|
||||
|
||||
Default(target_hex)
|
||||
|
@ -8,11 +8,12 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (AlwaysBuild, Builder, Default, DefaultEnvironment,
|
||||
SConscript, SConscriptChdir)
|
||||
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||
DefaultEnvironment)
|
||||
|
||||
from platformio.util import get_system
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
env.Replace(
|
||||
@ -60,9 +61,6 @@ env.Replace(
|
||||
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"'
|
||||
)
|
||||
|
||||
if "BUILD_FLAGS" in env:
|
||||
env.MergeFlags(env['BUILD_FLAGS'])
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToHex=Builder(
|
||||
@ -79,24 +77,7 @@ env.Append(
|
||||
)
|
||||
)
|
||||
|
||||
env.PrependENVPath(
|
||||
"PATH",
|
||||
join(env.subst("$PLATFORMTOOLS_DIR"), "toolchain", "bin")
|
||||
)
|
||||
|
||||
BUILT_LIBS = []
|
||||
|
||||
#
|
||||
# Process framework script
|
||||
#
|
||||
|
||||
if "FRAMEWORK" in env:
|
||||
SConscriptChdir(0)
|
||||
flibs = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts",
|
||||
"frameworks", "${FRAMEWORK}.py")),
|
||||
exports="env")
|
||||
BUILT_LIBS += flibs
|
||||
|
||||
BUILT_LIBS = env.ProcessGeneral()
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
@ -108,17 +89,20 @@ target_elf = env.BuildFirmware(BUILT_LIBS + ["m"])
|
||||
# Target: Build the .hex
|
||||
#
|
||||
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Upload firmware
|
||||
#
|
||||
|
||||
upload = env.Alias("upload", target_hex, ["$UPLOADCMD"])
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, "$UPLOADCMD")
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_elf, target_hex])
|
||||
Default(target_hex)
|
||||
|
@ -8,8 +8,9 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (AlwaysBuild, Builder, Default, DefaultEnvironment,
|
||||
SConscript, SConscriptChdir)
|
||||
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||
DefaultEnvironment)
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
@ -75,9 +76,6 @@ env.Replace(
|
||||
UPLOADCMD="$UPLOADER $SOURCES"
|
||||
)
|
||||
|
||||
if "BUILD_FLAGS" in env:
|
||||
env.MergeFlags(env['BUILD_FLAGS'])
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToBin=Builder(
|
||||
@ -87,28 +85,12 @@ env.Append(
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".hex"
|
||||
suffix=".bin"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
env.PrependENVPath(
|
||||
"PATH",
|
||||
join(env.subst("$PLATFORMTOOLS_DIR"), "toolchain", "bin")
|
||||
)
|
||||
|
||||
BUILT_LIBS = []
|
||||
|
||||
#
|
||||
# Process framework script
|
||||
#
|
||||
|
||||
if "FRAMEWORK" in env:
|
||||
SConscriptChdir(0)
|
||||
flibs = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts",
|
||||
"frameworks", "${FRAMEWORK}.py")),
|
||||
exports="env")
|
||||
BUILT_LIBS += flibs
|
||||
BUILT_LIBS = env.ProcessGeneral()
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
@ -120,17 +102,20 @@ target_elf = env.BuildFirmware(BUILT_LIBS + ["c", "gcc", "m"])
|
||||
# Target: Build the .bin file
|
||||
#
|
||||
|
||||
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Upload firmware
|
||||
#
|
||||
|
||||
upload = env.Alias("upload", target_bin, ["$UPLOADCMD"])
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, "$UPLOADCMD")
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_elf, target_bin])
|
||||
Default(target_bin)
|
||||
|
@ -2,8 +2,28 @@
|
||||
# See LICENSE for details.
|
||||
|
||||
import re
|
||||
from os import getenv, listdir, walk
|
||||
from os.path import isdir, isfile, join
|
||||
|
||||
from SCons.Script import SConscript, SConscriptChdir
|
||||
|
||||
|
||||
def ProcessGeneral(env):
|
||||
libs = []
|
||||
if "BUILD_FLAGS" in env:
|
||||
env.MergeFlags(env['BUILD_FLAGS'])
|
||||
|
||||
env.PrependENVPath(
|
||||
"PATH",
|
||||
join(env.subst("$PLATFORMTOOLS_DIR"), "toolchain", "bin")
|
||||
)
|
||||
|
||||
if "FRAMEWORK" in env:
|
||||
SConscriptChdir(0)
|
||||
libs = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts",
|
||||
"frameworks", "${FRAMEWORK}.py")),
|
||||
exports="env")
|
||||
return libs
|
||||
|
||||
|
||||
def BuildLibrary(env, variant_dir, library_dir):
|
||||
@ -120,6 +140,7 @@ def exists(_):
|
||||
|
||||
|
||||
def generate(env):
|
||||
env.AddMethod(ProcessGeneral)
|
||||
env.AddMethod(BuildLibrary)
|
||||
env.AddMethod(BuildDependentLibraries)
|
||||
env.AddMethod(BuildFirmware)
|
||||
|
Reference in New Issue
Block a user