From: duplo Date: Tue, 27 Apr 2010 15:32:28 +0000 (+0000) Subject: Copy the user mk file of the preset, replacing the old preset name with the project... X-Git-Tag: 2.5.0~358 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;ds=sidebyside;h=a8288de715df399717bfcc381e47af79642988e8;p=bertos.git Copy the user mk file of the preset, replacing the old preset name with the project name. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3550 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BProject.py b/wizard/BProject.py index 79e4477f..a9d285b9 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -339,9 +339,12 @@ class BProject(object): # Create/write/copy the common things self._newBertosProject() - # Copy all the files and dirs except cfg/hw/*_wiz.mk + # Copy all the files and dirs except cfg/hw/*.mk self._writeCustomSrcFiles() + # Copyt the new *_user.mk file + self._writeUserMkFileFromPreset() + if self.infos["EMPTY_MAIN"]: # Create and empty main.c file only if the user check the box self._writeMainFile(self.prjdir + "/main.c") @@ -395,6 +398,9 @@ class BProject(object): def _writeUserMkFile(self): bertos_utils.userMkGenerator(self) + def _writeUserMkFileFromPreset(self): + bertos_utils.userMkGeneratorFromPreset(self) + def _writeWizardMkFile(self): bertos_utils.mkGenerator(self) @@ -432,7 +438,8 @@ class BProject(object): # Files to be ignored (all project files, cfg dir, wizard mk file, all global ignored dirs) project_related_stuff = ( "cfg", - self.infos["PRESET_NAME"] + "_wiz.mk", + self.infos["PRESET_NAME"] + ".mk", + self.infos["PRESET_NAME"] + "_user.mk", "project.bertos", self.infos["PRESET_NAME"] + ".project", self.infos["PRESET_NAME"] + ".workspace", diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 8d4b6449..6afc8db2 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -140,6 +140,20 @@ def versionFileGenerator(project_info, version_file): version = bertosVersion(project_info.info("BERTOS_PATH")) return version_file.replace('$version', version) +def userMkGeneratorFromPreset(project_info): + project_name = project_info.info("PROJECT_NAME") + preset_path = project_info.info("PRESET_PATH") + preset_name = project_info.info("PRESET_NAME") + preset_src_dir = project_info.info("PRESET_SRC_PATH") + makefile = open(os.path.join(preset_path, preset_src_dir, "%s_user.mk" %preset_name), 'r').read() + destination = os.path.join(project_info.prjdir, "%s_user.mk" %project_info.info("PROJECT_NAME")) + # Temporary code. + # TODO: write it using regular expressions to secure this function + if preset_name != project_name: + while makefile.find(preset_name + "_") != -1: + makefile = makefile.replace(preset_name + "_", project_name + "_") + open(destination, "w").write(makefile) + def userMkGenerator(project_info): makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template_user.mk"), "r").read() destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + "_user.mk")