Ejemplo n.º 1
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"),
        "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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
    def _gather_tplvars(self):
        src_files = self.get_src_files()
        main_src_file = self.get_main_src_file(src_files)

        if not main_src_file and self.ide == "clion":
            click.secho(
                "Warning! Can not find main source file (*.c, *.cpp). So, "
                "code auto-completion is disabled. Please add source files "
                "to `src` directory and re-initialize project or edit "
                "`CMakeLists.txt` file manually (`add_executable` command).",
                fg="yellow")

        self._tplvars.update(self.get_project_env())
        self._tplvars.update(self.get_project_build_data())
        self._tplvars.update({
            "project_name":
            self.get_project_name(),
            "src_files":
            src_files,
            "main_src_file":
            main_src_file,
            "user_home_dir":
            abspath(expanduser("~")),
            "project_dir":
            self.project_dir,
            "systype":
            util.get_systype(),
            "platformio_path":
            self._fix_os_path(util.where_is_program("platformio")),
            "env_pathsep":
            os.pathsep,
            "env_path":
            self._fix_os_path(os.getenv("PATH"))
        })
Ejemplo n.º 4
0
    def _gather_tplvars(self):
        src_files = self.get_src_files()
        main_src_file = self.get_main_src_file(src_files)

        if not main_src_file and self.ide == "clion":
            click.secho(
                "Warning! Can not find main source file (*.c, *.cpp). So, "
                "code auto-completion is disabled. Please add source files "
                "to `src` directory and re-initialize project or edit "
                "`CMakeLists.txt` file manually (`add_executable` command).",
                fg="yellow",
            )

        self._tplvars.update(self.get_project_env())
        self._tplvars.update(self.get_project_build_data())
        self._tplvars.update(
            {
                "project_name": self.get_project_name(),
                "src_files": src_files,
                "main_src_file": main_src_file,
                "user_home_dir": abspath(expanduser("~")),
                "project_dir": self.project_dir,
                "systype": util.get_systype(),
                "platformio_path": self._fix_os_path(util.where_is_program("platformio")),
                "env_pathsep": os.pathsep,
                "env_path": self._fix_os_path(os.getenv("PATH")),
            }
        )
Ejemplo n.º 5
0
 def _gather_tplvars(self):
     self._tplvars.update(self.get_project_env())
     self._tplvars.update(self.get_project_build_data())
     self._tplvars.update({
         "project_name": self.get_project_name(),
         "srcfiles": self.get_srcfiles(),
         "user_home_dir": abspath(expanduser("~")),
         "project_dir": self.project_dir,
         "systype": util.get_systype(),
         "platformio_path": self._fix_os_path(
             util.where_is_program("platformio")),
         "env_pathsep": os.pathsep,
         "env_path": self._fix_os_path(os.getenv("PATH"))
     })
Ejemplo n.º 6
0
 def _gather_tplvars(self):
     self._tplvars.update(self.get_project_env())
     self._tplvars.update(self.get_project_build_data())
     with util.cd(self.project_dir):
         self._tplvars.update({
             "project_name": self.get_project_name(),
             "src_files": self.get_src_files(),
             "user_home_dir": abspath(expanduser("~")),
             "project_dir": self.project_dir,
             "project_src_dir": util.get_projectsrc_dir(),
             "project_lib_dir": util.get_projectlib_dir(),
             "project_libdeps_dir": util.get_projectlibdeps_dir(),
             "systype": util.get_systype(),
             "platformio_path": self._fix_os_path(
                 util.where_is_program("platformio")),
             "env_pathsep": os.pathsep,
             "env_path": self._fix_os_path(os.getenv("PATH"))
         })  # yapf: disable
Ejemplo n.º 7
0
 def _gather_tplvars(self):
     self._tplvars.update(self.get_project_env())
     self._tplvars.update(self.get_project_build_data())
     with util.cd(self.project_dir):
         self._tplvars.update({
             "project_name": self.get_project_name(),
             "src_files": self.get_src_files(),
             "user_home_dir": abspath(expanduser("~")),
             "project_dir": self.project_dir,
             "project_src_dir": util.get_projectsrc_dir(),
             "project_lib_dir": util.get_projectlib_dir(),
             "project_libdeps_dir": util.get_projectlibdeps_dir(),
             "systype": util.get_systype(),
             "platformio_path": self._fix_os_path(
                 sys.argv[0] if isfile(sys.argv[0])
                 else util.where_is_program("platformio")),
             "env_pathsep": os.pathsep,
             "env_path": self._fix_os_path(os.getenv("PATH"))
         })  # yapf: disable
Ejemplo n.º 8
0
def DumpIDEData(env):
    data = {
        "defines": [],
        "includes": [],
        "cxx_path": where_is_program(
            env.subst("$CXX"), env.subst("${ENV['PATH']}"))
    }

    # includes from framework and libs
    for item in env.get("VARIANT_DIRS", []):
        if "$BUILDSRC_DIR" in item[0]:
            continue
        data['includes'].append(env.subst(item[1]))

    # includes from toolchain
    toolchain_dir = env.subst(
        join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN"))
    toolchain_incglobs = [
        join(toolchain_dir, "*", "include*"),
        join(toolchain_dir, "lib", "gcc", "*", "*", "include*")
    ]
    for g in toolchain_incglobs:
        data['includes'].extend(glob(g))

    # global symbols
    for item in env.get("CPPDEFINES", []):
        if isinstance(item, list):
            item = "=".join(item)
        data['defines'].append(env.subst(item))

    # special symbol for Atmel AVR MCU
    board = env.get("BOARD_OPTIONS", {})
    if board and board['platform'] == "atmelavr":
        data['defines'].append(
            "__AVR_%s__" % board['build']['mcu'].upper()
            .replace("ATMEGA", "ATmega")
            .replace("ATTINY", "ATtiny")
        )

    return data
Ejemplo n.º 9
0
def DumpIDEData(env):
    data = {
        "defines": [],
        "includes": [],
        "cxx_path": where_is_program(
            env.subst("$CXX"), env.subst("${ENV['PATH']}"))
    }

    # includes from framework and libs
    for item in env.get("VARIANT_DIRS", []):
        if "$BUILDSRC_DIR" in item[0]:
            continue
        data['includes'].append(env.subst(item[1]))

    # includes from toolchain
    toolchain_dir = env.subst(
        join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN"))
    toolchain_incglobs = [
        join(toolchain_dir, "*", "include*"),
        join(toolchain_dir, "lib", "gcc", "*", "*", "include*")
    ]
    for g in toolchain_incglobs:
        data['includes'].extend(glob(g))

    # global symbols
    for item in env.get("CPPDEFINES", []):
        if isinstance(item, list):
            item = "=".join(item)
        data['defines'].append(env.subst(item).replace('\\"', '"'))

    # special symbol for Atmel AVR MCU
    board = env.get("BOARD_OPTIONS", {})
    if board and board['platform'] == "atmelavr":
        data['defines'].append(
            "__AVR_%s__" % board['build']['mcu'].upper()
            .replace("ATMEGA", "ATmega")
            .replace("ATTINY", "ATtiny")
        )

    return data
Ejemplo n.º 10
0
def DumpIDEData(env):

    BOARD_CORE = env.get("BOARD_OPTIONS", {}).get("build", {}).get("core")

    def get_includes(env_):
        includes = []
        # includes from used framework and libs
        for item in env_.get("VARIANT_DIRS", []):
            if "$BUILDSRC_DIR" in item[0]:
                continue
            includes.append(env_.subst(item[1]))

        # custom includes
        for item in env_.get("CPPPATH", []):
            if item.startswith("$BUILD_DIR"):
                continue
            includes.append(env_.subst(item))

        # installed libs
        for d in env_.get("LIBSOURCE_DIRS", []):
            lsd_dir = env_.subst(d)
            _append_lib_includes(env_, lsd_dir, includes)

        # includes from toolchain
        toolchain_dir = env_.subst(
            join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN"))
        toolchain_incglobs = [
            join(toolchain_dir, "*", "include*"),
            join(toolchain_dir, "lib", "gcc", "*", "*", "include*")
        ]
        for g in toolchain_incglobs:
            includes.extend(glob(g))

        return includes

    def _append_lib_includes(env_, libs_dir, includes):
        if not isdir(libs_dir):
            return
        for name in env_.get("LIB_USE", []) + sorted(listdir(libs_dir)):
            if not isdir(join(libs_dir, name)):
                continue
            # ignore user's specified libs
            if name in env_.get("LIB_IGNORE", []):
                continue
            if name == "__cores__":
                if isdir(join(libs_dir, name, BOARD_CORE)):
                    _append_lib_includes(
                        env_, join(libs_dir, name, BOARD_CORE), includes)
                return

            include = (
                join(libs_dir, name, "src")
                if isdir(join(libs_dir, name, "src"))
                else join(libs_dir, name)
            )
            if include not in includes:
                includes.append(include)

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

        # special symbol for Atmel AVR MCU
        board = env_.get("BOARD_OPTIONS", {})
        if board and board['platform'] == "atmelavr":
            defines.append(
                "__AVR_%s__" % board['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 = {
        "defines": get_defines(env_),
        "includes": get_includes(env_),
        "cc_flags": env_.subst(LINTCCOM),
        "cxx_flags": env_.subst(LINTCXXCOM),
        "cxx_path": where_is_program(
            env_.subst("$CXX"), env_.subst("${ENV['PATH']}"))
    }

    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in env_.get("CPPDEFINES", []):
        if isinstance(item, list):
            item = "=".join(item)
        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
Ejemplo n.º 11
0
def DumpIDEData(env):

    BOARD_CORE = env.get("BOARD_OPTIONS", {}).get("build", {}).get("core")

    def get_includes(env_):
        includes = []
        # includes from used framework and libs
        for item in env_.get("VARIANT_DIRS", []):
            if "$BUILDSRC_DIR" in item[0]:
                continue
            includes.append(env_.subst(item[1]))

        # custom includes
        for item in env_.get("CPPPATH", []):
            if item.startswith("$BUILD_DIR"):
                continue
            includes.append(env_.subst(item))

        # installed libs
        for d in env_.get("LIBSOURCE_DIRS", []):
            lsd_dir = env_.subst(d)
            _append_lib_includes(env_, lsd_dir, includes)

        # includes from toolchain
        toolchain_dir = env_.subst(
            join("$PIOPACKAGES_DIR", "$PIOPACKAGE_TOOLCHAIN"))
        toolchain_incglobs = [
            join(toolchain_dir, "*", "include*"),
            join(toolchain_dir, "lib", "gcc", "*", "*", "include*")
        ]
        for g in toolchain_incglobs:
            includes.extend(glob(g))

        return includes

    def _append_lib_includes(env_, libs_dir, includes):
        if not isdir(libs_dir):
            return
        for name in env_.get("LIB_USE", []) + sorted(listdir(libs_dir)):
            if not isdir(join(libs_dir, name)):
                continue
            # ignore user's specified libs
            if name in env_.get("LIB_IGNORE", []):
                continue
            if name == "__cores__":
                if isdir(join(libs_dir, name, BOARD_CORE)):
                    _append_lib_includes(env_, join(libs_dir, name,
                                                    BOARD_CORE), includes)
                return

            include = (join(libs_dir, name, "src") if isdir(
                join(libs_dir, name, "src")) else join(libs_dir, name))
            if include not in includes:
                includes.append(include)

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

        # special symbol for Atmel AVR MCU
        board = env_.get("BOARD_OPTIONS", {})
        if board and board['platform'] == "atmelavr":
            defines.append("__AVR_%s__" %
                           board['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 = {
        "defines":
        get_defines(env_),
        "includes":
        get_includes(env_),
        "cc_flags":
        env_.subst(LINTCCOM),
        "cxx_flags":
        env_.subst(LINTCXXCOM),
        "cxx_path":
        where_is_program(env_.subst("$CXX"), env_.subst("${ENV['PATH']}"))
    }

    # https://github.com/platformio/platformio-atom-ide/issues/34
    _new_defines = []
    for item in env_.get("CPPDEFINES", []):
        if isinstance(item, list):
            item = "=".join(item)
        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
Ejemplo n.º 12
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