Copy the user mk file of the preset, replacing the old preset name with the project...
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 15:32:28 +0000 (15:32 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 15:32:28 +0000 (15:32 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3550 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BProject.py
wizard/bertos_utils.py

index 79e4477fe57fbed51da28c3561497faec3290195..a9d285b90ac4522983a367ff99086515e8bd4282 100644 (file)
@@ -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",
index 8d4b644917a0664c8905ac0beac9dbf1ceee3bc1..6afc8db2222907c39fe3d4ecb3fe3cf4fc2193d5 100644 (file)
@@ -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")