예제 #1
0
def LoadProjectOptions(env):
    for option, value in env.GetProjectOptions():
        option_meta = ProjectOptions.get("env." + option)
        if (not option_meta or not option_meta.buildenvvar
                or option_meta.buildenvvar in env):
            continue
        env[option_meta.buildenvvar] = value
예제 #2
0
def LoadPioPlatform(env):
    p = env.PioPlatform()
    installed_packages = p.get_installed_packages()

    # Ensure real platform name
    env['PIOPLATFORM'] = p.name

    # Add toolchains and uploaders to $PATH and $*_LIBRARY_PATH
    systype = util.get_systype()
    for name in installed_packages:
        type_ = p.get_package_type(name)
        if type_ not in ("toolchain", "uploader", "debugger"):
            continue
        pkg_dir = p.get_package_dir(name)
        env.PrependENVPath(
            "PATH",
            join(pkg_dir, "bin") if isdir(join(pkg_dir, "bin")) else pkg_dir)
        if (not WINDOWS and isdir(join(pkg_dir, "lib"))
                and type_ != "toolchain"):
            env.PrependENVPath(
                "DYLD_LIBRARY_PATH"
                if "darwin" in systype else "LD_LIBRARY_PATH",
                join(pkg_dir, "lib"))

    # Platform specific LD Scripts
    if isdir(join(p.get_dir(), "ldscripts")):
        env.Prepend(LIBPATH=[join(p.get_dir(), "ldscripts")])

    if "BOARD" not in env:
        return

    # update board manifest with overridden data from INI config
    board_config = env.BoardConfig()
    for option, value in env.GetProjectOptions():
        if option.startswith("board_"):
            board_config.update(option.lower()[6:], value)

    # load default variables from board config
    for option_meta in ProjectOptions.values():
        if not option_meta.buildenvvar or option_meta.buildenvvar in env:
            continue
        data_path = (option_meta.name[6:]
                     if option_meta.name.startswith("board_") else
                     option_meta.name.replace("_", "."))
        try:
            env[option_meta.buildenvvar] = board_config.get(data_path)
        except KeyError:
            pass

    if "build.ldscript" in board_config:
        env.Replace(LDSCRIPT_PATH=board_config.get("build.ldscript"))
예제 #3
0
# The currently building build target
build_type = env.GetBuildType()

# The env:<NAME> from the projects platformio.ini file
build_environment = env["PIOENV"]

# The options specified in the `build_environment` section of the platform.ini file.
options = env.GetProjectOptions()

# I have found that using the debug_build_flags defaults of
# ["-Og", "-g2", "-ggdb2"] produces some serious
# "Spooky Action At A Distance", specifically the "-Og" flag.
# It seems to happen when calling functions in libmbed-os.a,
# which has not been compiled with the "-Og". So we clear
# out the default values of debug_build_flags and set it to "-g".
debug_build_flags = ProjectOptions.get("env.debug_build_flags")
debug_build_flags.default.clear()
debug_build_flags.default.append("-g")
debug_build_flags.default.append("-ggdb")


# This lets us run the auto-port-detect to find an upload port
# just before we issue the upload command.
def BeforeUpload(target, source, env):
    upload_port = env.subst("$UPLOAD_PORT")
    if len(upload_port) == 0:
        env.AutodetectUploadPort()


upload_actions = [
    env.VerboseAction(BeforeUpload, "Looking for upload port..."),