move config parsing out of the matrix module (and fix the graph module)
authorTimo Savola <tsavola@movial.fi>
Thu, 10 Apr 2008 19:46:34 +0000 (22:46 +0300)
committerTimo Savola <tsavola@movial.fi>
Thu, 10 Apr 2008 19:46:34 +0000 (22:46 +0300)
matrix/config.py
matrix/graph.py
matrix/matrix.py

index 2ca4f20..6b9b5d5 100644 (file)
@@ -46,3 +46,13 @@ def PlatformProvidedComponent(*args, **kwargs):
        c = _components.PlatformProvidedComponent(*args, **kwargs)
        components[c.name] = c
        return c
+
+def parse(path):
+       if _os.path.isabs(path):
+               path = _os.path.join(top_dir, path)
+
+       if _os.path.exists(path):
+               if debug:
+                       print 'Reading', path
+
+               execfile(path, globals(), globals())
index 8805844..6340836 100644 (file)
@@ -4,8 +4,8 @@
 import os
 import sys
 
+import components
 import config
-import matrix
 
 
 class Option(object):
@@ -64,13 +64,13 @@ class Graph(object):
                        pass
 
                try:
-                       matrix.parse_config(self.options["components"].argument)
+                       config.parse(self.options["components"].argument)
                except KeyError:
                        # Default to components.all
-                       matrix.parse_config('components/components.all')
+                       config.parse('components/components.all')
                        print "huuhaaaaaa"
 
-               matrix.update_components()
+               components.init()
 
                try:
                        self.maxdepth = int(self.options["depth"].argument)
index 8d0edf9..c6fb388 100644 (file)
@@ -19,13 +19,13 @@ from rootfs import RootFS
 Error = RuntimeError
 
 def main():
-       parse_config('config.local')
+       config.parse('config.local')
 
        command, params, targets = parse_args(sys.argv)
 
-       parse_config('config')
-       parse_config('boards')
-       parse_config('components')
+       config.parse('config')
+       config.parse('boards')
+       config.parse('components')
 
        if 'global-cache' in config.flags:
                config.cache_dir = config.global_cache_dir
@@ -165,16 +165,6 @@ def parse_args(args):
 
        return command, params, targets
 
-def parse_config(path):
-       if os.path.isabs(path):
-               path = os.path.join(config.top_dir, path)
-
-       if os.path.exists(path):
-               if config.debug:
-                       print 'Reading', path
-
-               execfile(path, config.__dict__, config.__dict__)
-
 def execute(args):
        if config.debug:
                print 'Executing:', ' '.join(args)
@@ -262,7 +252,7 @@ def dist_sources(c, location):
        c.repo.archive(name, path)
 
 def build_rootfs(clean=True, rootfs_only=False, jffs2_only=False, devrootfs_only=False):
-       parse_config('rootfs')
+       config.parse('rootfs')
 
        f = os.popen('sb-conf cu')
        target = f.read()