From f89fe8efdb8b81d7d1f29e241df3b40042c42712 Mon Sep 17 00:00:00 2001 From: duplo Date: Tue, 27 Apr 2010 10:25:09 +0000 Subject: [PATCH] New makefile architecture. NOTE: all the new infrastructure is under development. IT HAS TO BE TESTED HEAVILY. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3533 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BProject.py | 22 ++++----- wizard/bertos_utils.py | 23 ++++++--- wizard/compatibility.py | 9 ++-- wizard/mktemplates/Makefile | 2 +- wizard/mktemplates/template.mk | 76 +++++++++++++++++++---------- wizard/mktemplates/template_user.mk | 50 +++++++++++++++++++ wizard/mktemplates/template_wiz.mk | 71 --------------------------- 7 files changed, 133 insertions(+), 120 deletions(-) create mode 100644 wizard/mktemplates/template_user.mk delete mode 100644 wizard/mktemplates/template_wiz.mk diff --git a/wizard/BProject.py b/wizard/BProject.py index eadf9a7c..b3116d70 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -312,7 +312,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 +320,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 +330,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 @@ -358,13 +358,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 +390,14 @@ 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, filename): - bertos_utils.userMkGenerator(self, filename) + def _writeUserMkFile(self): + bertos_utils.userMkGenerator(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() diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index 4589de3b..c0dc0867 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -138,24 +138,28 @@ def versionFileGenerator(project_info, version_file): version = bertosVersion(project_info.info("BERTOS_PATH")) return version_file.replace('$version', version) -def userMkGenerator(project_info, destination): - makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template.mk"), "r").read() +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") # Deadly performances loss was here :( mk_data = {} mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH")) + mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c" for key in mk_data: while makefile.find(key) != -1: makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) -def mkGenerator(project_info, destination): +def mkGenerator(project_info): """ Generates the mk file for the current project. """ - makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template_wiz.mk"), "r").read() + makefile = open(os.path.join(const.DATA_DIR, "mktemplates/template.mk"), "r").read() + destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + ".mk") mk_data = {} mk_data["$pname"] = project_info.info("PROJECT_NAME") + mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) mk_data["$cpuclockfreq"] = project_info.info("SELECTED_FREQ") cpu_mk_parameters = [] for key, value in project_info.info("CPU_INFOS").items(): @@ -171,14 +175,19 @@ def mkGenerator(project_info, destination): makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) -def makefileGenerator(project_info, destination): +def makefileGenerator(project_info): """ Generate the Makefile for the current project. """ makefile = open(os.path.join(const.DATA_DIR, "mktemplates/Makefile"), "r").read() + destination = os.path.join(project_info.maindir, "Makefile") # TODO write a general function that works for both the mk file and the Makefile - while makefile.find("$pname") != -1: - makefile = makefile.replace("$pname", project_info.info("PROJECT_NAME")) + mk_data = {} + mk_data["$pname"] = project_info.info("PROJECT_NAME") + mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH")) + for key in mk_data: + while makefile.find(key) != -1: + makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) def csrcGenerator(project_info): diff --git a/wizard/compatibility.py b/wizard/compatibility.py index 22cd4f70..4d873f64 100644 --- a/wizard/compatibility.py +++ b/wizard/compatibility.py @@ -37,8 +37,9 @@ import const import os from bertos_utils import replaceSeparators, csrcGenerator -def _userMkGenerator(project_info, destination): +def _userMkGenerator(project_info): makefile = open(os.path.join(const.DATA_DIR, "mktemplates/old/template.mk"), "r").read() + destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + ".mk") # Deadly performances loss was here :( mk_data = {} mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH")) @@ -48,11 +49,12 @@ def _userMkGenerator(project_info, destination): makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) -def _mkGenerator(project_info, destination): +def _mkGenerator(project_info): """ Generates the mk file for the current project. """ makefile = open(os.path.join(const.DATA_DIR, "mktemplates/old/template_wiz.mk"), "r").read() + destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + "_wiz.mk") mk_data = {} mk_data["$pname"] = project_info.info("PROJECT_NAME") mk_data["$cpuclockfreq"] = project_info.info("SELECTED_FREQ") @@ -70,11 +72,12 @@ def _mkGenerator(project_info, destination): makefile = makefile.replace(key, mk_data[key]) open(destination, "w").write(makefile) -def _makefileGenerator(project_info, destination): +def _makefileGenerator(project_info): """ Generate the Makefile for the current project. """ makefile = open(os.path.join(const.DATA_DIR, "mktemplates/old/Makefile"), "r").read() + destination = os.path.join(project_info.maindir, "Makefile") # TODO write a general function that works for both the mk file and the Makefile while makefile.find("$pname") != -1: makefile = makefile.replace("$pname", project_info.info("PROJECT_NAME")) diff --git a/wizard/mktemplates/Makefile b/wizard/mktemplates/Makefile index d266fc9f..024e79b7 100644 --- a/wizard/mktemplates/Makefile +++ b/wizard/mktemplates/Makefile @@ -12,6 +12,6 @@ default: all include bertos/config.mk -include $pname/$pname.mk +include $ppath/$pname.mk include bertos/rules.mk diff --git a/wizard/mktemplates/template.mk b/wizard/mktemplates/template.mk index 4e1b8440..ca87743f 100644 --- a/wizard/mktemplates/template.mk +++ b/wizard/mktemplates/template.mk @@ -8,44 +8,66 @@ # # -# Programmer interface configuration, see http://dev.bertos.org/wiki/ProgrammerInterface for help -$pname_PROGRAMMER_TYPE = none -$pname_PROGRAMMER_PORT = none +# Constants automatically defined by the selected modules +$constants -# Files included by the user. -$pname_USER_CSRC = \ - $main \ - # +# Our target application +TRG += $pname -# Files included by the user. -$pname_USER_PCSRC = \ - # +$pname_PREFIX = "$prefix" -# Files included by the user. -$pname_USER_CPPASRC = \ - # +$pname_SUFFIX = "$suffix" -# Files included by the user. -$pname_USER_CXXSRC = \ +# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CSRC INSTEAD! +$pname_WIZARD_CSRC = \ + $csrc # -# Files included by the user. -$pname_USER_ASRC = \ +# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_PCSRC INSTEAD! +$pname_WIZARD_PCSRC = \ + $pcsrc # -# Flags included by the user. -$pname_USER_LDFLAGS = \ +# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CPPASRC INSTEAD! +$pname_WIZARD_CPPASRC = \ + $cppasrc # -# Flags included by the user. -$pname_USER_CPPAFLAGS = \ +# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CXXSRC INSTEAD! +$pname_WIZARD_CXXSRC = \ + $cxxsrc # -# Flags included by the user. -$pname_USER_CPPFLAGS = \ - -fno-strict-aliasing \ - -fwrapv \ +# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_ASRC INSTEAD! +$pname_WIZARD_ASRC = \ + $asrc # -# Include the mk file generated by the wizard -include $pname/$pname_wiz.mk +$pname_CPPFLAGS = -D'CPU_FREQ=($cpuclockfreqUL)' -D'ARCH=(ARCH_DEFAULT)' -D'WIZ_AUTOGEN' -I$pname/ $($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) + +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$pname_CPPAFLAGS = $($pname_CPU_CPPAFLAGS) $($pname_WIZARD_CPPAFLAGS) $($pname_USER_CPPAFLAGS) + +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$pname_CSRC = $($pname_CPU_CSRC) $($pname_WIZARD_CSRC) $($pname_USER_CSRC) + +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$pname_PCSRC = $($pname_CPU_PCSRC) $($pname_WIZARD_PCSRC) $($pname_USER_PCSRC) + +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$pname_CPPASRC = $($pname_CPU_CPPASRC) $($pname_WIZARD_CPPASRC) $($pname_USER_CPPASRC) + +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$pname_CXXSRC = $($pname_CPU_CXXSRC) $($pname_WIZARD_CXXSRC) $($pname_USER_CXXSRC) + +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$pname_ASRC = $($pname_CPU_ASRC) $($pname_WIZARD_ASRC) $($pname_USER_ASRC) + +# CPU specific flags and options, defined in the CPU definition files. +# Automatically generated by the wizard. PLEASE DO NOT EDIT! +$cpuparameters + +include $ppath/$pname_user.mk diff --git a/wizard/mktemplates/template_user.mk b/wizard/mktemplates/template_user.mk new file mode 100644 index 00000000..230efd58 --- /dev/null +++ b/wizard/mktemplates/template_user.mk @@ -0,0 +1,50 @@ +# +# Copyright 2009 Develer S.r.l. (http://www.develer.com/) +# All rights reserved. +# +# Makefile template for BeRTOS wizard. +# +# Author: Lorenzo Berni +# +# + +# Programmer interface configuration, see http://dev.bertos.org/wiki/ProgrammerInterface for help +$pname_PROGRAMMER_TYPE = none +$pname_PROGRAMMER_PORT = none + +# Files included by the user. +$pname_USER_CSRC = \ + $main \ + # + +# Files included by the user. +$pname_USER_PCSRC = \ + # + +# Files included by the user. +$pname_USER_CPPASRC = \ + # + +# Files included by the user. +$pname_USER_CXXSRC = \ + # + +# Files included by the user. +$pname_USER_ASRC = \ + # + +# Flags included by the user. +$pname_USER_LDFLAGS = \ + # + +# Flags included by the user. +$pname_USER_CPPAFLAGS = \ + # + +# Flags included by the user. +$pname_USER_CPPFLAGS = \ + -fno-strict-aliasing \ + -fwrapv \ + # + +# Include the mk file generated by the wizard diff --git a/wizard/mktemplates/template_wiz.mk b/wizard/mktemplates/template_wiz.mk deleted file mode 100644 index 8edc07c5..00000000 --- a/wizard/mktemplates/template_wiz.mk +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright 2009 Develer S.r.l. (http://www.develer.com/) -# All rights reserved. -# -# Makefile template for BeRTOS wizard. -# -# Author: Lorenzo Berni -# -# - -# Constants automatically defined by the selected modules -$constants - -# Our target application -TRG += $pname - -$pname_PREFIX = "$prefix" - -$pname_SUFFIX = "$suffix" - -# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CSRC INSTEAD! -$pname_WIZARD_CSRC = \ - $csrc - # - -# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_PCSRC INSTEAD! -$pname_WIZARD_PCSRC = \ - $pcsrc - # - -# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CPPASRC INSTEAD! -$pname_WIZARD_CPPASRC = \ - $cppasrc - # - -# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CXXSRC INSTEAD! -$pname_WIZARD_CXXSRC = \ - $cxxsrc - # - -# Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_ASRC INSTEAD! -$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) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_LDFLAGS = $($pname_CPU_LDFLAGS) $($pname_WIZARD_LDFLAGS) $($pname_USER_LDFLAGS) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_CPPAFLAGS = $($pname_CPU_CPPAFLAGS) $($pname_WIZARD_CPPAFLAGS) $($pname_USER_CPPAFLAGS) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_CSRC = $($pname_CPU_CSRC) $($pname_WIZARD_CSRC) $($pname_USER_CSRC) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_PCSRC = $($pname_CPU_PCSRC) $($pname_WIZARD_PCSRC) $($pname_USER_PCSRC) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_CPPASRC = $($pname_CPU_CPPASRC) $($pname_WIZARD_CPPASRC) $($pname_USER_CPPASRC) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_CXXSRC = $($pname_CPU_CXXSRC) $($pname_WIZARD_CXXSRC) $($pname_USER_CXXSRC) - -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$pname_ASRC = $($pname_CPU_ASRC) $($pname_WIZARD_ASRC) $($pname_USER_ASRC) - -# CPU specific flags and options, defined in the CPU definition files. -# Automatically generated by the wizard. PLEASE DO NOT EDIT! -$cpuparameters -- 2.25.1