Copy the user mk file of the preset, replacing the old preset name with the project...
[bertos.git] / wizard / BProject.py
index eadf9a7c784737861bc96d776664cb6a2034b209..a9d285b90ac4522983a367ff99086515e8bd4282 100644 (file)
@@ -86,8 +86,7 @@ class BProject(object):
         # NOTE: this can throw an Exception if the user has changed the directory containing the project
         self.infos["PROJECT_NAME"] = project_data.get("PROJECT_NAME", os.path.basename(project_dir))
         self.infos["PROJECT_PATH"] = os.path.dirname(project_file)
-        project_src_path = project_data.get("PROJECT_SRC_PATH", None)
-        project_src_path = os.path.join(project_dir, project_data.get("PROJECT_SRC_PATH", None))
+        project_src_path = os.path.join(project_dir, project_data.get("PROJECT_SRC_PATH", project_data["PROJECT_NAME"]))
         if project_src_path:
             self.infos["PROJECT_SRC_PATH"] = project_src_path
             
@@ -312,7 +311,7 @@ class BProject(object):
         # VERSION file
         self._writeVersionFile(os.path.join(self.maindir, "VERSION"))
         # Destination makefile
-        self._writeMakefile(os.path.join(self.maindir, "Makefile"))
+        self._writeMakefile()
         # Copy the sources
         self._copySources(self.sources_dir, self.srcdir)
         # Set properly the autoenabled parameters
@@ -320,7 +319,7 @@ class BProject(object):
         # Copy all the configuration files
         self._writeCfgFiles(self.sources_dir, self.cfgdir)
         # Destination wizard mk file
-        self._writeWizardMkFile(os.path.join(self.prjdir, os.path.basename(self.prjdir) + "_wiz.mk"))
+        self._writeWizardMkFile()
 
     def _newCustomBertosProject(self):
         # Create/write/copy the common things
@@ -330,7 +329,7 @@ class BProject(object):
         # Copy all the hw files
         self._writeHwFiles(self.sources_dir, self.hwdir)
         # Destination user mk file
-        self._writeUserMkFile(os.path.join(self.prjdir, os.path.basename(self.prjdir) + ".mk"))
+        self._writeUserMkFile()
         # Destination main.c file
         self._writeMainFile(self.prjdir + "/main.c")
         # Create project files for selected plugins
@@ -340,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")
@@ -358,13 +360,13 @@ class BProject(object):
             # VERSION file
             self._writeVersionFile(os.path.join(self.maindir, "VERSION"))
             # Destination makefile
-            self._writeMakefile(os.path.join(self.maindir, "Makefile"))
+            self._writeMakefile()
             # Merge sources
             self._mergeSources(self.sources_dir, self.srcdir, self.old_srcdir)
             # Copy all the hw files
             self._writeHwFiles(self.sources_dir, self.hwdir)
             # Destination wizard mk file
-            self._writeWizardMkFile(os.path.join(self.prjdir, os.path.basename(self.prjdir) + "_wiz.mk"))
+            self._writeWizardMkFile()
         # Set properly the autoenabled parameters
         self._setupAutoenabledParameters()
         # Copy all the configuration files
@@ -390,14 +392,17 @@ class BProject(object):
         f.write(projectFileGenerator(self))
         f.close()
 
-    def _writeMakefile(self, filename):
-        bertos_utils.makefileGenerator(self, filename)
+    def _writeMakefile(self):
+        bertos_utils.makefileGenerator(self)
+
+    def _writeUserMkFile(self):
+        bertos_utils.userMkGenerator(self)
 
-    def _writeUserMkFile(self, filename):
-        bertos_utils.userMkGenerator(self, filename)
+    def _writeUserMkFileFromPreset(self):
+        bertos_utils.userMkGeneratorFromPreset(self)
 
-    def _writeWizardMkFile(self, filename):
-        bertos_utils.mkGenerator(self, filename)
+    def _writeWizardMkFile(self):
+        bertos_utils.mkGenerator(self)
 
     def _writeMainFile(self, filename):
         main = open(os.path.join(const.DATA_DIR, "srctemplates/main.c"), "r").read()
@@ -433,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",