- if not edit:
- # Destination user mk file (only on project creation)
- makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template.mk"), "r").read()
- # Deadly performances loss was here :(
- makefile = userMkGenerator(self, makefile)
- open(prjdir + "/" + os.path.basename(prjdir) + ".mk", "w").write(makefile)
- # Destination wizard mk file
- makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template_wiz.mk"), "r").read()
- makefile = mkGenerator(self, makefile)
- open(prjdir + "/" + os.path.basename(prjdir) + "_wiz.mk", "w").write(makefile)
- # Destination main.c file
- if not edit:
- main = open(os.path.join(const.DATA_DIR, "srctemplates/main.c"), "r").read()
- open(prjdir + "/main.c", "w").write(main)
- # Files for selected plugins
- relevants_files = {}
- for plugin in self.infos["OUTPUT"]:
- module = loadPlugin(plugin)
- relevants_files[plugin] = module.createProject(self)
- self.infos["RELEVANT_FILES"] = relevants_files
+
+ def _writeCustomSrcFiles(self):
+ origin = self.infos["PRESET_SRC_PATH"]
+ # Files to be ignored (all project files, cfg dir, wizard mk file, all global ignored dirs)
+ project_related_stuff = (
+ "cfg",
+ self.infos["PROJECT_NAME"] + "_wiz.mk",
+ "project.bertos",
+ self.infos["PROJECT_NAME"] + ".project",
+ self.infos["PROJECT_NAME"] + ".workspace",
+ ) + const.IGNORE_LIST
+ for element in os.listdir(origin):
+ if element not in project_related_stuff:
+ full_path = os.path.join(origin, element)
+ if os.path.isdir(full_path):
+ copytree.copytree(full_path, os.path.join(self.prjdir, element), ignore_list=const.IGNORE_LIST)
+ else:
+ shutil.copy(full_path, self.prjdir)
+
+ def _setupAutoenabledParameters(self):
+ for module, information in self.infos["MODULES"].items():
+ if "configuration" in information and information["configuration"] != "":
+ configurations = self.infos["CONFIGURATIONS"]
+ configuration = configurations[information["configuration"]]
+ for start, parameter in configuration["paramlist"]:
+ if "type" in configuration[parameter]["informations"] and configuration[parameter]["informations"]["type"] == "autoenabled":
+ configuration[parameter]["value"] = "1" if information["enabled"] else "0"
+ self.infos["CONFIGURATIONS"] = configurations
+
+ @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_SOURCES_PATH", None)
+
+ @property
+ def sources_dir(self):
+ return self.infos.get("SOURCES_PATH", None)
+
+ @property
+ def from_preset(self):
+ return self.infos.get("PROJECT_FROM_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)