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 os.path import join
|
||||||
|
|
||||||
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||||
DefaultEnvironment, Exit, SConscript,
|
DefaultEnvironment, Exit)
|
||||||
SConscriptChdir)
|
|
||||||
|
from platformio.util import reset_serialport
|
||||||
|
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -66,9 +68,6 @@ env.Replace(
|
|||||||
UPLOADEEPCMD="$UPLOADER $UPLOADERFLAGS -U eeprom:w:$SOURCES:i"
|
UPLOADEEPCMD="$UPLOADER $UPLOADERFLAGS -U eeprom:w:$SOURCES:i"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "BUILD_FLAGS" in env:
|
|
||||||
env.MergeFlags(env['BUILD_FLAGS'])
|
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
BUILDERS=dict(
|
BUILDERS=dict(
|
||||||
ElfToEep=Builder(
|
ElfToEep=Builder(
|
||||||
@ -101,23 +100,7 @@ env.Append(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
env.PrependENVPath(
|
BUILT_LIBS = env.ProcessGeneral()
|
||||||
"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
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# 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: 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: 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
|
# Target: Upload .eep file
|
||||||
#
|
#
|
||||||
|
|
||||||
eep = env.Alias("eep", target_eep, [
|
uploadeep = env.Alias("uploadeep", target_eep, [
|
||||||
lambda target, source, env: env.ResetDevice(), "$UPLOADEEPCMD"])
|
lambda target, source, env: reset_serialport(env.subst("$UPLOAD_PORT")),
|
||||||
AlwaysBuild(eep)
|
"$UPLOADEEPCMD"])
|
||||||
|
AlwaysBuild(uploadeep)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Upload .hex file
|
# Check for $UPLOAD_PORT variable
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias("upload", target_hex, [
|
is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) &
|
||||||
lambda target, source, env: env.ResetDevice(), "$UPLOADHEXCMD"])
|
set(COMMAND_LINE_TARGETS))
|
||||||
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)
|
|
||||||
if is_uptarget and not env.subst("$UPLOAD_PORT"):
|
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 os.path import join
|
||||||
|
|
||||||
from SCons.Script import (AlwaysBuild, Builder, Default, DefaultEnvironment,
|
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||||
SConscript, SConscriptChdir)
|
DefaultEnvironment)
|
||||||
|
|
||||||
from platformio.util import get_system
|
from platformio.util import get_system
|
||||||
|
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
@ -60,9 +61,6 @@ env.Replace(
|
|||||||
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"'
|
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"'
|
||||||
)
|
)
|
||||||
|
|
||||||
if "BUILD_FLAGS" in env:
|
|
||||||
env.MergeFlags(env['BUILD_FLAGS'])
|
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
BUILDERS=dict(
|
BUILDERS=dict(
|
||||||
ElfToHex=Builder(
|
ElfToHex=Builder(
|
||||||
@ -79,24 +77,7 @@ env.Append(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
env.PrependENVPath(
|
BUILT_LIBS = env.ProcessGeneral()
|
||||||
"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
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# Target: Build executable and linkable firmware
|
||||||
@ -108,17 +89,20 @@ target_elf = env.BuildFirmware(BUILT_LIBS + ["m"])
|
|||||||
# Target: Build the .hex
|
# 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
|
# Target: Upload firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias("upload", target_hex, ["$UPLOADCMD"])
|
upload = env.Alias(["upload", "uploadlazy"], target_hex, "$UPLOADCMD")
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# Target: Define targets
|
||||||
#
|
#
|
||||||
|
|
||||||
Default([target_elf, target_hex])
|
Default(target_hex)
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import (AlwaysBuild, Builder, Default, DefaultEnvironment,
|
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
|
||||||
SConscript, SConscriptChdir)
|
DefaultEnvironment)
|
||||||
|
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
@ -75,9 +76,6 @@ env.Replace(
|
|||||||
UPLOADCMD="$UPLOADER $SOURCES"
|
UPLOADCMD="$UPLOADER $SOURCES"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "BUILD_FLAGS" in env:
|
|
||||||
env.MergeFlags(env['BUILD_FLAGS'])
|
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
BUILDERS=dict(
|
BUILDERS=dict(
|
||||||
ElfToBin=Builder(
|
ElfToBin=Builder(
|
||||||
@ -87,28 +85,12 @@ env.Append(
|
|||||||
"binary",
|
"binary",
|
||||||
"$SOURCES",
|
"$SOURCES",
|
||||||
"$TARGET"]),
|
"$TARGET"]),
|
||||||
suffix=".hex"
|
suffix=".bin"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
env.PrependENVPath(
|
BUILT_LIBS = env.ProcessGeneral()
|
||||||
"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
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# 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: 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
|
# Target: Upload firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias("upload", target_bin, ["$UPLOADCMD"])
|
upload = env.Alias(["upload", "uploadlazy"], target_bin, "$UPLOADCMD")
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# Target: Define targets
|
||||||
#
|
#
|
||||||
|
|
||||||
Default([target_elf, target_bin])
|
Default(target_bin)
|
||||||
|
@ -2,8 +2,28 @@
|
|||||||
# See LICENSE for details.
|
# See LICENSE for details.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from os import getenv, listdir, walk
|
||||||
from os.path import isdir, isfile, join
|
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):
|
def BuildLibrary(env, variant_dir, library_dir):
|
||||||
@ -120,6 +140,7 @@ def exists(_):
|
|||||||
|
|
||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
|
env.AddMethod(ProcessGeneral)
|
||||||
env.AddMethod(BuildLibrary)
|
env.AddMethod(BuildLibrary)
|
||||||
env.AddMethod(BuildDependentLibraries)
|
env.AddMethod(BuildDependentLibraries)
|
||||||
env.AddMethod(BuildFirmware)
|
env.AddMethod(BuildFirmware)
|
||||||
|
Reference in New Issue
Block a user