Пример #1
0
def BuildProgram(env):
    def _append_pio_macros():
        env.AppendUnique(CPPDEFINES=[("PLATFORMIO",
                                      int("{0:02d}{1:02d}{2:02d}".format(
                                          *pioversion_to_intstr())))])

    _append_pio_macros()

    env.PrintConfiguration()

    # fix ASM handling under non case-sensitive OS
    if not Util.case_sensitive_suffixes(".s", ".S"):
        env.Replace(AS="$CC", ASCOM="$ASPPCOM")

    if set(["__debug", "debug"]) & set(COMMAND_LINE_TARGETS):
        env.ProcessDebug()

    # process extra flags from board
    if "BOARD" in env and "build.extra_flags" in env.BoardConfig():
        env.ProcessFlags(env.BoardConfig().get("build.extra_flags"))

    # apply user flags
    env.ProcessFlags(env.get("BUILD_FLAGS"))

    # process framework scripts
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))

    # restore PIO macros if it was deleted by framework
    _append_pio_macros()

    # remove specified flags
    env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))

    if "__test" in COMMAND_LINE_TARGETS:
        env.ProcessTest()

    # build project with dependencies
    _build_project_deps(env)

    # append into the beginning a main LD script
    if (env.get("LDSCRIPT_PATH")
            and not any("-Wl,-T" in f for f in env['LINKFLAGS'])):
        env.Prepend(LINKFLAGS=["-T", "$LDSCRIPT_PATH"])

    # enable "cyclic reference" for linker
    if env.get("LIBS") and env.GetCompilerType() == "gcc":
        env.Prepend(_LIBFLAGS="-Wl,--start-group ")
        env.Append(_LIBFLAGS=" -Wl,--end-group")

    program = env.Program(join("$BUILD_DIR", env.subst("$PROGNAME")),
                          env['PIOBUILDFILES'])
    env.Replace(PIOMAINPROG=program)

    AlwaysBuild(
        env.Alias(
            "checkprogsize", program,
            env.VerboseAction(env.CheckUploadSize,
                              "Checking size $PIOMAINPROG")))

    return program
Пример #2
0
def BuildProgram(env):
    env.ProcessProgramDeps()
    env.ProcessProjectDeps()

    # append into the beginning a main LD script
    if env.get("LDSCRIPT_PATH") and not any("-Wl,-T" in f
                                            for f in env["LINKFLAGS"]):
        env.Prepend(LINKFLAGS=["-T", env.subst("$LDSCRIPT_PATH")])

    # enable "cyclic reference" for linker
    if (env.get("LIBS") and env.GetCompilerType() == "gcc"
            and (env.PioPlatform().is_embedded() or not MACOS)):
        env.Prepend(_LIBFLAGS="-Wl,--start-group ")
        env.Append(_LIBFLAGS=" -Wl,--end-group")

    program = env.Program(os.path.join("$BUILD_DIR", env.subst("$PROGNAME")),
                          env["PIOBUILDFILES"])
    env.Replace(PIOMAINPROG=program)

    AlwaysBuild(
        env.Alias(
            "checkprogsize",
            program,
            env.VerboseAction(env.CheckUploadSize,
                              "Checking size $PIOMAINPROG"),
        ))

    print("Building in %s mode" % env.GetBuildType())

    return program
Пример #3
0
    def __call__(self, env, libraries):
        if not self._add_dependents:
            logger.warn(
                "BoostSharedLibrary() is deprecated, use BoostSharedLibs() or BoostSharedLib() instead"
            )
        libraries = Flatten([libraries])

        if not 'boost' in env['BUILD_WITH']:
            env.BuildWith('boost')
        Boost = env['dependencies']['boost'](env)

        for library in libraries:
            if library.startswith('log'):
                env.AppendUnique(CPPDEFINES='BOOST_LOG_DYN_LINK')
            elif library == 'chrono':
                env.AppendUnique(CPPDEFINES='BOOST_CHRONO_DYN_LINK')
            elif library == 'filesystem':
                env.AppendUnique(CPPDEFINES='BOOST_FILESYSTEM_DYN_LINK')
            elif library == 'date_time':
                env.AppendUnique(CPPDEFINES='BOOST_DATE_TIME_DYN_LINK')
            elif library == 'regex':
                env.AppendUnique(CPPDEFINES='BOOST_REGEX_DYN_LINK')
            elif library == 'system':
                env.AppendUnique(CPPDEFINES='BOOST_SYSTEM_DYN_LINK')

        library = BoostLibraryBuilder(Boost,
                                      add_dependents=self._add_dependents,
                                      verbose_build=self._verbose_build,
                                      verbose_config=self._verbose_config)(
                                          env, None, None, libraries, 'shared')
        if self._build_always:
            return AlwaysBuild(library)
        else:
            return library
Пример #4
0
 def __call__(self, env, library):
     if not 'boost' in env['BUILD_WITH']:
         env.BuildWith('boost')
     Boost = env['dependencies']['boost']
     library = BoostLibraryBuilder(Boost,
                                   verbose=self._verbose)(env, None, None,
                                                          library, 'shared')
     if self._build_once:
         return library
     else:
         return AlwaysBuild(library)
Пример #5
0
 def AddPlatformTarget(
     env,
     name,
     dependencies,
     actions,
     title=None,
     description=None,
     always_build=True,
 ):
     target = env.Alias(name, dependencies, actions)
     if always_build:
         AlwaysBuild(target)
     return target
Пример #6
0
def AddTarget(  # pylint: disable=too-many-arguments
    env,
    name,
    dependencies,
    actions,
    title=None,
    description=None,
    group="Generic",
    always_build=True,
):
    if "__PIO_TARGETS" not in env:
        env["__PIO_TARGETS"] = {}
    assert name not in env["__PIO_TARGETS"]
    env["__PIO_TARGETS"][name] = dict(name=name,
                                      title=title,
                                      description=description,
                                      group=group)
    target = env.Alias(name, dependencies, actions)
    if always_build:
        AlwaysBuild(target)
    return target
Пример #7
0
    def __call__( self, env, libraries ):

        if not self._add_dependents:
            logger.warn( "BoostStaticLibrary() is deprecated, use BoostStaticLibs() or BoostStaticLib() instead" )
        libraries = Flatten( [ libraries ] )

        if not 'boost' in env['BUILD_WITH']:
            env.BuildWith( 'boost' )
        Boost = env['dependencies']['boost']( env )

        logger.trace( "Build static libraries [{}]".format( colour_items( libraries ) ) )

        library = BoostLibraryBuilder(
                Boost,
                add_dependents = self._add_dependents,
                verbose_build  = self._verbose_build,
                verbose_config = self._verbose_config )( env, None, None, libraries, 'static' )
        if self._build_always:
            return AlwaysBuild( library )
        else:
            return library
Пример #8
0
def ZephyrBuildProgram(env):
    env["LDSCRIPT_PATH"] = None
    env.ProcessProgramDeps()
    env.ProcessProjectDeps()

    # append into the beginning a main LD script
    env.Prepend(LINKFLAGS=["-T", "$LDSCRIPT_PATH"])

    # enable "cyclic reference" for linker
    if env.get("LIBS") and env.GetCompilerType() == "gcc":
        env.Prepend(_LIBFLAGS="-Wl,--start-group ")
        env.Append(_LIBFLAGS=" -Wl,--end-group")

    program_pre = env.Program(os.path.join("$BUILD_DIR", "firmware-pre"),
                              env["PIOBUILDFILES"],
                              LDSCRIPT_PATH=os.path.join(
                                  "$BUILD_DIR", "zephyr", "linker.cmd"))

    # Force execution of offset header target before compiling project sources
    env.Depends(env["PIOBUILDFILES"], env["__ZEPHYR_OFFSET_HEADER_CMD"])

    program = env.Program(os.path.join("$BUILD_DIR", env.subst("$PROGNAME")),
                          env["PIOBUILDFILES"] +
                          env["_EXTRA_ZEPHYR_PIOBUILDFILES"],
                          LDSCRIPT_PATH=os.path.join("$BUILD_DIR", "zephyr",
                                                     "linker_pass_final.cmd"))

    env.Replace(PIOMAINPROG=program)

    AlwaysBuild(
        env.Alias(
            "checkprogsize",
            program,
            env.VerboseAction(env.CheckUploadSize,
                              "Checking size $PIOMAINPROG"),
        ))

    print("Building in %s mode" % env.GetBuildType())

    return program
Пример #9
0
Файл: main.py Проект: OS-Q/P411
        target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"),
                                   target_elf)
    elif "sam-ba" == upload_protocol:
        target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"),
                                   target_elf)
    else:
        if "DFUBOOTHEX" in env:
            target_firm = env.SignBin(
                join("$BUILD_DIR", "${PROGNAME}"),
                env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf))
        else:
            target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"),
                                       target_elf)
        env.Depends(target_firm, "checkprogsize")

AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)

if "DFUBOOTHEX" in env:
    env.Append(
        # Check the linker script for the correct location
        BOOT_SETTING_ADDR=board.get("build.bootloader.settings_addr",
                                    "0x7F000"))

    env.AddPlatformTarget(
        "dfu",
        env.PackageDfu(
            join("$BUILD_DIR", "${PROGNAME}"),
            env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf),
        ),
        target_firm,
Пример #10
0
target_elf = env.BuildProgram()

#
# Target: Build the .hex
#

if "uploadlazy" in COMMAND_LINE_TARGETS:
    target_firm = join("$BUILD_DIR", "firmware.hex")
else:
    target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)

#
# Target: Print binary size
#

target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
AlwaysBuild(target_size)

#
# Target: Upload firmware
#

upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD")
AlwaysBuild(upload)

#
# Target: Define targets
#

Default([target_firm, target_size])
Пример #11
0
            CXX="${_BINPREFIX}g++",
            OBJCOPY="${_BINPREFIX}objcopy",
            RANLIB="${_BINPREFIX}ranlib",
            SIZETOOL="${_BINPREFIX}size",
            SIZEPRINTCMD='"$SIZETOOL" $SOURCES',
            PROGSUFFIX=".exe")

if get_systype() == "darwin_x86_64":
    env.Replace(_BINPREFIX="i586-mingw32-")
elif get_systype() in ("linux_x86_64", "linux_i686"):
    env.Replace(_BINPREFIX="i686-w64-mingw32-")

#
# Target: Build executable program
#

target_bin = env.BuildProgram()

#
# Target: Print binary size
#

target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD")
AlwaysBuild(target_size)

#
# Target: Define targets
#

Default([target_bin])
Пример #12
0
#
# Target: Build the .bin file
#

if "uploadlazy" in COMMAND_LINE_TARGETS:
    target_firm = join("$BUILD_DIR", "firmware.bin")
else:
    target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)

#
# Target: Print binary size
#

target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
AlwaysBuild(target_size)

#
# Target: Upload by default .bin file
#

upload = env.Alias(["upload", "uploadlazy"], target_firm,
                   [BeforeUpload, "$UPLOADCMD"])

AlwaysBuild(upload)

#
# Target: Unit Testing
#

AlwaysBuild(env.Alias("test", [target_firm, target_size]))
Пример #13
0
    SIZECHECKCMD="$SIZETOOL -A -d $SOURCES",
    SIZEPRINTCMD='$SIZETOOL --mcu=$BOARD_MCU -C -d $SOURCES',
    PROGSUFFIX=".elf",  
    UPLOADNAME=join("$BUILD_DIR", "${PROGNAME}.cfg"),
)

####################################################
# Target: Build executable and linkable program
####################################################
elf = None
elf = env.BuildProgram()
src = env.GFH(
    join("$BUILD_DIR", "${PROGNAME}"),
    env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), elf),    
)
AlwaysBuild( env.Alias("nobuild", src) )

####################################################
# Target: Upload BC66
####################################################
target_upload = env.Alias("upload", src, [
    env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
    env.VerboseAction("",  "--- WAITING MODULE ---"),
    env.VerboseAction("$UPLOADCMD", "RESET BOARD TO START FLASHING"),
    env.VerboseAction("",  "POWER ON BOARD"),

])


AlwaysBuild( target_upload )
Пример #14
0
# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode)
env.Append(ASFLAGS=env.get("CCFLAGS", [])[:])

#
# Target: Build executable and linkable firmware
#

target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
    target_firm = join("$BUILD_DIR", "${PROGNAME}.bin")
else:
    target_elf = env.BuildProgram()
    target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)

#
# Target: Print binary size
#

target_size = env.Alias(
    "size", target_elf,
    env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"))
AlwaysBuild(target_size)

#
# Target: Upload firmware
#
Пример #15
0
from SCons.Script import ARGUMENTS, AlwaysBuild

Import('env')

# Run the linker with "-g", to prevent stripping of debugging symbols
env.Append(
  LINKFLAGS=[
      "-g"
  ]
)

# Don't try to upload the firmware
env.Replace(UPLOADHEXCMD="echo Upload is not supported for ${PIOENV}. Skipping")

pioenv = env.get("PIOENV")
progname = env.get("PROGNAME")

def simulate_callback(*args, **kwargs):
    env.Execute("./simduino/simduino .pioenvs/" + pioenv + "/" + progname + ".elf")

AlwaysBuild(env.Alias("simulate", "", simulate_callback))
Пример #16
0
if "zephyr" in pioframework:
    env.SConscript(
        join(platform.get_package_dir(
            "framework-zephyr"), "scripts", "platformio", "platformio-build-pre.py"),
        exports={"env": env}
    )

target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
    target_elf = join("$BUILD_DIR", "${PROGNAME}.elf")
    target_hex = join("$BUILD_DIR", "${PROGNAME}.hex")
else:
    target_elf = env.BuildProgram()
    target_hex = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

AlwaysBuild(env.Alias("nobuild", target_hex))
target_buildprog = env.Alias("buildprog", target_hex, target_hex)

#
# Target: Print binary size
#

target_size = env.Alias(
    "size", target_elf,
    env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"))
AlwaysBuild(target_size)

#
# Target: Upload by default .bin file
#
Пример #17
0
CORELIBS = env.ProcessGeneral()

#
# Target: Build executable and linkable firmware
#

target_elf = env.BuildFirmware(CORELIBS + ["m"])

#
# Target: Build the .hex
#

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", "uploadlazy"], target_hex, "$UPLOADCMD")
AlwaysBuild(upload)

#
# Target: Define targets
#

Default(target_hex)
Пример #18
0
    'PnR': pnr,
    'Bin': bitstream,
    'Time': time_rpt
})

blif = env.Synth(TARGET, [src_synth])
asc = env.PnR(TARGET, [blif, PCF])
binf = env.Bin(TARGET, asc)

#
# Target: Time analysis (.rpt)
#
rpt = env.Time(asc)

target_time = env.Alias('time', rpt)
AlwaysBuild(target_time)

#
# Target: Upload bitstream
#
target_upload = env.Alias('upload', binf, '$UPLOADBINCMD')
AlwaysBuild(target_upload)

#
# Builders: Icarus Verilog
#
iverilog = Builder(
    action='iverilog {0} -o $TARGET -D VCD_OUTPUT={1} {2} $SOURCES'.format(
        IVER_PATH, TARGET_SIM, VLIB_FILES),
    suffix='.out',
    src_suffix='.v')
Пример #19
0
def show_progress(env):
    import sys
    from SCons.Script import Progress, Command, AlwaysBuild

    screen = sys.stdout
    # Progress reporting is not available in non-TTY environments since it
    # messes with the output (for example, when writing to a file)
    show_progress = env["progress"] and sys.stdout.isatty()
    node_count = 0
    node_count_max = 0
    node_count_interval = 1
    node_count_fname = str(env.Dir("#")) + "/.scons_node_count"

    import time, math

    class cache_progress:
        # The default is 1 GB cache and 12 hours half life
        def __init__(self, path=None, limit=1073741824, half_life=43200):
            self.path = path
            self.limit = limit
            self.exponent_scale = math.log(2) / half_life
            if env["verbose"] and path != None:
                screen.write(
                    "Current cache limit is {} (used: {})\n".format(
                        self.convert_size(limit), self.convert_size(self.get_size(path))
                    )
                )
            self.delete(self.file_list())

        def __call__(self, node, *args, **kw):
            nonlocal node_count, node_count_max, node_count_interval, node_count_fname, show_progress
            if show_progress:
                # Print the progress percentage
                node_count += node_count_interval
                if node_count_max > 0 and node_count <= node_count_max:
                    screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max))
                    screen.flush()
                elif node_count_max > 0 and node_count > node_count_max:
                    screen.write("\r[100%] ")
                    screen.flush()
                else:
                    screen.write("\r[Initial build] ")
                    screen.flush()

        def delete(self, files):
            if len(files) == 0:
                return
            if env["verbose"]:
                # Utter something
                screen.write("\rPurging %d %s from cache...\n" % (len(files), len(files) > 1 and "files" or "file"))
            [os.remove(f) for f in files]

        def file_list(self):
            if self.path is None:
                # Nothing to do
                return []
            # Gather a list of (filename, (size, atime)) within the
            # cache directory
            file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, "*", "*"))]
            if file_stat == []:
                # Nothing to do
                return []
            # Weight the cache files by size (assumed to be roughly
            # proportional to the recompilation time) times an exponential
            # decay since the ctime, and return a list with the entries
            # (filename, size, weight).
            current_time = time.time()
            file_stat = [(x[0], x[1][0], (current_time - x[1][1])) for x in file_stat]
            # Sort by the most recently accessed files (most sensible to keep) first
            file_stat.sort(key=lambda x: x[2])
            # Search for the first entry where the storage limit is
            # reached
            sum, mark = 0, None
            for i, x in enumerate(file_stat):
                sum += x[1]
                if sum > self.limit:
                    mark = i
                    break
            if mark is None:
                return []
            else:
                return [x[0] for x in file_stat[mark:]]

        def convert_size(self, size_bytes):
            if size_bytes == 0:
                return "0 bytes"
            size_name = ("bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
            i = int(math.floor(math.log(size_bytes, 1024)))
            p = math.pow(1024, i)
            s = round(size_bytes / p, 2)
            return "%s %s" % (int(s) if i == 0 else s, size_name[i])

        def get_size(self, start_path="."):
            total_size = 0
            for dirpath, dirnames, filenames in os.walk(start_path):
                for f in filenames:
                    fp = os.path.join(dirpath, f)
                    total_size += os.path.getsize(fp)
            return total_size

    def progress_finish(target, source, env):
        nonlocal node_count, progressor
        try:
            with open(node_count_fname, "w") as f:
                f.write("%d\n" % node_count)
            progressor.delete(progressor.file_list())
        except Exception:
            pass

    try:
        with open(node_count_fname) as f:
            node_count_max = int(f.readline())
    except Exception:
        pass

    cache_directory = os.environ.get("SCONS_CACHE")
    # Simple cache pruning, attached to SCons' progress callback. Trim the
    # cache directory to a size not larger than cache_limit.
    cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024
    progressor = cache_progress(cache_directory, cache_limit)
    Progress(progressor, interval=node_count_interval)

    progress_finish_command = Command("progress_finish", [], progress_finish)
    AlwaysBuild(progress_finish_command)
Пример #20
0
from os.path import join
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
                          DefaultEnvironment)
from colorama import Fore

env = DefaultEnvironment()
print(Fore.GREEN + '<<<<<<<<<<<< ' + env.BoardConfig().get("name").upper() +
      " 2019 Victor Fragoso >>>>>>>>>>>>")

####################################################
# Build executable and linkable program
####################################################
elf = env.BuildProgram()
src = env.MakeHeader(join("$BUILD_DIR", "${PROGNAME}"),
                     env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), elf))
AlwaysBuild(src)

#upload = env.Alias("upload", src, [
#    env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
#    env.VerboseAction("$UPLOADCMD", '\033[93m'+"Uploading: $PROGNAME"),
#    env.VerboseAction("", '\033[93m'+"Ready"),
#])
#AlwaysBuild( upload )

Default(src)

#### vffs ####
print "Building project"
print os.getcwd()
userpath = (os.path.expanduser('~'))
platformiopath = (userpath + "\\.platformio")
Пример #21
0
# Target: Build executable and linkable firmware
#

target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
    target_elf = os.path.join("$BUILD_DIR", "${PROGNAME}.elf")
    target_bin = os.path.join("$BUILD_DIR", "${PROGNAME}.bin")
    target_vh = os.path.join("$BUILD_DIR", "${PROGNAME}.vh")
else:
    target_elf = env.BuildProgram()
    target_bin = env.ElfToBin(os.path.join("$BUILD_DIR", "${PROGNAME}"),
                              target_elf)
    target_vh = env.BinToVh(os.path.join("$BUILD_DIR", "${PROGNAME}"),
                            target_bin)

AlwaysBuild(env.Alias("nobuild", target_bin))
target_buildprog = env.Alias("buildprog", target_bin, target_bin)

env.AddPostAction(
    target_elf,
    env.VerboseAction(generate_disassembly, "Generating disassembly"))

#
# Target: Print binary size
#

target_size = env.AddPlatformTarget(
    "size",
    target_elf,
    env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"),
    "Program Size",
Пример #22
0
# WizIO 2021 Georgi Angelov
#   http://www.wizio.eu/
#   https://github.com/Wiz-IO/wizio-pico

from __future__ import print_function
from os.path import join
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment)
from colorama import Fore
from pioasm import dev_pioasm

env = DefaultEnvironment()
print( '<<<<<<<<<<<< ' + env.BoardConfig().get("name").upper() + " 2021 Georgi Angelov >>>>>>>>>>>>" )

dev_pioasm(env)

elf = env.BuildProgram()
src = env.ElfToBin( join("$BUILD_DIR", "${PROGNAME}"), elf )
prg = env.Alias( "buildprog", src, [ env.VerboseAction("", "DONE") ] )
AlwaysBuild( prg )

upload = env.Alias("upload", prg, [ 
    env.VerboseAction("$UPLOADCMD", "Uploading..."),
    env.VerboseAction("", "  DONE"),
])
AlwaysBuild( upload )    

Default( prg )
Пример #23
0
    )

#
# Target: Build executable and linkable firmware
#

target_elf = env.BuildProgram()

#
# Target: Build the .hex or SPIFFS image
#

if set(["uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS):
    target_firm = env.DataToBin(
        join("$BUILD_DIR", "spiffs"), "$PROJECTDATA_DIR")
    AlwaysBuild(target_firm)

elif "uploadlazy" in COMMAND_LINE_TARGETS:
    if "PIOFRAMEWORK" not in env:
        target_firm = [
            join("$BUILD_DIR", "firmware_00000.bin"),
            join("$BUILD_DIR", "firmware_40000.bin")
        ]
    else:
        target_firm = join("$BUILD_DIR", "firmware.bin")
else:
    if "PIOFRAMEWORK" not in env:
        target_firm = env.ElfToBin(
            [join("$BUILD_DIR", "firmware_00000"),
             join("$BUILD_DIR", "firmware_40000")], target_elf)
    else:
Пример #24
0
#
# Target: Build executable and linkable firmware or SPIFFS image
#

target_elf = env.BuildProgram()
if "nobuild" in COMMAND_LINE_TARGETS:
    if set(["uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS):
        fetch_spiffs_size(env)
        target_firm = join("$BUILD_DIR", "spiffs.bin")
    else:
        target_firm = join("$BUILD_DIR", "${PROGNAME}.bin")
else:
    if set(["buildfs", "uploadfs", "uploadfsota"]) & set(COMMAND_LINE_TARGETS):
        target_firm = env.DataToBin(join("$BUILD_DIR", "spiffs"),
                                    "$PROJECTDATA_DIR")
        AlwaysBuild(target_firm)
        AlwaysBuild(env.Alias("buildfs", target_firm))
    else:
        target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"),
                                   target_elf)

AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)

# update max upload size based on CSV file
if env.get("PIOMAINPROG"):
    env.AddPreAction(
        "checkprogsize",
        env.VerboseAction(
            lambda source, target, env: _update_max_upload_size(env),
            "Retrieving maximum program size $SOURCES"))
Пример #25
0
        "-U%s:w:%s:m" % (k, v)
        for k, v in env.BoardConfig().get("fuses", {}).items()
    ]))

#
# Target: Build executable and linkable firmware
#

target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
    target_firm = join("$BUILD_DIR", "${PROGNAME}.hex")
else:
    target_elf = env.BuildProgram()
    target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)

#
# Target: Print binary size
#

target_size = env.Alias(
    "size", target_elf,
    env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"))
AlwaysBuild(target_size)

#
# Target: Upload by default .hex file
#
Пример #26
0
                      ["$OBJDUMP", "-S", "-d", "$SOURCES", ">$TARGET"]),
                                   suffix=".lst"),
                  ElfToHex=Builder(action=env.VerboseAction(
                      " ".join(
                          ["$OBJCOPY", "-O", "ihex", "$SOURCES", "$TARGET"]),
                      "Building $TARGET"),
                                   suffix=".hex")))

# The source code of "platformio-build-tool" is here
# https://github.com/platformio/platformio-core/blob/develop/platformio/builder/tools/platformio.py

#
# Target: Build executable and linkable firmware
#
target_elf = env.BuildProgram()
AlwaysBuild(target_elf)

#
# Target: Build the .bin file
#
_name = env.get("PROGNAME")

target_bin = env.ElfToBin(join("$BUILD_DIR", _name), target_elf)

# Target: Build the .hex file
#
target_hex = env.ElfToHex(join("$BUILD_DIR", _name), target_elf)
# Target: Build the .lst file
#
target_lst = env.ElfToLst(join("$BUILD_DIR", _name), target_elf)
Пример #27
0
Файл: main.py Проект: OS-Q/P244
)

if not env.get("PIOFRAMEWORK"):
    env.SConscript("frameworks/_bare.py")


target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
    target_elf = join("$BUILD_DIR", "${PROGNAME}.elf")
    target_firm = join("$BUILD_DIR", "${PROGNAME}.bin")
else:
    target_elf = env.BuildProgram()
    target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)
    env.Depends(target_firm, "checkprogsize")

AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)

#
# Target: Print binary size
#

target_size = env.Alias(
    "size", target_elf,
    env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"))
AlwaysBuild(target_size)

#
# Target: Upload by default .bin file
#
Пример #28
0
#
# Support: Comet Electronics
#   https://www.comet.bg/?cid=92
##########################################################################

from os.path import join
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
                          DefaultEnvironment)
from colorama import Fore

env = DefaultEnvironment()
print(Fore.GREEN + '<<<<<<<<<<<< ' + env.BoardConfig().get("name").upper() +
      " 2018 Georgi Angelov >>>>>>>>>>>>")

####################################################
# Build executable and linkable program
####################################################
elf = env.BuildProgram()
src = env.MakeHeader(join("$BUILD_DIR", "${PROGNAME}"),
                     env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), elf))
AlwaysBuild(src)

upload = env.Alias("upload", src, [
    env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
    env.VerboseAction("$UPLOADCMD", '\033[93m' + "Uploading: $PROGNAME"),
    env.VerboseAction("", '\033[93m' + "Ready"),
])
AlwaysBuild(upload)

Default(src)
def BuildProgram(env):
    def _append_pio_macros():
        env.AppendUnique(CPPDEFINES=[("PLATFORMIO",
                                      int("{0:02d}{1:02d}{2:02d}".format(
                                          *pioversion_to_intstr())))])

    _append_pio_macros()

    # fix ASM handling under non-casitive OS
    if not case_sensitive_suffixes(".s", ".S"):
        env.Replace(AS="$CC", ASCOM="$ASPPCOM")

    if "__debug" in COMMAND_LINE_TARGETS:
        env.ProcessDebug()

    # process extra flags from board
    if "BOARD" in env and "build.extra_flags" in env.BoardConfig():
        env.ProcessFlags(env.BoardConfig().get("build.extra_flags"))
    # remove base flags
    env.ProcessUnFlags(env.get("BUILD_UNFLAGS"))
    # apply user flags
    env.ProcessFlags(env.get("BUILD_FLAGS"))

    # process framework scripts
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))

    # restore PIO macros if it was deleted by framework
    _append_pio_macros()

    # build dependent libs
    env.Append(LIBS=env.BuildProjectLibraries())

    # append specified LD_SCRIPT
    if ("LDSCRIPT_PATH" in env
            and not any(["-Wl,-T" in f for f in env['LINKFLAGS']])):
        env.Append(LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"'])

    # enable "cyclic reference" for linker
    if env.get("LIBS") and env.GetCompilerType() == "gcc":
        env.Prepend(_LIBFLAGS="-Wl,--start-group ")
        env.Append(_LIBFLAGS=" -Wl,--end-group")

    # Handle SRC_BUILD_FLAGS
    env.ProcessFlags(env.get("SRC_BUILD_FLAGS"))

    env.Append(LIBPATH=["$BUILD_DIR"],
               PIOBUILDFILES=env.CollectBuildFiles(
                   "$BUILDSRC_DIR",
                   "$PROJECTSRC_DIR",
                   src_filter=env.get("SRC_FILTER"),
                   duplicate=False))

    if "__test" in COMMAND_LINE_TARGETS:
        env.Append(PIOBUILDFILES=env.ProcessTest())

    if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS:
        sys.stderr.write(
            "Error: Nothing to build. Please put your source code files "
            "to '%s' folder\n" % env.subst("$PROJECTSRC_DIR"))
        env.Exit(1)

    program = env.Program(join("$BUILD_DIR", env.subst("$PROGNAME")),
                          env['PIOBUILDFILES'])

    checksize_action = Action(env.CheckUploadSize, "Checking program size")
    AlwaysBuild(env.Alias("checkprogsize", program, checksize_action))
    if set(["upload", "program"]) & set(COMMAND_LINE_TARGETS):
        env.AddPostAction(program, checksize_action)

    return program
Пример #30
0
if not env.get("PIOFRAMEWORK"):
    env.SConscript("frameworks/_bare.py", exports="env")

#
# Target: Build executable and linkable firmware
#

target_elf = None
if "nobuild" in COMMAND_LINE_TARGETS:
    target_elf = join("$BUILD_DIR", "${PROGNAME}.elf")
    target_firm = join("$BUILD_DIR", "${PROGNAME}.hex")
else:
    target_elf = env.BuildProgram()
    target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

AlwaysBuild(env.Alias("nobuild", target_firm))
target_buildprog = env.Alias("buildprog", target_firm, target_firm)

#
# Target: Print binary size
#

target_size = env.Alias(
    "size", target_elf,
    env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"))
AlwaysBuild(target_size)

#
# Target: Upload by default .hex file
#