Resolve the bug of the autoenabled modules
[bertos.git] / wizard / bertos_utils.py
index 191aad32f3643ef722ca67c4e044d49c0511bf0f..d8c5f515ad1069407ddb6fd352d61c5173a00037 100644 (file)
@@ -19,7 +19,7 @@ import copytree
 import pickle
 
 import const
-from plugins import codelite
+import plugins
 import DefineException
 
 def isBertosDir(directory):
@@ -70,7 +70,7 @@ def createBertosProject(project_info):
             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":
+                if "type" in configuration[parameter]["informations"] and configuration[parameter]["informations"]["type"] == "autoenabled":
                     configuration[parameter]["value"] = "1"
             project_info.setInfo("CONFIGURATIONS", configurations)
     # Copy all the configuration files
@@ -94,10 +94,19 @@ def createBertosProject(project_info):
     # Destination main.c file
     main = open("srctemplates/main.c", "r").read()
     open(prjdir + "/main.c", "w").write(main)
-    # Codelite project files
-    if "codelite" in project_info.info("OUTPUT"):
-        codelite.createProject(project_info)
-
+    # Files for selected plugins
+    relevants_files = {}
+    for plugin in project_info.info("OUTPUT"):
+        module = loadPlugin(plugin)
+        relevants_files[plugin] = module.createProject(project_info)
+    project_info.setInfo("RELEVANT_FILES", relevants_files)
+
+def loadPlugin(plugin):
+    """
+    Returns the given plugin module.
+    """
+    return getattr(__import__("plugins", {}, {}, [plugin]), plugin)
+    
 def mkGenerator(project_info, makefile):
     """
     Generates the mk file for the current project.