X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2Fplugins%2Fcodelite.py;h=1789c52048eb5eccaaa04efa567dc1a2fcedf988;hb=0b5e269f0571dac2454992b94b563f80c31291e1;hp=6e14f51e61404a53b8f102883ec4b6e46927fb12;hpb=6fb67bc94e1d53acc1e1b339f22bb7d4f2f7dea3;p=bertos.git diff --git a/wizard/plugins/codelite.py b/wizard/plugins/codelite.py index 6e14f51e..1789c520 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): @@ -52,11 +100,17 @@ def codeliteProjectGenerator(project_info): """ template = open("cltemplates/bertos.project", "r").read() filelist = "\n".join(clFiles(findSources(project_info.info("PROJECT_PATH")), "")) + debugger_path = project_info.info("TOOLCHAIN")["path"].replace("gcc", "gdb") + init_script = project_info.info("CPU_INFOS")["GDB_INIT_SCRIPT"] while template.find("$filelist") != -1: 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) + while template.find("$debuggerpath") != -1: + template = template.replace("$debuggerpath", debugger_path) + while template.find("$initscript") != -1: + template = template.replace("$initscript", init_script) return template def codeliteWorkspaceGenerator(project_info): @@ -68,15 +122,3 @@ def codeliteWorkspaceGenerator(project_info): while template.find("$project") != -1: 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"