diff options
author | Michael 'Mickey' Lauer <mickey@vanille-media.de> | 2004-04-30 15:26:34 +0000 |
---|---|---|
committer | Michael 'Mickey' Lauer <mickey@vanille-media.de> | 2004-04-30 15:26:34 +0000 |
commit | e98ba885428efbaa943a4bc369e0f0e41fc87c8a (patch) | |
tree | a7b81c03226e9f0e4754a1566b01fd7b4d77db23 | |
parent | 28215a94d4317f56f350e2a98fb7f1d056d70e88 (diff) | |
download | bitbake-contrib-e98ba885428efbaa943a4bc369e0f0e41fc87c8a.tar.gz |
add dependency tracking for parse cache - patch courtesy pb_.
-rw-r--r-- | bin/oe/make.py | 17 | ||||
-rw-r--r-- | bin/oe/parse/ConfHandler.py | 6 | ||||
-rw-r--r-- | bin/oe/parse/OEHandler.py | 5 | ||||
-rw-r--r-- | bin/oe/parse/__init__.py | 16 |
4 files changed, 42 insertions, 2 deletions
diff --git a/bin/oe/make.py b/bin/oe/make.py index 43e40a866..d1e54dfab 100644 --- a/bin/oe/make.py +++ b/bin/oe/make.py @@ -21,6 +21,7 @@ cfg = {} cache = None digits = "0123456789" ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +mtime_cache = {} def get_oefiles( path = os.getcwd() ): """Get list of default .oe files by reading out the current directory""" @@ -41,6 +42,16 @@ def find_oefiles( path ): return [] return finddata.readlines() +def deps_clean(d): + deps = (data.getVar('__depends', d) or "").split(" ") + for dep in deps: + (f,old_mtime_s) = dep.split("@") + old_mtime = int(old_mtime_s) + new_mtime = parse.cached_mtime(f) + if (new_mtime > old_mtime): + return False + return True + def load_oefile( oefile ): """Load and parse one .oe build file""" @@ -51,14 +62,16 @@ def load_oefile( oefile ): cache_mtime = os.stat( "%s/%s" % ( cache, cache_oefile ) )[8] except OSError: cache_mtime = 0 - file_mtime = os.stat( oefile )[8] + file_mtime = parse.cached_mtime(oefile) if file_mtime > cache_mtime: #print " : '%s' dirty. reparsing..." % oefile pass else: #print " : '%s' clean. loading from cache..." % oefile - return unpickle_oe( cache_oefile ) + cache_data = unpickle_oe( cache_oefile ) + if deps_clean(cache_data): + return cache_data oepath = data.getVar('OEPATH', cfg) topdir = data.getVar('TOPDIR', cfg) diff --git a/bin/oe/parse/ConfHandler.py b/bin/oe/parse/ConfHandler.py index 19c5eb3da..110c87b5a 100644 --- a/bin/oe/parse/ConfHandler.py +++ b/bin/oe/parse/ConfHandler.py @@ -104,6 +104,7 @@ def handle(fn, data = {}, include = 0): currname = os.path.join(oe.data.expand(p, data), fn) if os.access(currname, os.R_OK): f = open(currname, 'r') + abs_fn = currname debug(1, "CONF %s %s" % (inc_string, currname)) break if f is None: @@ -111,6 +112,11 @@ def handle(fn, data = {}, include = 0): else: f = open(fn,'r') debug(1, "CONF %s %s" % (inc_string,fn)) + abs_fn = fn + + if include: + oe.parse.mark_dependency(data, abs_fn) + lineno = 0 oe.data.setVar('FILE', fn, data) while 1: diff --git a/bin/oe/parse/OEHandler.py b/bin/oe/parse/OEHandler.py index 78f44fef2..9eb181e3c 100644 --- a/bin/oe/parse/OEHandler.py +++ b/bin/oe/parse/OEHandler.py @@ -79,12 +79,17 @@ def handle(fn, d = {}, include = 0): p = data.expand(p, d) 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 not found") else: f = open(fn,'r') + abs_fn = fn + + if include: + oe.parse.mark_dependency(d, abs_fn) if ext != ".oeclass": data.setVar('FILE', fn, d) diff --git a/bin/oe/parse/__init__.py b/bin/oe/parse/__init__.py index effd5e778..e147b8ffd 100644 --- a/bin/oe/parse/__init__.py +++ b/bin/oe/parse/__init__.py @@ -26,6 +26,22 @@ OEHandler.ParseError = ParseError import SRPMHandler SRPMHandler.ParseError = ParseError +__mtime_cache = {} + +def cached_mtime(f): + import os + if not __mtime_cache.has_key(f): + __mtime_cache[f] = os.stat(f)[8] + return __mtime_cache[f] + +def mark_dependency(d, f): + import oe, os + if f.startswith('./'): + f = "%s/%s" % (os.getcwd(), f[2:]) + deps = (oe.data.getVar('__depends', d) or "").split() + deps.append("%s@%s" % (f, cached_mtime(f))) + oe.data.setVar('__depends', " ".join(deps), d) + def supports(fn, data): """Returns true if we have a handler for this file, false otherwise""" for h in handlers: |