2006-05-09 15:44:08 +00:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2007-01-08 23:53:01 +00:00
|
|
|
#
|
|
|
|
# BitBake 'Event' implementation
|
|
|
|
#
|
|
|
|
# Caching of bitbake variables before task execution
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
# Copyright (C) 2006 Richard Purdie
|
|
|
|
|
|
|
|
# but small sections based on code from bin/bitbake:
|
|
|
|
# Copyright (C) 2003, 2004 Chris Larson
|
|
|
|
# Copyright (C) 2003, 2004 Phil Blundell
|
|
|
|
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
|
|
|
|
# Copyright (C) 2005 Holger Hans Peter Freyther
|
|
|
|
# Copyright (C) 2005 ROAD GmbH
|
2007-01-08 23:53:01 +00:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
|
2010-04-08 17:22:29 +00:00
|
|
|
import os
|
2006-05-09 15:44:08 +00:00
|
|
|
import bb.data
|
|
|
|
import bb.utils
|
|
|
|
|
|
|
|
try:
|
|
|
|
import cPickle as pickle
|
|
|
|
except ImportError:
|
|
|
|
import pickle
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.")
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2010-03-25 17:28:34 +00:00
|
|
|
__cache_version__ = "131"
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
class Cache:
|
|
|
|
"""
|
|
|
|
BitBake Cache implementation
|
|
|
|
"""
|
2010-04-06 15:52:54 +00:00
|
|
|
def __init__(self, data):
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
|
2010-04-06 15:52:54 +00:00
|
|
|
self.cachedir = bb.data.getVar("CACHE", data, True)
|
2006-05-09 15:44:08 +00:00
|
|
|
self.clean = {}
|
2008-03-03 22:01:45 +00:00
|
|
|
self.checked = {}
|
2006-05-09 15:44:08 +00:00
|
|
|
self.depends_cache = {}
|
|
|
|
self.data = None
|
|
|
|
self.data_fn = None
|
2008-03-03 22:01:45 +00:00
|
|
|
self.cacheclean = True
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
if self.cachedir in [None, '']:
|
|
|
|
self.has_cache = False
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Not using a cache. Set CACHE = <directory> to enable.")
|
2009-01-02 23:57:03 +00:00
|
|
|
return
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2009-01-02 23:57:03 +00:00
|
|
|
self.has_cache = True
|
2010-04-12 00:03:55 +00:00
|
|
|
self.cachefile = os.path.join(self.cachedir, "bb_cache.dat")
|
2009-01-01 14:43:54 +00:00
|
|
|
|
2009-01-02 23:57:03 +00:00
|
|
|
bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir)
|
2010-06-10 16:46:02 +00:00
|
|
|
bb.utils.mkdirhier(self.cachedir)
|
2008-03-03 22:01:45 +00:00
|
|
|
|
|
|
|
# If any of configuration.data's dependencies are newer than the
|
|
|
|
# cache there isn't even any point in loading it...
|
|
|
|
newest_mtime = 0
|
2010-04-20 18:53:31 +00:00
|
|
|
deps = bb.data.getVar("__depends", data)
|
2010-06-04 12:04:39 +00:00
|
|
|
|
|
|
|
old_mtimes = [old_mtime for f, old_mtime in deps]
|
|
|
|
old_mtimes.append(newest_mtime)
|
|
|
|
newest_mtime = max(old_mtimes)
|
2008-03-03 22:01:45 +00:00
|
|
|
|
2008-03-14 11:44:34 +00:00
|
|
|
if bb.parse.cached_mtime_noerror(self.cachefile) >= newest_mtime:
|
2006-05-09 15:44:08 +00:00
|
|
|
try:
|
2008-03-03 22:01:45 +00:00
|
|
|
p = pickle.Unpickler(file(self.cachefile, "rb"))
|
2006-05-09 15:44:08 +00:00
|
|
|
self.depends_cache, version_data = p.load()
|
|
|
|
if version_data['CACHE_VER'] != __cache_version__:
|
2010-04-12 00:03:55 +00:00
|
|
|
raise ValueError('Cache Version Mismatch')
|
2006-05-09 15:44:08 +00:00
|
|
|
if version_data['BITBAKE_VER'] != bb.__version__:
|
2010-04-12 00:03:55 +00:00
|
|
|
raise ValueError('Bitbake Version Mismatch')
|
2007-04-01 15:04:49 +00:00
|
|
|
except EOFError:
|
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Truncated cache found, rebuilding...")
|
|
|
|
self.depends_cache = {}
|
2008-03-14 11:44:34 +00:00
|
|
|
except:
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Invalid cache found, rebuilding...")
|
2006-05-09 15:44:08 +00:00
|
|
|
self.depends_cache = {}
|
2008-03-03 22:01:45 +00:00
|
|
|
else:
|
2010-06-04 12:04:38 +00:00
|
|
|
if os.path.isfile(self.cachefile):
|
2008-12-06 13:16:13 +00:00
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Out of date cache found, rebuilding...")
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
def getVar(self, var, fn, exp = 0):
|
|
|
|
"""
|
|
|
|
Gets the value of a variable
|
|
|
|
(similar to getVar in the data class)
|
2010-03-24 23:56:12 +00:00
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
There are two scenarios:
|
|
|
|
1. We have cached data - serve from depends_cache[fn]
|
2010-03-24 23:56:12 +00:00
|
|
|
2. We're learning what data to cache - serve from data
|
2006-05-09 15:44:08 +00:00
|
|
|
backend but add a copy of the data to the cache.
|
|
|
|
"""
|
|
|
|
if fn in self.clean:
|
|
|
|
return self.depends_cache[fn][var]
|
|
|
|
|
2010-06-04 12:04:40 +00:00
|
|
|
self.depends_cache.setdefault(fn, {})
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
if fn != self.data_fn:
|
|
|
|
# We're trying to access data in the cache which doesn't exist
|
|
|
|
# yet setData hasn't been called to setup the right access. Very bad.
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.error(bb.msg.domain.Cache, "Parsing error data_fn %s and fn %s don't match" % (self.data_fn, fn))
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
self.cacheclean = False
|
2006-05-09 15:44:08 +00:00
|
|
|
result = bb.data.getVar(var, self.data, exp)
|
|
|
|
self.depends_cache[fn][var] = result
|
|
|
|
return result
|
|
|
|
|
2009-01-01 14:43:54 +00:00
|
|
|
def setData(self, virtualfn, fn, data):
|
2006-05-09 15:44:08 +00:00
|
|
|
"""
|
|
|
|
Called to prime bb_cache ready to learn which variables to cache.
|
|
|
|
Will be followed by calls to self.getVar which aren't cached
|
|
|
|
but can be fulfilled from self.data.
|
|
|
|
"""
|
2009-01-01 14:43:54 +00:00
|
|
|
self.data_fn = virtualfn
|
2006-05-09 15:44:08 +00:00
|
|
|
self.data = data
|
|
|
|
|
|
|
|
# Make sure __depends makes the depends_cache
|
2010-03-24 23:56:12 +00:00
|
|
|
# If we're a virtual class we need to make sure all our depends are appended
|
2010-01-20 18:46:02 +00:00
|
|
|
# to the depends of fn.
|
2010-06-04 12:04:40 +00:00
|
|
|
depends = self.getVar("__depends", virtualfn) or set()
|
2010-03-21 22:02:56 +00:00
|
|
|
self.depends_cache.setdefault(fn, {})
|
2010-01-20 18:46:02 +00:00
|
|
|
if "__depends" not in self.depends_cache[fn] or not self.depends_cache[fn]["__depends"]:
|
|
|
|
self.depends_cache[fn]["__depends"] = depends
|
2010-06-04 12:04:40 +00:00
|
|
|
else:
|
|
|
|
self.depends_cache[fn]["__depends"].update(depends)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
# Make sure the variants always make it into the cache too
|
|
|
|
self.getVar('__VARIANTS', virtualfn, True)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2009-01-01 14:43:54 +00:00
|
|
|
self.depends_cache[virtualfn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn)
|
|
|
|
|
|
|
|
def virtualfn2realfn(self, virtualfn):
|
|
|
|
"""
|
|
|
|
Convert a virtual file name to a real one + the associated subclass keyword
|
|
|
|
"""
|
|
|
|
|
|
|
|
fn = virtualfn
|
|
|
|
cls = ""
|
|
|
|
if virtualfn.startswith('virtual:'):
|
|
|
|
cls = virtualfn.split(':', 2)[1]
|
|
|
|
fn = virtualfn.replace('virtual:' + cls + ':', '')
|
|
|
|
#bb.msg.debug(2, bb.msg.domain.Cache, "virtualfn2realfn %s to %s %s" % (virtualfn, fn, cls))
|
|
|
|
return (fn, cls)
|
|
|
|
|
|
|
|
def realfn2virtual(self, realfn, cls):
|
|
|
|
"""
|
|
|
|
Convert a real filename + the associated subclass keyword to a virtual filename
|
|
|
|
"""
|
|
|
|
if cls == "":
|
|
|
|
#bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and '%s' to %s" % (realfn, cls, realfn))
|
|
|
|
return realfn
|
|
|
|
#bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and %s to %s" % (realfn, cls, "virtual:" + cls + ":" + realfn))
|
|
|
|
return "virtual:" + cls + ":" + realfn
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
def loadDataFull(self, virtualfn, appends, cfgData):
|
2006-05-09 15:44:08 +00:00
|
|
|
"""
|
|
|
|
Return a complete set of data for fn.
|
|
|
|
To do this, we need to parse the file.
|
|
|
|
"""
|
2009-01-01 14:43:54 +00:00
|
|
|
|
|
|
|
(fn, cls) = self.virtualfn2realfn(virtualfn)
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn)
|
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
bb_data = self.load_bbfile(fn, appends, cfgData)
|
2010-01-20 18:46:02 +00:00
|
|
|
return bb_data[cls]
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
def loadData(self, fn, appends, cfgData, cacheData):
|
2006-05-09 15:44:08 +00:00
|
|
|
"""
|
|
|
|
Load a subset of data for fn.
|
|
|
|
If the cached data is valid we do nothing,
|
|
|
|
To do this, we need to parse the file and set the system
|
|
|
|
to record the variables accessed.
|
|
|
|
Return the cache status and whether the file was skipped when parsed
|
|
|
|
"""
|
2010-01-20 18:46:02 +00:00
|
|
|
skipped = 0
|
|
|
|
virtuals = 0
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
if fn not in self.checked:
|
|
|
|
self.cacheValidUpdate(fn)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
if self.cacheValid(fn):
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
multi = self.getVar('__VARIANTS', fn, True)
|
2010-01-20 18:46:02 +00:00
|
|
|
for cls in (multi or "").split() + [""]:
|
|
|
|
virtualfn = self.realfn2virtual(fn, cls)
|
|
|
|
if self.depends_cache[virtualfn]["__SKIPPED"]:
|
|
|
|
skipped += 1
|
|
|
|
bb.msg.debug(1, bb.msg.domain.Cache, "Skipping %s" % virtualfn)
|
|
|
|
continue
|
|
|
|
self.handle_data(virtualfn, cacheData)
|
|
|
|
virtuals += 1
|
|
|
|
return True, skipped, virtuals
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn)
|
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
bb_data = self.load_bbfile(fn, appends, cfgData)
|
2009-01-01 14:43:54 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
for data in bb_data:
|
|
|
|
virtualfn = self.realfn2virtual(fn, data)
|
|
|
|
self.setData(virtualfn, fn, bb_data[data])
|
2010-04-20 18:53:31 +00:00
|
|
|
if self.getVar("__SKIPPED", virtualfn):
|
2010-01-20 18:46:02 +00:00
|
|
|
skipped += 1
|
|
|
|
bb.msg.debug(1, bb.msg.domain.Cache, "Skipping %s" % virtualfn)
|
|
|
|
else:
|
2009-01-01 14:43:54 +00:00
|
|
|
self.handle_data(virtualfn, cacheData)
|
2010-01-20 18:46:02 +00:00
|
|
|
virtuals += 1
|
|
|
|
return False, skipped, virtuals
|
2009-01-01 14:43:54 +00:00
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
def cacheValid(self, fn):
|
|
|
|
"""
|
|
|
|
Is the cache valid for fn?
|
|
|
|
Fast version, no timestamps checked.
|
|
|
|
"""
|
|
|
|
# Is cache enabled?
|
|
|
|
if not self.has_cache:
|
|
|
|
return False
|
|
|
|
if fn in self.clean:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def cacheValidUpdate(self, fn):
|
|
|
|
"""
|
|
|
|
Is the cache valid for fn?
|
|
|
|
Make thorough (slower) checks including timestamps.
|
|
|
|
"""
|
|
|
|
# Is cache enabled?
|
|
|
|
if not self.has_cache:
|
|
|
|
return False
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
self.checked[fn] = ""
|
|
|
|
|
|
|
|
# Pretend we're clean so getVar works
|
|
|
|
self.clean[fn] = ""
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
# File isn't in depends_cache
|
|
|
|
if not fn in self.depends_cache:
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % fn)
|
2006-05-09 15:44:08 +00:00
|
|
|
self.remove(fn)
|
|
|
|
return False
|
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
mtime = bb.parse.cached_mtime_noerror(fn)
|
2008-03-14 11:44:34 +00:00
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
# Check file still exists
|
2008-03-14 11:44:34 +00:00
|
|
|
if mtime == 0:
|
2010-06-04 12:04:36 +00:00
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s no longer exists" % fn)
|
2008-03-03 22:01:45 +00:00
|
|
|
self.remove(fn)
|
|
|
|
return False
|
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
# Check the file's timestamp
|
2008-03-28 17:19:49 +00:00
|
|
|
if mtime != self.getVar("CACHETIMESTAMP", fn, True):
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s changed" % fn)
|
2006-05-09 15:44:08 +00:00
|
|
|
self.remove(fn)
|
|
|
|
return False
|
|
|
|
|
|
|
|
# Check dependencies are still valid
|
|
|
|
depends = self.getVar("__depends", fn, True)
|
2008-03-14 11:44:34 +00:00
|
|
|
if depends:
|
2010-03-24 23:56:12 +00:00
|
|
|
for f, old_mtime in depends:
|
2008-03-14 11:44:34 +00:00
|
|
|
fmtime = bb.parse.cached_mtime_noerror(f)
|
|
|
|
# Check if file still exists
|
2009-11-03 23:20:15 +00:00
|
|
|
if old_mtime != 0 and fmtime == 0:
|
2008-03-14 11:44:34 +00:00
|
|
|
self.remove(fn)
|
|
|
|
return False
|
|
|
|
|
2008-03-28 17:19:49 +00:00
|
|
|
if (fmtime != old_mtime):
|
2008-03-14 11:44:34 +00:00
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s's dependency %s changed" % (fn, f))
|
|
|
|
self.remove(fn)
|
|
|
|
return False
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
#bb.msg.debug(2, bb.msg.domain.Cache, "Depends Cache: %s is clean" % fn)
|
2006-05-09 15:44:08 +00:00
|
|
|
if not fn in self.clean:
|
|
|
|
self.clean[fn] = ""
|
|
|
|
|
2010-07-25 10:33:11 +00:00
|
|
|
invalid = False
|
2010-01-20 18:46:02 +00:00
|
|
|
# Mark extended class data as clean too
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
multi = self.getVar('__VARIANTS', fn, True)
|
2010-01-20 18:46:02 +00:00
|
|
|
for cls in (multi or "").split():
|
|
|
|
virtualfn = self.realfn2virtual(fn, cls)
|
|
|
|
self.clean[virtualfn] = ""
|
2010-07-25 10:33:11 +00:00
|
|
|
if not virtualfn in self.depends_cache:
|
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % virtualfn)
|
|
|
|
invalid = True
|
|
|
|
|
|
|
|
# If any one of the varients is not present, mark cache as invalid for all
|
|
|
|
if invalid:
|
|
|
|
for cls in (multi or "").split():
|
|
|
|
virtualfn = self.realfn2virtual(fn, cls)
|
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: Removing %s from cache" % virtualfn)
|
|
|
|
del self.clean[virtualfn]
|
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Cache: Removing %s from cache" % fn)
|
|
|
|
del self.clean[fn]
|
|
|
|
return False
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
return True
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
def remove(self, fn):
|
|
|
|
"""
|
|
|
|
Remove a fn from the cache
|
|
|
|
Called from the parser in error cases
|
|
|
|
"""
|
2006-11-16 15:02:15 +00:00
|
|
|
bb.msg.debug(1, bb.msg.domain.Cache, "Removing %s from cache" % fn)
|
2006-05-09 15:44:08 +00:00
|
|
|
if fn in self.depends_cache:
|
|
|
|
del self.depends_cache[fn]
|
|
|
|
if fn in self.clean:
|
|
|
|
del self.clean[fn]
|
|
|
|
|
|
|
|
def sync(self):
|
|
|
|
"""
|
|
|
|
Save the cache
|
2006-11-16 15:02:15 +00:00
|
|
|
Called from the parser when complete (or exiting)
|
2006-05-09 15:44:08 +00:00
|
|
|
"""
|
2008-09-30 21:54:47 +00:00
|
|
|
import copy
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
if not self.has_cache:
|
|
|
|
return
|
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
if self.cacheclean:
|
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Cache is clean, not saving.")
|
|
|
|
return
|
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
version_data = {}
|
|
|
|
version_data['CACHE_VER'] = __cache_version__
|
|
|
|
version_data['BITBAKE_VER'] = bb.__version__
|
|
|
|
|
2009-05-17 03:59:06 +00:00
|
|
|
cache_data = copy.copy(self.depends_cache)
|
2008-09-30 21:54:47 +00:00
|
|
|
for fn in self.depends_cache:
|
|
|
|
if '__BB_DONT_CACHE' in self.depends_cache[fn] and self.depends_cache[fn]['__BB_DONT_CACHE']:
|
|
|
|
bb.msg.debug(2, bb.msg.domain.Cache, "Not caching %s, marked as not cacheable" % fn)
|
|
|
|
del cache_data[fn]
|
2009-09-03 21:57:26 +00:00
|
|
|
elif 'PV' in self.depends_cache[fn] and 'SRCREVINACTION' in self.depends_cache[fn]['PV']:
|
2009-09-22 18:53:34 +00:00
|
|
|
bb.msg.error(bb.msg.domain.Cache, "Not caching %s as it had SRCREVINACTION in PV. Please report this bug" % fn)
|
2009-09-03 21:57:26 +00:00
|
|
|
del cache_data[fn]
|
2008-09-30 21:54:47 +00:00
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
p = pickle.Pickler(file(self.cachefile, "wb" ), -1 )
|
2008-09-30 21:54:47 +00:00
|
|
|
p.dump([cache_data, version_data])
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
def mtime(self, cachefile):
|
2006-11-16 15:02:15 +00:00
|
|
|
return bb.parse.cached_mtime_noerror(cachefile)
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2006-11-16 15:02:15 +00:00
|
|
|
def handle_data(self, file_name, cacheData):
|
|
|
|
"""
|
2010-03-24 23:56:12 +00:00
|
|
|
Save data we need into the cache
|
2006-11-16 15:02:15 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
pn = self.getVar('PN', file_name, True)
|
2007-04-01 15:04:49 +00:00
|
|
|
pe = self.getVar('PE', file_name, True) or "0"
|
2006-11-16 15:02:15 +00:00
|
|
|
pv = self.getVar('PV', file_name, True)
|
2009-09-22 18:53:34 +00:00
|
|
|
if 'SRCREVINACTION' in pv:
|
2010-04-09 19:33:29 +00:00
|
|
|
bb.msg.note(1, bb.msg.domain.Cache, "Found SRCREVINACTION in PV (%s) or %s. Please report this bug." % (pv, file_name))
|
2006-11-16 15:02:15 +00:00
|
|
|
pr = self.getVar('PR', file_name, True)
|
|
|
|
dp = int(self.getVar('DEFAULT_PREFERENCE', file_name, True) or "0")
|
|
|
|
depends = bb.utils.explode_deps(self.getVar("DEPENDS", file_name, True) or "")
|
|
|
|
packages = (self.getVar('PACKAGES', file_name, True) or "").split()
|
|
|
|
packages_dynamic = (self.getVar('PACKAGES_DYNAMIC', file_name, True) or "").split()
|
|
|
|
rprovides = (self.getVar("RPROVIDES", file_name, True) or "").split()
|
|
|
|
|
2010-04-20 18:53:31 +00:00
|
|
|
cacheData.task_deps[file_name] = self.getVar("_task_deps", file_name)
|
2006-11-16 15:02:15 +00:00
|
|
|
|
|
|
|
# build PackageName to FileName lookup table
|
|
|
|
if pn not in cacheData.pkg_pn:
|
|
|
|
cacheData.pkg_pn[pn] = []
|
|
|
|
cacheData.pkg_pn[pn].append(file_name)
|
|
|
|
|
|
|
|
cacheData.stamp[file_name] = self.getVar('STAMP', file_name, True)
|
|
|
|
|
|
|
|
# build FileName to PackageName lookup table
|
|
|
|
cacheData.pkg_fn[file_name] = pn
|
2010-03-24 23:56:12 +00:00
|
|
|
cacheData.pkg_pepvpr[file_name] = (pe, pv, pr)
|
2006-11-16 15:02:15 +00:00
|
|
|
cacheData.pkg_dp[file_name] = dp
|
|
|
|
|
2008-03-14 11:44:34 +00:00
|
|
|
provides = [pn]
|
|
|
|
for provide in (self.getVar("PROVIDES", file_name, True) or "").split():
|
|
|
|
if provide not in provides:
|
|
|
|
provides.append(provide)
|
|
|
|
|
2006-11-16 15:02:15 +00:00
|
|
|
# Build forward and reverse provider hashes
|
|
|
|
# Forward: virtual -> [filenames]
|
|
|
|
# Reverse: PN -> [virtuals]
|
|
|
|
if pn not in cacheData.pn_provides:
|
2008-03-14 11:44:34 +00:00
|
|
|
cacheData.pn_provides[pn] = []
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2008-03-14 11:44:34 +00:00
|
|
|
cacheData.fn_provides[file_name] = provides
|
2006-11-16 15:02:15 +00:00
|
|
|
for provide in provides:
|
|
|
|
if provide not in cacheData.providers:
|
|
|
|
cacheData.providers[provide] = []
|
|
|
|
cacheData.providers[provide].append(file_name)
|
2008-03-14 11:44:34 +00:00
|
|
|
if not provide in cacheData.pn_provides[pn]:
|
|
|
|
cacheData.pn_provides[pn].append(provide)
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2008-03-14 11:44:34 +00:00
|
|
|
cacheData.deps[file_name] = []
|
2006-11-16 15:02:15 +00:00
|
|
|
for dep in depends:
|
2008-03-14 11:44:34 +00:00
|
|
|
if not dep in cacheData.deps[file_name]:
|
|
|
|
cacheData.deps[file_name].append(dep)
|
|
|
|
if not dep in cacheData.all_depends:
|
|
|
|
cacheData.all_depends.append(dep)
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
# Build reverse hash for PACKAGES, so runtime dependencies
|
2006-11-16 15:02:15 +00:00
|
|
|
# can be be resolved (RDEPENDS, RRECOMMENDS etc.)
|
|
|
|
for package in packages:
|
|
|
|
if not package in cacheData.packages:
|
|
|
|
cacheData.packages[package] = []
|
|
|
|
cacheData.packages[package].append(file_name)
|
2010-03-24 23:56:12 +00:00
|
|
|
rprovides += (self.getVar("RPROVIDES_%s" % package, file_name, 1) or "").split()
|
2006-11-16 15:02:15 +00:00
|
|
|
|
|
|
|
for package in packages_dynamic:
|
|
|
|
if not package in cacheData.packages_dynamic:
|
|
|
|
cacheData.packages_dynamic[package] = []
|
|
|
|
cacheData.packages_dynamic[package].append(file_name)
|
|
|
|
|
|
|
|
for rprovide in rprovides:
|
|
|
|
if not rprovide in cacheData.rproviders:
|
|
|
|
cacheData.rproviders[rprovide] = []
|
|
|
|
cacheData.rproviders[rprovide].append(file_name)
|
|
|
|
|
|
|
|
# Build hash of runtime depends and rececommends
|
|
|
|
|
|
|
|
if not file_name in cacheData.rundeps:
|
|
|
|
cacheData.rundeps[file_name] = {}
|
|
|
|
if not file_name in cacheData.runrecs:
|
|
|
|
cacheData.runrecs[file_name] = {}
|
|
|
|
|
2008-03-14 11:44:34 +00:00
|
|
|
rdepends = self.getVar('RDEPENDS', file_name, True) or ""
|
|
|
|
rrecommends = self.getVar('RRECOMMENDS', file_name, True) or ""
|
2006-11-16 15:02:15 +00:00
|
|
|
for package in packages + [pn]:
|
|
|
|
if not package in cacheData.rundeps[file_name]:
|
2008-03-14 11:44:34 +00:00
|
|
|
cacheData.rundeps[file_name][package] = []
|
2006-11-16 15:02:15 +00:00
|
|
|
if not package in cacheData.runrecs[file_name]:
|
2008-03-14 11:44:34 +00:00
|
|
|
cacheData.runrecs[file_name][package] = []
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2008-03-14 11:44:34 +00:00
|
|
|
cacheData.rundeps[file_name][package] = rdepends + " " + (self.getVar("RDEPENDS_%s" % package, file_name, True) or "")
|
|
|
|
cacheData.runrecs[file_name][package] = rrecommends + " " + (self.getVar("RRECOMMENDS_%s" % package, file_name, True) or "")
|
2006-11-16 15:02:15 +00:00
|
|
|
|
|
|
|
# Collect files we may need for possible world-dep
|
|
|
|
# calculations
|
|
|
|
if not self.getVar('BROKEN', file_name, True) and not self.getVar('EXCLUDE_FROM_WORLD', file_name, True):
|
|
|
|
cacheData.possible_world.append(file_name)
|
|
|
|
|
2008-09-30 21:54:47 +00:00
|
|
|
# Touch this to make sure its in the cache
|
|
|
|
self.getVar('__BB_DONT_CACHE', file_name, True)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
self.getVar('__VARIANTS', file_name, True)
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
def load_bbfile(self, bbfile, appends, config):
|
2006-05-09 15:44:08 +00:00
|
|
|
"""
|
|
|
|
Load and parse one .bb build file
|
|
|
|
Return the data and whether parsing resulted in the file being skipped
|
|
|
|
"""
|
2010-06-04 12:04:42 +00:00
|
|
|
chdir_back = False
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2010-04-08 17:22:29 +00:00
|
|
|
from bb import data, parse
|
2006-05-09 15:44:08 +00:00
|
|
|
|
|
|
|
# expand tmpdir to include this topdir
|
2006-11-16 15:02:15 +00:00
|
|
|
data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
|
|
|
|
bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
|
2006-05-09 15:44:08 +00:00
|
|
|
oldpath = os.path.abspath(os.getcwd())
|
2010-06-04 12:04:42 +00:00
|
|
|
parse.cached_mtime_noerror(bbfile_loc)
|
2006-11-16 15:02:15 +00:00
|
|
|
bb_data = data.init_db(config)
|
2010-06-04 12:04:42 +00:00
|
|
|
# The ConfHandler first looks if there is a TOPDIR and if not
|
|
|
|
# then it would call getcwd().
|
|
|
|
# Previously, we chdir()ed to bbfile_loc, called the handler
|
|
|
|
# and finally chdir()ed back, a couple of thousand times. We now
|
|
|
|
# just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
|
|
|
|
if not data.getVar('TOPDIR', bb_data):
|
|
|
|
chdir_back = True
|
|
|
|
data.setVar('TOPDIR', bbfile_loc, bb_data)
|
2006-05-09 15:44:08 +00:00
|
|
|
try:
|
2010-07-16 14:10:22 +00:00
|
|
|
if appends:
|
|
|
|
data.setVar('__BBAPPEND', " ".join(appends), bb_data)
|
2006-11-16 15:02:15 +00:00
|
|
|
bb_data = parse.handle(bbfile, bb_data) # read .bb data
|
2010-06-04 12:04:42 +00:00
|
|
|
if chdir_back: os.chdir(oldpath)
|
2010-01-20 18:46:02 +00:00
|
|
|
return bb_data
|
2006-05-09 15:44:08 +00:00
|
|
|
except:
|
2010-06-04 12:04:42 +00:00
|
|
|
if chdir_back: os.chdir(oldpath)
|
2006-05-09 15:44:08 +00:00
|
|
|
raise
|
|
|
|
|
|
|
|
def init(cooker):
|
|
|
|
"""
|
2010-03-24 23:56:12 +00:00
|
|
|
The Objective: Cache the minimum amount of data possible yet get to the
|
2006-05-09 15:44:08 +00:00
|
|
|
stage of building packages (i.e. tryBuild) without reparsing any .bb files.
|
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
To do this, we intercept getVar calls and only cache the variables we see
|
|
|
|
being accessed. We rely on the cache getVar calls being made for all
|
|
|
|
variables bitbake might need to use to reach this stage. For each cached
|
2006-05-09 15:44:08 +00:00
|
|
|
file we need to track:
|
|
|
|
|
|
|
|
* Its mtime
|
|
|
|
* The mtimes of all its dependencies
|
|
|
|
* Whether it caused a parse.SkipPackage exception
|
|
|
|
|
|
|
|
Files causing parsing errors are evicted from the cache.
|
|
|
|
|
|
|
|
"""
|
2010-04-06 15:52:54 +00:00
|
|
|
return Cache(cooker.configuration.data)
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2006-11-16 15:02:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
#============================================================================#
|
|
|
|
# CacheData
|
|
|
|
#============================================================================#
|
|
|
|
class CacheData:
|
|
|
|
"""
|
|
|
|
The data structures we compile from the cached data
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
"""
|
|
|
|
Direct cache variables
|
|
|
|
(from Cache.handle_data)
|
|
|
|
"""
|
|
|
|
self.providers = {}
|
|
|
|
self.rproviders = {}
|
|
|
|
self.packages = {}
|
|
|
|
self.packages_dynamic = {}
|
|
|
|
self.possible_world = []
|
|
|
|
self.pkg_pn = {}
|
|
|
|
self.pkg_fn = {}
|
2007-04-01 15:04:49 +00:00
|
|
|
self.pkg_pepvpr = {}
|
2006-11-16 15:02:15 +00:00
|
|
|
self.pkg_dp = {}
|
|
|
|
self.pn_provides = {}
|
2007-09-02 14:10:08 +00:00
|
|
|
self.fn_provides = {}
|
2008-03-14 11:44:34 +00:00
|
|
|
self.all_depends = []
|
2006-11-16 15:02:15 +00:00
|
|
|
self.deps = {}
|
|
|
|
self.rundeps = {}
|
|
|
|
self.runrecs = {}
|
|
|
|
self.task_queues = {}
|
|
|
|
self.task_deps = {}
|
|
|
|
self.stamp = {}
|
|
|
|
self.preferred = {}
|
|
|
|
|
|
|
|
"""
|
|
|
|
Indirect Cache variables
|
|
|
|
(set elsewhere)
|
|
|
|
"""
|
|
|
|
self.ignored_dependencies = []
|
2009-05-12 15:53:22 +00:00
|
|
|
self.world_target = set()
|
2006-11-16 15:02:15 +00:00
|
|
|
self.bbfile_priority = {}
|
|
|
|
self.bbfile_config_priorities = []
|