Exemple #1
0
def DumpIDEData(env, globalenv):
    """ env here is `projenv`"""

    env["__escape_build_flag"] = _escape_build_flag

    LINTCCOM = (
        "${__escape_build_flag(CFLAGS)} ${__escape_build_flag(CCFLAGS)} $CPPFLAGS"
    )
    LINTCXXCOM = (
        "${__escape_build_flag(CXXFLAGS)} ${__escape_build_flag(CCFLAGS)} $CPPFLAGS"
    )

    data = {
        "env_name":
        env["PIOENV"],
        "libsource_dirs": [env.subst(l) for l in env.GetLibSourceDirs()],
        "defines":
        _dump_defines(env),
        "includes":
        _dump_includes(env),
        "cc_path":
        where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
        "cxx_path":
        where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
        "gdb_path":
        where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
        "prog_path":
        env.subst("$PROG_PATH"),
        "svd_path":
        _get_svd_path(env),
        "compiler_type":
        env.GetCompilerType(),
        "targets":
        globalenv.DumpTargets(),
        "extra":
        dict(flash_images=[{
            "offset": item[0],
            "path": env.subst(item[1])
        } for item in env.get("FLASH_EXTRA_IMAGES", [])]),
    }
    data["extra"].update(env.get("IDE_EXTRA_DATA", {}))

    env_ = env.Clone()
    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in processDefines(env_.get("CPPDEFINES", [])):
        item = item.replace('\\"', '"')
        if " " in item:
            _new_defines.append(item.replace(" ", "\\\\ "))
        else:
            _new_defines.append(item)
    env_.Replace(CPPDEFINES=_new_defines)

    data.update({
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM)
    })

    return data
Exemple #2
0
    def keilv5_project_emitter(target, source, env):
        assert (len(target) == 1)
        data = dict()
        root_dir = env.Dir("#").abspath
        target_dir = os.path.dirname(target[0].abspath)

        file = str(target[0])
        target = list()
        target.append(file + '.uvprojx')
        target.append(file + '.uvoptx')

        # Add SVD-File.
        if env['mcu'].startswith('nrf51'):
            path = os.path.join(os.path.dirname(__file__), 'keil', 'svd',
                                'nrf51.svd')
            data['svd_file'] = os.path.relpath(path, target_dir)

        elif env['mcu'].startswith('nrf52'):
            path = os.path.join(os.path.dirname(__file__), 'keil', 'svd',
                                'nrf52.svd')
            data['svd_file'] = os.path.relpath(path, target_dir)

        # Add defines.
        data['defines'] = processDefines(env.get('CPPDEFINES', []))

        # Add includes.
        data['includes'] = list()
        for path in env.get('CPPPATH', []):
            path = root_dir + '/' + path[1:]
            data['includes'].append(os.path.relpath(path, target_dir))

        # Add files.
        data['files'] = list()
        source.append(env['startup'])
        for s in source:
            path = os.path.relpath(s.srcnode().abspath, target_dir)

            new = dict()
            new['name'] = os.path.basename(path)
            new['path'] = path

            ext = os.path.splitext(path)[1]
            if ext in ['.c']:
                new['type'] = '1'

            elif ext in ['.S', '.s']:
                new['type'] = '2'

            elif ext == '.lib':
                new['type'] = '4'

            else:
                new['type'] = '5'

            data['files'].append(new)

        return (target, [Python.Value(data)])
Exemple #3
0
    def get_defines(env_):
        defines = []
        # global symbols
        for item in processDefines(env_.get("CPPDEFINES", [])):
            defines.append(env_.subst(item).replace('\\', ''))

        # special symbol for Atmel AVR MCU
        if env['PIOPLATFORM'] == "atmelavr":
            defines.append(
                "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
                .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))
        return defines
Exemple #4
0
def DumpIDEData(env):
    LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS"
    LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS"

    data = {
        "env_name":
        env["PIOENV"],
        "libsource_dirs": [env.subst(l) for l in env.GetLibSourceDirs()],
        "defines":
        _dump_defines(env),
        "includes":
        _dump_includes(env),
        "cc_flags":
        env.subst(LINTCCOM),
        "cxx_flags":
        env.subst(LINTCXXCOM),
        "cc_path":
        where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
        "cxx_path":
        where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
        "gdb_path":
        where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
        "prog_path":
        env.subst("$PROG_PATH"),
        "flash_extra_images": [{
            "offset": item[0],
            "path": env.subst(item[1])
        } for item in env.get("FLASH_EXTRA_IMAGES", [])],
        "svd_path":
        _get_svd_path(env),
        "compiler_type":
        env.GetCompilerType(),
    }

    env_ = env.Clone()
    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in processDefines(env_.get("CPPDEFINES", [])):
        item = item.replace('\\"', '"')
        if " " in item:
            _new_defines.append(item.replace(" ", "\\\\ "))
        else:
            _new_defines.append(item)
    env_.Replace(CPPDEFINES=_new_defines)

    data.update({
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM)
    })

    return data
Exemple #5
0
def DumpIDEData(env):
    LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS"
    LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS"

    data = {
        "libsource_dirs":
        [env.subst(l) for l in env.get("LIBSOURCE_DIRS", [])],
        "defines":
        _dump_defines(env),
        "includes":
        _dump_includes(env),
        "cc_flags":
        env.subst(LINTCCOM),
        "cxx_flags":
        env.subst(LINTCXXCOM),
        "cc_path":
        util.where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
        "cxx_path":
        util.where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
        "gdb_path":
        util.where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
        "prog_path":
        env.subst("$PROG_PATH"),
        "flash_extra_images": [{
            "offset": item[0],
            "path": env.subst(item[1])
        } for item in env.get("FLASH_EXTRA_IMAGES", [])],
        "svd_path":
        _get_svd_path(env),
        "compiler_type":
        env.GetCompilerType()
    }

    env_ = env.Clone()
    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in processDefines(env_.get("CPPDEFINES", [])):
        item = item.replace('\\"', '"')
        if " " in item:
            _new_defines.append(item.replace(" ", "\\\\ "))
        else:
            _new_defines.append(item)
    env_.Replace(CPPDEFINES=_new_defines)

    data.update({
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM)
    })

    return data
Exemple #6
0
def DumpIDEData(env):
    LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS"
    LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS"

    data = {
        "libsource_dirs":
        [env.subst(l) for l in env.get("LIBSOURCE_DIRS", [])],
        "defines":
        _dump_defines(env),
        "includes":
        _dump_includes(env),
        "cc_flags":
        env.subst(LINTCCOM),
        "cxx_flags":
        env.subst(LINTCXXCOM),
        "cc_path":
        util.where_is_program(env.subst("$CC"), env.subst("${ENV['PATH']}")),
        "cxx_path":
        util.where_is_program(env.subst("$CXX"), env.subst("${ENV['PATH']}")),
        "gdb_path":
        util.where_is_program(env.subst("$GDB"), env.subst("${ENV['PATH']}")),
        "prog_path":
        env.subst("$PROG_PATH"),
        "svd_path":
        _get_svd_path(env),
        "compiler_type":
        env.GetCompilerType()
    }

    env_ = env.Clone()
    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in processDefines(env_.get("CPPDEFINES", [])):
        item = item.replace('\\"', '"')
        if " " in item:
            _new_defines.append(item.replace(" ", "\\\\ "))
        else:
            _new_defines.append(item)
    env_.Replace(CPPDEFINES=_new_defines)

    data.update({
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM)
    })

    return data
Exemple #7
0
def _dump_defines(env):
    defines = []
    # global symbols
    for item in processDefines(env.get("CPPDEFINES", [])):
        defines.append(env.subst(item).replace('\\', ''))

    # special symbol for Atmel AVR MCU
    if env['PIOPLATFORM'] == "atmelavr":
        board_mcu = env.get("BOARD_MCU")
        if not board_mcu and "BOARD" in env:
            board_mcu = env.BoardConfig().get("build.mcu")
        if board_mcu:
            defines.append(
                str("__AVR_%s__" % board_mcu.upper().replace(
                    "ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))

    # built-in GCC marcos
    # if env.GetCompilerType() == "gcc":
    #     defines.extend(_get_gcc_defines(env))

    return defines
Exemple #8
0
def _dump_defines(env):
    defines = []
    # global symbols
    for item in processDefines(env.get("CPPDEFINES", [])):
        defines.append(env.subst(item).replace('\\', ''))

    # special symbol for Atmel AVR MCU
    if env['PIOPLATFORM'] == "atmelavr":
        board_mcu = env.get("BOARD_MCU")
        if not board_mcu and "BOARD" in env:
            board_mcu = env.BoardConfig().get("build.mcu")
        if board_mcu:
            defines.append(
                str("__AVR_%s__" % board_mcu.upper().replace(
                    "ATMEGA", "ATmega").replace("ATTINY", "ATtiny")))

    # built-in GCC marcos
    # if env.GetCompilerType() == "gcc":
    #     defines.extend(_get_gcc_defines(env))

    return defines
Exemple #9
0
def DumpIDEData(env):

    def get_includes(env_):
        includes = []

        for item in env_.get("CPPPATH", []):
            includes.append(env_.subst(item))

        # installed libs
        for lb in env.GetLibBuilders():
            includes.extend(lb.get_inc_dirs())

        # includes from toolchains
        p = env.PioPlatform()
        for name in p.get_installed_packages():
            if p.get_package_type(name) != "toolchain":
                continue
            toolchain_dir = p.get_package_dir(name)
            toolchain_incglobs = [
                join(toolchain_dir, "*", "include*"),
                join(toolchain_dir, "lib", "gcc", "*", "*", "include*")
            ]
            for g in toolchain_incglobs:
                includes.extend(glob(g))

        return includes

    def get_defines(env_):
        defines = []
        # global symbols
        for item in processDefines(env_.get("CPPDEFINES", [])):
            defines.append(env_.subst(item).replace('\\', ''))

        # special symbol for Atmel AVR MCU
        if env['PIOPLATFORM'] == "atmelavr":
            defines.append(
                "__AVR_%s__" % env.BoardConfig().get("build.mcu").upper()
                .replace("ATMEGA", "ATmega").replace("ATTINY", "ATtiny"))
        return defines

    LINTCCOM = "$CFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS"
    LINTCXXCOM = "$CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS"
    env_ = env.Clone()

    data = {
        "libsource_dirs":
        [env_.subst(l) for l in env_.get("LIBSOURCE_DIRS", [])],
        "defines": get_defines(env_),
        "includes": get_includes(env_),
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM),
        "cc_path": util.where_is_program(
            env_.subst("$CC"), env_.subst("${ENV['PATH']}")),
        "cxx_path": util.where_is_program(
            env_.subst("$CXX"), env_.subst("${ENV['PATH']}"))
    }

    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in processDefines(env_.get("CPPDEFINES", [])):
        item = item.replace('\\"', '"')
        if " " in item:
            _new_defines.append(item.replace(" ", "\\\\ "))
        else:
            _new_defines.append(item)
    env_.Replace(CPPDEFINES=_new_defines)

    data.update({
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM)
    })

    return data