Change module definition in order to contain hw dependency
[bertos.git] / wizard / bertos_utils.py
index 5d3edd6900b8ea1aabdf1b34fae233649bb1568d..fe346e8f12f41d8a19cb30ce736115efaa157c34 100644 (file)
@@ -4,7 +4,7 @@
 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
 # All rights reserved.
 #
-# $Id:$
+# $Id$
 #
 # Author: Lorenzo Berni <duplo@develer.com>
 #
@@ -14,6 +14,8 @@ import fnmatch
 import glob
 import re
 import shutil
+# Use custom copytree function
+import copytree
 import pickle
 
 import const
@@ -37,7 +39,7 @@ def createBertosProject(project_info):
     # Destination source dir
     srcdir = directory + "/bertos"
     shutil.rmtree(srcdir, True)
-    shutil.copytree(sources_dir + "/bertos", srcdir)
+    copytree.copytree(sources_dir + "/bertos", srcdir, ignore_list=const.IGNORE_LIST)
     # Destination makefile
     makefile = directory + "/Makefile"
     if os.path.exists(makefile):
@@ -53,13 +55,21 @@ def createBertosProject(project_info):
     cfgdir = prjdir + "/cfg"
     shutil.rmtree(cfgdir, True)
     os.mkdir(cfgdir)
+    # Set to 1 the autoenabled for enabled modules
+    for module, information in project_info.info("MODULES").items():
+        if information["enabled"] and "configuration" in information and information["configuration"] != "":
+            configurations = project_info.info("CONFIGURATIONS")
+            configuration = configurations[information["configuration"]]
+            for start, parameter in configuration["paramlist"]:
+                if "type" in configuration[parameter] and configuration[parameter]["type"] == "autoenabled":
+                    configuration[parameter]["value"] = "1"
+            project_info.setInfo("CONFIGURATIONS", configurations)
+    # Copy all the configuration files
     for configuration, information in project_info.info("CONFIGURATIONS").items():
         string = open(sources_dir + "/" + configuration, "r").read()
         for start, parameter in information["paramlist"]:
             infos = information[parameter]
             value = infos["value"]
-            if "type" in infos["informations"] and infos["informations"]["type"] == "autoenabled":
-                value = "1"
             if "unsigned" in infos["informations"].keys() and infos["informations"]["unsigned"]:
                 value += "U"
             if "long" in infos["informations"].keys() and infos["informations"]["long"]:
@@ -87,6 +97,7 @@ def mkGenerator(project_info, makefile):
     mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH"))
     mk_data["$cpuflag"] = project_info.info("CPU_INFOS")["CPU_FLAG_NAME"]
     mk_data["$cpuname"] = project_info.info("CPU_INFOS")["CORE_CPU"]
+    mk_data["$cpuclockfreq"] = project_info.info("SELECTED_FREQ")
     mk_data["$cflags"] = " ".join(project_info.info("CPU_INFOS")["C_FLAGS"])
     mk_data["$ldflags"] = " ".join(project_info.info("CPU_INFOS")["LD_FLAGS"])
     mk_data["$cppflags"] = " ".join(project_info.info("CPU_INFOS")["CPP_FLAGS"])