]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: [parser] Make resolve_file only resolve the path
authorHolger Freyther <ich@tamarin.(none)>
Tue, 19 May 2009 11:59:50 +0000 (13:59 +0200)
committerRichard Purdie <rpurdie@linux.intel.com>
Mon, 15 Feb 2010 17:07:55 +0000 (17:07 +0000)
Do not attempt to open the file in the resolve_file method
(a lot like bb.which... maybe bb.which can be used). This way
we don't need to open/close a file which we have already parsed.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/parse/__init__.py
bitbake/lib/bb/parse/parse_py/BBHandler.py
bitbake/lib/bb/parse/parse_py/ConfHandler.py

index 6737e061ea32b81eb858d8a693d1cc32c43fc7db..5e74afd9ac0f4d8e4e9ce329ebe5c1f2c54d50f7 100644 (file)
@@ -82,22 +82,16 @@ def init(fn, data):
 
 def resolve_file(fn, d):
     if not os.path.isabs(fn):
-        f = None
         bbpath = (bb.data.getVar('BBPATH', d, 1) or '').split(':')
         for p in bbpath:
             j = os.path.join(p, fn)
             if os.access(j, os.R_OK):
-                abs_fn = j
-                f = open(j, 'r')
-                break
-        if f is None:
-            raise IOError("file %s not found" % fn)
-    else:
-        f = open(fn,'r')
-        abs_fn = fn
-
-    bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % abs_fn)
-    return (f, abs_fn)
+                bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % j)
+                return j
+        raise IOError("file %s not found" % fn)
+
+    bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % fn)
+    return fn
 
 # Used by OpenEmbedded metadata
 __pkgsplit_cache__={}
index ab479c1eb27fb6082ccc3a52d2eb784f92fc2f8e..1ba81886a7664f29ef88aa3acddbcd55f52490ae 100644 (file)
@@ -80,12 +80,13 @@ def inherit(files, d):
             include(fn, file, d, "inherit")
             __inherit_cache = data.getVar('__inherit_cache', d) or []
 
-def get_statements(filename, absolsute_filename, base_name, file):
+def get_statements(filename, absolsute_filename, base_name):
     global cached_statements
 
     try:
         return cached_statements[absolsute_filename]
     except KeyError:
+        file = open(absolsute_filename, 'r')
         statements = ast.StatementGroup()
 
         lineno = 0
@@ -133,13 +134,13 @@ def handle(fn, d, include):
     else:
         oldfile = None
 
-    (f, abs_fn) = resolve_file(fn, d)
+    abs_fn = resolve_file(fn, d)
 
     if include:
         bb.parse.mark_dependency(d, abs_fn)
 
     # actual loading
-    statements = get_statements(fn, abs_fn, base_name, f)
+    statements = get_statements(fn, abs_fn, base_name)
 
     # DONE WITH PARSING... time to evaluate
     if ext != ".bbclass":
index 839a66202467d01534e473f90a3f8175c2f9c142..deafd6479f53d9fccf013c55876545da3689056b 100644 (file)
@@ -84,7 +84,8 @@ def handle(fn, data, include):
     else:
         oldfile = bb.data.getVar('FILE', data)
 
-    (f, abs_fn) = resolve_file(fn, data)
+    abs_fn = resolve_file(fn, data)
+    f = open(abs_fn, 'r')
 
     if include:
         bb.parse.mark_dependency(data, abs_fn)