Add support for parametric hw dir.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 29 Apr 2010 12:21:12 +0000 (12:21 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 29 Apr 2010 12:21:12 +0000 (12:21 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3570 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BFolderPage.py
wizard/BProject.py
wizard/bertos_utils.py
wizard/mktemplates/template.mk

index 3b3bce8956ba0cc523191dbfcce1dd14ad9711d4..eaa5d02f11b4eb94ed57c7bf7d552bc2fb85861d 100644 (file)
@@ -66,6 +66,7 @@ class BFolderPage(BWizardPage):
             self.setProjectInfo("PROJECT_PATH", unicode(self.pageContent.projectPath.text()))
             self.setProjectInfo("PROJECT_NAME", os.path.basename(unicode(self.pageContent.projectPath.text())))
             self.setProjectInfo("PROJECT_SRC_PATH", os.path.join(self.projectInfo("PROJECT_PATH"), self.projectInfo("PROJECT_NAME")))
+            self.setProjectInfo("HW_PATH", os.path.join(self.projectInfo("PROJECT_PATH"), self.projectInfo("PROJECT_NAME")))
             self.setProjectInfo("ROUTE", self.next_page)
             self.setProjectInfo("PROJECT_FROM_PRESET", self.from_preset)
             return True
index a9d285b90ac4522983a367ff99086515e8bd4282..798a96a9539c2a27eadbdf6de91df59f3840eef4 100644 (file)
@@ -93,6 +93,7 @@ class BProject(object):
         else:
             # In projects created with older versions of the Wizard this metadata doesn't exist
             self.infos["PROJECT_SRC_PATH"] = os.path.join(self.infos["PROJECT_PATH"], self.infos["PROJECT_NAME"])
+        self.infos["HW_PATH"] = os.path.join(self.infos["PROJECT_PATH"], project_data.get("HW_PATH", self.infos["PROJECT_PATH"]))
 
         linked_sources_path = project_data["BERTOS_PATH"]
         sources_abspath = os.path.abspath(os.path.join(project_dir, linked_sources_path))
@@ -167,6 +168,7 @@ class BProject(object):
         # TODO: find a better way to reuse loadModuleData
         preset_project_name = project_data.get("PROJECT_NAME", os.path.basename(preset))
         preset_prj_src_path = os.path.join(preset, project_data.get("PROJECT_SRC_PATH", os.path.join(preset, preset_project_name)))
+        preset_hw_path = os.path.join(preset, project_data.get("PROJET_HW_DIR", preset))
 
         old_project_name = self.infos["PROJECT_NAME"]
         old_project_path = self.infos["PROJECT_PATH"]
@@ -187,6 +189,7 @@ class BProject(object):
         self.infos["PRESET_NAME"] = preset_project_name
         self.infos["PRESET_PATH"] = preset
         self.infos["PRESET_SRC_PATH"] = preset_prj_src_path
+        self.infos["PRESET_HW_DIR"] = preset_hw_path
 
     def loadProjectPresets(self):
         """
@@ -304,7 +307,7 @@ class BProject(object):
                 self._newBertosProjectFromPreset()
 
     def _newBertosProject(self):
-        for directory in (self.maindir, self.srcdir, self.prjdir, self.cfgdir):
+        for directory in (self.maindir, self.srcdir, self.prjdir, self.cfgdir, self.hwdir):
             self._createDirectory(directory)
         # Write the project file
         self._writeProjectFile(os.path.join(self.maindir, "project.bertos"))
@@ -341,6 +344,9 @@ class BProject(object):
 
         # Copy all the files and dirs except cfg/hw/*.mk
         self._writeCustomSrcFiles()
+        
+        # Copy the hw files
+        self._writeHwFiles(self.src_hwdir, self.hwdir)
 
         # Copyt the new *_user.mk file
         self._writeUserMkFileFromPreset()
@@ -438,6 +444,7 @@ class BProject(object):
         # Files to be ignored (all project files, cfg dir, wizard mk file, all global ignored dirs)
         project_related_stuff = (
             "cfg",
+            "hw",
             self.infos["PRESET_NAME"] + ".mk",
             self.infos["PRESET_NAME"] + "_user.mk",
             "project.bertos",
@@ -499,6 +506,13 @@ class BProject(object):
     def sources_dir(self):
         return self.infos.get("BERTOS_PATH", None)
 
+    @property
+    def src_hwdir(self):
+        if self.from_preset:
+            return os.path.join(self.infos["PRESET_PATH"], self.infos["PRESET_HW_DIR"])
+        else:
+            return self.sources_dir
+
     @property
     def from_preset(self):
         return self.infos.get("PROJECT_FROM_PRESET", False)
index a6bef914e904d6d989f74ba1282e645333c4176e..f5be4429225d0298294b5a22469cc8bce5dd3863 100644 (file)
@@ -128,6 +128,7 @@ def projectFileGenerator(project_info):
     project_data["OUTPUT"] = project_info.info("OUTPUT")
     project_data["WIZARD_VERSION"] = WIZARD_VERSION
     project_data["PRESET"] = project_info.info("PRESET")
+    project_data["HW_PATH"] = relpath.relpath(project_info.info("HW_PATH"), directory)
     return pickle.dumps(project_data)
 
 def loadPlugin(plugin):
@@ -182,6 +183,7 @@ def mkGenerator(project_info):
     mk_data["$csrc"], mk_data["$pcsrc"], mk_data["$cppasrc"], mk_data["$cxxsrc"], mk_data["$asrc"], mk_data["$constants"] = csrcGenerator(project_info)
     mk_data["$prefix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[0])
     mk_data["$suffix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[1])
+    mk_data["$hwpath"] = relpath.relpath(project_info.info("HW_PATH"), project_info.info("PROJECT_PATH"))
     for key in mk_data:
         makefile = makefile.replace(key, mk_data[key])
     open(destination, "w").write(makefile)
@@ -195,7 +197,7 @@ def makefileGenerator(project_info):
     # TODO write a general function that works for both the mk file and the Makefile
     mk_data = {}
     mk_data["$pname"] = project_info.info("PROJECT_NAME")
-    mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH"))
+    mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH"))
     for key in mk_data:
         makefile = makefile.replace(key, mk_data[key])
     open(destination, "w").write(makefile)
index 801fa5110b4979d24fa1bbd04fb6b56b5baa5f46..cf63352d7a3e257be4dd2099ad182c74a1822b35 100644 (file)
@@ -15,6 +15,8 @@ $pname_SUFFIX = "$suffix"
 
 $pname_SRC_PATH = $ppath
 
+$pname_HW_PATH = $hwpath
+
 # Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CSRC INSTEAD!
 $pname_WIZARD_CSRC = \
        $csrc
@@ -40,7 +42,7 @@ $pname_WIZARD_ASRC = \
        $asrc
        #
 
-$pname_CPPFLAGS = -D'CPU_FREQ=($cpuclockfreqUL)' -D'ARCH=(ARCH_DEFAULT)' -D'WIZ_AUTOGEN' -I$pname/ $($pname_CPU_CPPFLAGS) $($pname_USER_CPPFLAGS)
+$pname_CPPFLAGS = -D'CPU_FREQ=($cpuclockfreqUL)' -D'ARCH=(ARCH_DEFAULT)' -D'WIZ_AUTOGEN' -I$($pname_HW_PATH) -I$($pname_SRC_PATH) $($pname_CPU_CPPFLAGS) $($pname_USER_CPPFLAGS)
 
 # Automatically generated by the wizard. PLEASE DO NOT EDIT!
 $pname_LDFLAGS = $($pname_CPU_LDFLAGS) $($pname_WIZARD_LDFLAGS) $($pname_USER_LDFLAGS)