# 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")
def _writeUserMkFile(self):
bertos_utils.userMkGenerator(self)
+ def _writeUserMkFileFromPreset(self):
+ bertos_utils.userMkGeneratorFromPreset(self)
+
def _writeWizardMkFile(self):
bertos_utils.mkGenerator(self)
# 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",
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")