New makefile architecture.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 10:25:09 +0000 (10:25 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 10:25:09 +0000 (10:25 +0000)
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
wizard/bertos_utils.py
wizard/compatibility.py
wizard/mktemplates/Makefile
wizard/mktemplates/template.mk
wizard/mktemplates/template_user.mk [new file with mode: 0644]
wizard/mktemplates/template_wiz.mk [deleted file]

index eadf9a7c784737861bc96d776664cb6a2034b209..b3116d70390044b23c6a202e3153f74977bfa96e 100644 (file)
@@ -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()
index 4589de3bf8bd2ca767beff5b1bc9ae38474b778a..c0dc0867b0088095bc27a64a0e7afdc56f33b55a 100644 (file)
@@ -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):
index 22cd4f70f4372aab06f344d1c95948d889d4d54f..4d873f64b6969031e53662e574c1b4de42e7d48c 100644 (file)
@@ -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"))
index d266fc9fdd7fbb13757074dfda9243bf606d71ea..024e79b71280962f52245c9409e36e7025b8aa69 100644 (file)
@@ -12,6 +12,6 @@ default: all
 
 include bertos/config.mk
 
-include $pname/$pname.mk
+include $ppath/$pname.mk
 
 include bertos/rules.mk
index 4e1b84403f8b4cba34e7dff9f11bfea1d3fe2fb4..ca87743f103fd1f70c5f70fe97126c18f86bcd2a 100644 (file)
@@ -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 (file)
index 0000000..230efd5
--- /dev/null
@@ -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 <duplo@develer.com>
+#
+#
+
+# 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 (file)
index 8edc07c..0000000
+++ /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 <duplo@develer.com>
-#
-#
-
-# 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