From: duplo Date: Mon, 29 Mar 2010 12:53:54 +0000 (+0000) Subject: Add Wizard version check (to change the way the project file is loaded) X-Git-Tag: 2.5.0~610 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=85a0e5ef831385250d4855b1a19b1ae561f14f0c;p=bertos.git Add Wizard version check (to change the way the project file is loaded) git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3293 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/_wizard_version.py b/wizard/_wizard_version.py new file mode 100644 index 00000000..da574507 --- /dev/null +++ b/wizard/_wizard_version.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# 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 2010 Develer S.r.l. (http://www.develer.com/) +# +# $Id$ +# +# Author: Lorenzo Berni +# + + +# This variable contains the wizard version. This will be stored into the +# project files to let the Wizard know how to use them. +# Previous versions: +# 0 - the project file doesn't contain the version number. +# When the current Wizard is opening project done with this version of +# the Wizard it has to change the origina SOURCES_PATH to the local path +# 1 - this is the current version. No special behaviours needed. + + +# NOTE: Change this variable may cause the wizard to not work properly. +WIZARD_VERSION = 1 diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index dc2172d7..98fd23dd 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -47,6 +47,8 @@ import plugins import DefineException import BProject +from _wizard_version import WIZARD_VERSION + from LoadException import VersionException, ToolchainException def isBertosDir(directory): @@ -59,6 +61,10 @@ def loadBertosProject(project_file, info_dict): project_data = pickle.loads(open(project_file, "r").read()) project_info = BProject.BProject() project_info.setInfo("PROJECT_PATH", os.path.dirname(project_file)) + # Check for the Wizard version + wizard_version = project_data.get("WIZARD_VERSION", 0) + if not wizard_version: + project_data["SOURCES_PATH"] = os.path.dirname(project_file) if "SOURCES_PATH" in info_dict: project_data["SOURCES_PATH"] = info_dict["SOURCES_PATH"] if os.path.exists(project_data["SOURCES_PATH"]): @@ -142,6 +148,7 @@ def projectFileGenerator(project_info): project_data["CPU_NAME"] = project_info.info("CPU_NAME") project_data["SELECTED_FREQ"] = project_info.info("SELECTED_FREQ") project_data["OUTPUT"] = project_info.info("OUTPUT") + project_data["WIZARD_VERSION"] = WIZARD_VERSION return pickle.dumps(project_data) def createBertosProject(project_info, edit=False): @@ -439,7 +446,12 @@ def getToolchainName(toolchain_info): return name def loadSourceTree(project): - fileList = [f for f in os.walk(project.info("SOURCES_PATH"))] + # Index only the SOURCES_PATH/bertos content + bertos_sources_dir = os.path.join(project.info("SOURCES_PATH"), 'bertos') + if os.path.exists(bertos_sources_dir): + fileList = [f for f in os.walk(bertos_sources_dir)] + else: + fileList = [] project.setInfo("FILE_LIST", fileList) def findDefinitions(ftype, project):