diff options
author | Holger Freyther <ich@tamarin.(none)> | 2009-05-19 13:59:50 +0200 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-02-15 17:07:55 +0000 |
commit | 7b57ad901af2ded02995d22718ec6f280a9edd7f (patch) | |
tree | 81b9b3909460269bdd60744a255ac923775fa71c /bitbake/lib | |
parent | 83ec5eaed411225d16a4fc4dc92323e3acc9f5cd (diff) | |
download | poky-7b57ad901af2ded02995d22718ec6f280a9edd7f.tar.gz |
bitbake: [parser] Make resolve_file only resolve the path
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>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/parse/__init__.py | 18 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 3 |
3 files changed, 12 insertions, 16 deletions
diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py index 6737e061ea..5e74afd9ac 100644 --- a/bitbake/lib/bb/parse/__init__.py +++ b/bitbake/lib/bb/parse/__init__.py | |||
@@ -82,22 +82,16 @@ def init(fn, data): | |||
82 | 82 | ||
83 | def resolve_file(fn, d): | 83 | def resolve_file(fn, d): |
84 | if not os.path.isabs(fn): | 84 | if not os.path.isabs(fn): |
85 | f = None | ||
86 | bbpath = (bb.data.getVar('BBPATH', d, 1) or '').split(':') | 85 | bbpath = (bb.data.getVar('BBPATH', d, 1) or '').split(':') |
87 | for p in bbpath: | 86 | for p in bbpath: |
88 | j = os.path.join(p, fn) | 87 | j = os.path.join(p, fn) |
89 | if os.access(j, os.R_OK): | 88 | if os.access(j, os.R_OK): |
90 | abs_fn = j | 89 | bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % j) |
91 | f = open(j, 'r') | 90 | return j |
92 | break | 91 | raise IOError("file %s not found" % fn) |
93 | if f is None: | 92 | |
94 | raise IOError("file %s not found" % fn) | 93 | bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % fn) |
95 | else: | 94 | return fn |
96 | f = open(fn,'r') | ||
97 | abs_fn = fn | ||
98 | |||
99 | bb.msg.debug(2, bb.msg.domain.Parsing, "LOAD %s" % abs_fn) | ||
100 | return (f, abs_fn) | ||
101 | 95 | ||
102 | # Used by OpenEmbedded metadata | 96 | # Used by OpenEmbedded metadata |
103 | __pkgsplit_cache__={} | 97 | __pkgsplit_cache__={} |
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index ab479c1eb2..1ba81886a7 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -80,12 +80,13 @@ def inherit(files, d): | |||
80 | include(fn, file, d, "inherit") | 80 | include(fn, file, d, "inherit") |
81 | __inherit_cache = data.getVar('__inherit_cache', d) or [] | 81 | __inherit_cache = data.getVar('__inherit_cache', d) or [] |
82 | 82 | ||
83 | def get_statements(filename, absolsute_filename, base_name, file): | 83 | def get_statements(filename, absolsute_filename, base_name): |
84 | global cached_statements | 84 | global cached_statements |
85 | 85 | ||
86 | try: | 86 | try: |
87 | return cached_statements[absolsute_filename] | 87 | return cached_statements[absolsute_filename] |
88 | except KeyError: | 88 | except KeyError: |
89 | file = open(absolsute_filename, 'r') | ||
89 | statements = ast.StatementGroup() | 90 | statements = ast.StatementGroup() |
90 | 91 | ||
91 | lineno = 0 | 92 | lineno = 0 |
@@ -133,13 +134,13 @@ def handle(fn, d, include): | |||
133 | else: | 134 | else: |
134 | oldfile = None | 135 | oldfile = None |
135 | 136 | ||
136 | (f, abs_fn) = resolve_file(fn, d) | 137 | abs_fn = resolve_file(fn, d) |
137 | 138 | ||
138 | if include: | 139 | if include: |
139 | bb.parse.mark_dependency(d, abs_fn) | 140 | bb.parse.mark_dependency(d, abs_fn) |
140 | 141 | ||
141 | # actual loading | 142 | # actual loading |
142 | statements = get_statements(fn, abs_fn, base_name, f) | 143 | statements = get_statements(fn, abs_fn, base_name) |
143 | 144 | ||
144 | # DONE WITH PARSING... time to evaluate | 145 | # DONE WITH PARSING... time to evaluate |
145 | if ext != ".bbclass": | 146 | if ext != ".bbclass": |
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 839a662024..deafd6479f 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -84,7 +84,8 @@ def handle(fn, data, include): | |||
84 | else: | 84 | else: |
85 | oldfile = bb.data.getVar('FILE', data) | 85 | oldfile = bb.data.getVar('FILE', data) |
86 | 86 | ||
87 | (f, abs_fn) = resolve_file(fn, data) | 87 | abs_fn = resolve_file(fn, data) |
88 | f = open(abs_fn, 'r') | ||
88 | 89 | ||
89 | if include: | 90 | if include: |
90 | bb.parse.mark_dependency(data, abs_fn) | 91 | bb.parse.mark_dependency(data, abs_fn) |