Aggiunte nuove meccaniche di load dei progetti e nuovi files di progetto.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 20 Jul 2009 14:27:16 +0000 (14:27 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 20 Jul 2009 14:27:16 +0000 (14:27 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2759 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py

index ec52a21050acd81b7d341fd2ba8f69c069724b49..567eeb7087975b3dd23eee8337c1a0faf8a34130 100644 (file)
@@ -45,6 +45,7 @@ import pickle
 import const
 import plugins
 import DefineException
+import BProject
 
 def isBertosDir(directory):
    return os.path.exists(directory + "/VERSION")
@@ -52,6 +53,40 @@ def isBertosDir(directory):
 def bertosVersion(directory):
    return open(directory + "/VERSION").readline().strip()
 
+def loadBertosProject(project_file):
+    project_data = pickle.loads(open(project_file, "r").read())
+    project_info = BProject.BProject()
+    project_info.setInfo("PROJECT_PATH", os.path.dirname(project_file))
+    project_info.setInfo("SOURCES_PATH", project_data["SOURCES_PATH"])
+    loadSourceTree(project_info)
+    cpu_name = project_data["CPU_NAME"]
+    project_info.setInfo("CPU_NAME", cpu_name)
+    cpu_info = loadCpuInfos(project_info)
+    for cpu in cpu_info:
+        print cpu["CPU_NAME"], cpu_name
+        if cpu["CPU_NAME"] == cpu_name:
+            print "sono uguali"
+            project_info.setInfo("CPU_INFOS", cpu)
+            break
+    loadModuleData(project_info)
+    print project_info
+
+
+def projectFileGenerator(project_info):
+    directory = project_info.info("PROJECT_PATH")
+    project_data = {}
+    enabled_modules = []
+    for module, information in project_info.info("MODULES").items():
+        if information["enabled"]:
+            enabled_modules.append(module)
+    project_data["ENABLED_MODULES"] = enabled_modules
+    project_data["SOURCES_PATH"] = project_info.info("SOURCES_PATH")
+    project_data["TOOLCHAIN"] = project_info.info("TOOLCHAIN")
+    project_data["CPU_NAME"] = project_info.info("CPU_NAME")
+    print project_info.info("CPU_NAME")
+    project_data["SELECTED_FREQ"] = project_info.info("SELECTED_FREQ")
+    return pickle.dumps(project_data)
+
 def createBertosProject(project_info):
     directory = project_info.info("PROJECT_PATH")
     sources_dir = project_info.info("SOURCES_PATH")
@@ -59,7 +94,7 @@ def createBertosProject(project_info):
         shutil.rmtree(directory, True)        
     os.makedirs(directory)
     f = open(directory + "/project.bertos", "w")
-    f.write(pickle.dumps(project_info))
+    f.write(projectFileGenerator(project_info))
     f.close()
     # Destination source dir
     srcdir = directory + "/bertos"
@@ -647,4 +682,4 @@ class ParseError(Exception):
 class SupportedException(Exception):
     def __init__(self, support_string):
         Exception.__init__(self)
-        self.support_string = support_string
\ No newline at end of file
+        self.support_string = support_string