X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fplugins%2Fcodelite.py;h=1638823304d0ad243fc2c7127496c63f45795126;hb=47219caf366ee98c051346d9e3fbdd30eca45827;hp=6e14f51e61404a53b8f102883ec4b6e46927fb12;hpb=6fb67bc94e1d53acc1e1b339f22bb7d4f2f7dea3;p=bertos.git diff --git a/wizard/plugins/codelite.py b/wizard/plugins/codelite.py index 6e14f51e..16388233 100644 --- a/wizard/plugins/codelite.py +++ b/wizard/plugins/codelite.py @@ -1,8 +1,32 @@ #!/usr/bin/env python # encoding: utf-8 # -# Copyright 2009 Develer S.r.l. (http://www.develer.com/) -# All rights reserved. +# This file is part of BeRTOS. +# +# Bertos is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As a special exception, you may use this file as part of a free software +# library without restriction. Specifically, if other files instantiate +# templates or use macros or inline functions from this file, or you compile +# this file and link it with other files to produce an executable, this +# file does not by itself cause the resulting executable to be covered by +# the GNU General Public License. This exception does not however +# invalidate any other reasons why the executable file might be covered by +# the GNU General Public License. +# +# Copyright 2008 Develer S.r.l. (http://www.develer.com/) # # $Id$ # @@ -13,18 +37,42 @@ import os import const +## Plugin interface ## + +PLUGIN_NAME = "CodeLite" + +PLUGIN_DESCRIPTION = "Create CodeLite project files" + +def createProject(project_info): + """ + Function that creates codelite projects and return the project relevant file. + """ + directory = project_info.info("PROJECT_PATH") + prjdir = directory + os.sep + os.path.basename(directory) + workspace = codeliteWorkspaceGenerator(project_info) + open(directory + os.sep + os.path.basename(prjdir) + ".workspace", "w").write(workspace) + project = codeliteProjectGenerator(project_info) + open(directory + os.sep + os.path.basename(prjdir) + ".project", "w").write(project) + return directory + os.sep + os.path.basename(prjdir) + ".workspace" + +#### + def clFiles(file_dict, directory): """ Creates the list of the lines for the files founded in file_dict, using directory as the base folder. """ filelist = [] - filelist.append("" %os.path.basename(directory)) + # Do not create an empty VDir. + # TODO: this is *really* ugly, but an empty VDir is worse + if directory: + filelist.append("" %os.path.basename(directory)) for f in file_dict[directory]["files"]: filelist.append("" %os.path.join(directory, f)) for d in file_dict[directory]["dirs"]: filelist += clFiles(file_dict, os.path.join(directory, d)) - filelist.append("") + if directory: + filelist.append("") return filelist def findSources(path): @@ -39,10 +87,11 @@ def findSources(path): if root.find("svn") == -1: file_dict[root.replace(path, "")] = {"dirs": [], "files": []} for dir in dirs: - if dir.find("svn") == -1: + # TODO: place the directory name in a constant file. + if dir.find("svn") == -1 and dir != "images" and dir != "obj" and dir != "doc": file_dict[root.replace(path, "")]["dirs"].append(dir) for file in files: - if file.endswith(const.EXTENSION_FILTER): + if file.endswith(const.EXTENSION_FILTER) and file != "buildrev.h": file_dict[root.replace(path, "")]["files"].append(file) return file_dict @@ -50,33 +99,22 @@ def codeliteProjectGenerator(project_info): """ Returns the string rapresenting the codelite project. """ - template = open("cltemplates/bertos.project", "r").read() + template = open(os.path.join(const.DATA_DIR, "cltemplates/bertos.project"), "r").read() filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), "")) - while template.find("$filelist") != -1: - template = template.replace("$filelist", filelist) + debugger_path = project_info.info("TOOLCHAIN")["path"].replace("gcc", "gdb") + init_script = project_info.info("CPU_INFOS")["GDB_INIT_SCRIPT"] + template = template.replace("$filelist", filelist) project_name = os.path.basename(project_info.info("PROJECT_PATH")) - while template.find("$project") != -1: - template = template.replace("$project", project_name) + template = template.replace("$project", project_name) + template = template.replace("$debuggerpath", debugger_path) + template = template.replace("$initscript", init_script) return template def codeliteWorkspaceGenerator(project_info): """ Returns the string rapresentig the codelite workspace. """ - template = open("cltemplates/bertos.workspace", "r").read() + template = open(os.path.join(const.DATA_DIR, "cltemplates/bertos.workspace"), "r").read() project_name = os.path.basename(project_info.info("PROJECT_PATH")) - while template.find("$project") != -1: - template = template.replace("$project", project_name) + template = template.replace("$project", project_name) return template - -def createProject(project_info): - """ - Function that creates codelite projects and return the project relevant file. - """ - directory = project_info.info("PROJECT_PATH") - prjdir = directory + "/" + os.path.basename(directory) - workspace = codeliteWorkspaceGenerator(project_info) - open(directory + "/" + os.path.basename(prjdir) + ".workspace", "w").write(workspace) - project = codeliteProjectGenerator(project_info) - open(directory + "/" + os.path.basename(prjdir) + ".project", "w").write(project) - return directory + "/" + os.path.basename(prjdir) + ".workspace"