- def _createDestinationDirectory(self, maindir, edit=False):
- if not edit:
- if os.path.isdir(maindir):
- shutil.rmtree(maindir, True)
- os.makedirs(maindir)
-
- def _createProjectDir(self, maindir, edit=False):
- prjdir = os.path.join(maindir, self.infos["PROJECT_NAME"])
- if not edit:
- shutil.rmtree(prjdir, True)
- os.mkdir(prjdir)
- return prjdir
-
- def _createHwFilesDir(self, prjdir, edit=False):
- hwdir = prjdir + "/hw"
- if not edit:
- shutil.rmtree(hwdir, True)
- os.mkdir(hwdir)
- return hwdir
-
- def _createCfgFilesDir(self, prjdir, edit=False):
- cfgdir = prjdir + "/cfg"
- if not edit:
- shutil.rmtree(cfgdir, True)
- os.mkdir(cfgdir)
- return cfgdir
+ # Project related properties
+ @property
+ def maindir(self):
+ return self.infos.get("PROJECT_PATH", None)
+
+ @property
+ def srcdir(self):
+ if self.maindir:
+ return os.path.join(self.maindir, "bertos")
+ else:
+ return None
+
+ @property
+ def prjdir(self):
+ return self.infos.get("PROJECT_SRC_PATH", None)
+
+ @property
+ def hwdir(self):
+ if self.prjdir:
+ return os.path.join(self.prjdir, "hw")
+ else:
+ return None
+
+ @property
+ def cfgdir(self):
+ if self.prjdir:
+ return os.path.join(self.prjdir, "cfg")
+ else:
+ return None
+
+ @property
+ def old_srcdir(self):
+ return self.infos.get("OLD_BERTOS_PATH", None)
+
+ # BeRTOS sources related properties
+ @property
+ def bertos_maindir(self):
+ return self.infos.get("BERTOS_PATH", None)
+
+ @property
+ def bertos_srcdir(self):
+ if self.bertos_maindir:
+ return os.path.join(self.bertos_maindir, "bertos")
+ else:
+ return None
+
+ @property
+ def src_hwdir(self):
+ if self.from_preset:
+ return os.path.join(self.infos["PRESET_PATH"], self.infos["PRESET_HW_PATH"])
+ else:
+ return self.bertos_maindir
+
+ @property
+ def from_preset(self):
+ return self.infos.get("PROJECT_FROM_PRESET", False)
+
+ @property
+ def is_preset(self):
+ return self.infos.get("PRESET", False)
+
+ def _createDirectory(self, directory):
+ if not directory:
+ return
+ if os.path.isdir(directory):
+ shutil.rmtree(directory, True)
+ os.makedirs(directory)
+
+ def _copySources(self, origin, destination):
+ # If not in editing mode it copies all the bertos sources in the /bertos subdirectory of the project
+ shutil.rmtree(destination, True)
+ copytree.copytree(origin + "/bertos", destination, ignore_list=const.IGNORE_LIST)
+
+ def _mergeSources(self, origin, destination, old_sources_dir):
+ if old_sources_dir:
+ mergeSources(destination, origin, old_sources_dir)