Exemple #1
0
    def loadModuleData(self, edit=False):
        module_info_dict = {}
        list_info_dict = {}
        configuration_info_dict = {}
        file_dict = {}
        for filename, path in self.findDefinitions("*.h") + self.findDefinitions("*.c") + self.findDefinitions("*.s") + self.findDefinitions("*.S"):
            comment_list = getCommentList(open(path + "/" + filename, "r").read())
            if len(comment_list) > 0:
                module_info = {}
                configuration_info = {}
                try:
                    to_be_parsed, module_dict = loadModuleDefinition(comment_list[0])
                except ParseError, err:
                    raise DefineException.ModuleDefineException(os.path.join(path, filename), err.line_number, err.line)
                for module, information in module_dict.items():
                    if "depends" not in information:
                        information["depends"] = ()
                    information["depends"] += (filename.split(".")[0],)
                    information["category"] = os.path.basename(path)

                    # Hack to remove 'bertos/' from the configuration file path.
                    #
                    # The new module information format substitute paths like 'bertos/cfg/config_file.h'
                    # with the relative path into the bertos directory ('cfg/config_file.h')
                    information["configuration"] = information["configuration"].replace("bertos/", "")
                    information["hw"] = [hw.replace("bertos/", "") for hw in information["hw"]]

                    if "configuration" in information and len(information["configuration"]):
                        configuration = module_dict[module]["configuration"]
                        try:
                            cfg_file_path = os.path.join(self.bertos_srcdir, configuration)
                            configuration_info[configuration] = loadConfigurationInfos(cfg_file_path)
                        except ParseError, err:
                            raise DefineException.ConfigurationDefineException(cfg_file_path, err.line_number, err.line)
                        if edit:
                            try:
                                path = self.infos["PROJECT_SRC_PATH"]
                                cfg_file_path = os.path.join(path, configuration)
                                configuration_info[configuration] = updateConfigurationValues(configuration_info[configuration], loadConfigurationInfos(cfg_file_path))
                            except ParseError, err:
                                raise DefineException.ConfigurationDefineException(cfg_file_path, err.line_number, err.line)
                            except IOError, err:
                                # The wizard can't find the file, use the default configuration
                                pass
Exemple #2
0
    def loadModuleData(self, edit=False):
        module_info_dict = {}
        list_info_dict = {}
        configuration_info_dict = {}
        file_dict = {}
        for filename, path in self.findDefinitions(
                "*.h") + self.findDefinitions("*.c") + self.findDefinitions(
                    "*.s") + self.findDefinitions("*.S"):
            comment_list = getCommentList(
                open(path + "/" + filename, "r").read())
            if len(comment_list) > 0:
                module_info = {}
                configuration_info = {}
                try:
                    to_be_parsed, module_dict = loadModuleDefinition(
                        comment_list[0])
                except ParseError, err:
                    raise DefineException.ModuleDefineException(
                        os.path.join(path, filename), err.line_number,
                        err.line)
                for module, information in module_dict.items():
                    if "depends" not in information:
                        information["depends"] = ()
                    information["depends"] += (filename.split(".")[0], )
                    information["category"] = os.path.basename(path)

                    # Hack to remove 'bertos/' from the configuration file path.
                    #
                    # The new module information format substitute paths like 'bertos/cfg/config_file.h'
                    # with the relative path into the bertos directory ('cfg/config_file.h')
                    information["configuration"] = information[
                        "configuration"].replace("bertos/", "")
                    information["hw"] = [
                        hw.replace("bertos/", "") for hw in information["hw"]
                    ]

                    if "configuration" in information and len(
                            information["configuration"]):
                        configuration = module_dict[module]["configuration"]
                        try:
                            cfg_file_path = os.path.join(
                                self.bertos_srcdir, configuration)
                            configuration_info[
                                configuration] = loadConfigurationInfos(
                                    cfg_file_path)
                        except ParseError, err:
                            raise DefineException.ConfigurationDefineException(
                                cfg_file_path, err.line_number, err.line)
                        if edit:
                            try:
                                path = self.infos["PROJECT_SRC_PATH"]
                                cfg_file_path = os.path.join(
                                    path, configuration)
                                configuration_info[
                                    configuration] = updateConfigurationValues(
                                        configuration_info[configuration],
                                        loadConfigurationInfos(cfg_file_path))
                            except ParseError, err:
                                raise DefineException.ConfigurationDefineException(
                                    cfg_file_path, err.line_number, err.line)
                            except IOError, err:
                                # The wizard can't find the file, use the default configuration
                                pass
Exemple #3
0
                            except ParseError, err:
                                raise DefineException.ConfigurationDefineException(cfg_file_path, err.line_number, err.line)
                            except IOError, err:
                                # The wizard can't find the file, use the default configuration
                                pass
                module_info_dict.update(module_dict)
                configuration_info_dict.update(configuration_info)
                if to_be_parsed:
                    try:
                        list_dict = loadDefineLists(comment_list[1:])
                        list_info_dict.update(list_dict)
                    except ParseError, err:
                        raise DefineException.EnumDefineException(os.path.join(path, filename), err.line_number, err.line)
        for tag in self.infos["CPU_INFOS"]["CPU_TAGS"]:
            for filename, path in self.findDefinitions("*_" + tag + ".h"):
                comment_list = getCommentList(open(path + "/" + filename, "r").read())
                list_info_dict.update(loadDefineLists(comment_list))
        self.infos["MODULES"] = module_info_dict
        self.infos["LISTS"] = list_info_dict
        self.infos["CONFIGURATIONS"] = configuration_info_dict
        self.infos["FILES"] = file_dict

    def loadSourceTree(self):
        """
        Index BeRTOS source and load it in memory.
        """
        # Index only the BERTOS_PATH/bertos content
        bertos_sources_dir = os.path.join(self.info("BERTOS_PATH"), "bertos")
        file_dict = {}
        if os.path.exists(bertos_sources_dir):
            for element in os.walk(bertos_sources_dir):
Exemple #4
0
                            except IOError, err:
                                # The wizard can't find the file, use the default configuration
                                pass
                module_info_dict.update(module_dict)
                configuration_info_dict.update(configuration_info)
                if to_be_parsed:
                    try:
                        list_dict = loadDefineLists(comment_list[1:])
                        list_info_dict.update(list_dict)
                    except ParseError, err:
                        raise DefineException.EnumDefineException(
                            os.path.join(path, filename), err.line_number,
                            err.line)
        for tag in self.infos["CPU_INFOS"]["CPU_TAGS"]:
            for filename, path in self.findDefinitions("*_" + tag + ".h"):
                comment_list = getCommentList(
                    open(path + "/" + filename, "r").read())
                list_info_dict.update(loadDefineLists(comment_list))
        self.infos["MODULES"] = module_info_dict
        self.infos["LISTS"] = list_info_dict
        self.infos["CONFIGURATIONS"] = configuration_info_dict
        self.infos["FILES"] = file_dict

    def loadSourceTree(self):
        """
        Index BeRTOS source and load it in memory.
        """
        # Index only the BERTOS_PATH/bertos content
        bertos_sources_dir = os.path.join(self.info("BERTOS_PATH"), "bertos")
        file_dict = {}
        if os.path.exists(bertos_sources_dir):
            for element in os.walk(bertos_sources_dir):