2011-01-01 23:55:54 +00:00
|
|
|
#!/usr/bin/env python
|
2007-01-08 23:53:01 +00:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# 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
|
2010-01-20 18:46:02 +00:00
|
|
|
# Copyright (C) 2006 - 2007 Richard Purdie
|
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.
|
|
|
|
|
2010-04-10 02:46:14 +00:00
|
|
|
from __future__ import print_function
|
2010-04-08 17:22:29 +00:00
|
|
|
import sys, os, glob, os.path, re, time
|
2010-12-07 18:00:22 +00:00
|
|
|
import atexit
|
|
|
|
import itertools
|
2010-06-10 17:35:31 +00:00
|
|
|
import logging
|
2010-11-19 03:21:54 +00:00
|
|
|
import multiprocessing
|
2010-12-07 18:00:22 +00:00
|
|
|
import sre_constants
|
|
|
|
import threading
|
2010-06-16 13:53:24 +00:00
|
|
|
from cStringIO import StringIO
|
|
|
|
from contextlib import closing
|
2011-02-24 20:16:43 +00:00
|
|
|
from functools import wraps
|
2011-06-29 18:37:37 +00:00
|
|
|
from collections import defaultdict
|
2013-03-06 15:32:35 +00:00
|
|
|
import bb, bb.exceptions, bb.command
|
2012-01-06 09:02:28 +00:00
|
|
|
from bb import utils, data, parse, event, cache, providers, taskdata, runqueue
|
2012-01-09 18:31:32 +00:00
|
|
|
import Queue
|
2014-03-09 17:05:54 +00:00
|
|
|
import signal
|
2012-01-10 06:13:50 +00:00
|
|
|
import prserv.serv
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
import pyinotify
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-06-10 17:35:31 +00:00
|
|
|
logger = logging.getLogger("BitBake")
|
|
|
|
collectlog = logging.getLogger("BitBake.Collection")
|
|
|
|
buildlog = logging.getLogger("BitBake.Build")
|
|
|
|
parselog = logging.getLogger("BitBake.Parsing")
|
|
|
|
providerlog = logging.getLogger("BitBake.Provider")
|
|
|
|
|
2012-01-13 17:01:51 +00:00
|
|
|
class NoSpecificMatch(bb.BBHandledException):
|
2010-01-20 18:46:02 +00:00
|
|
|
"""
|
2012-01-13 17:01:51 +00:00
|
|
|
Exception raised when no or multiple file matches are found
|
2010-01-20 18:46:02 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
class NothingToBuild(Exception):
|
|
|
|
"""
|
|
|
|
Exception raised when there is nothing to build
|
|
|
|
"""
|
|
|
|
|
2012-02-24 18:36:42 +00:00
|
|
|
class CollectionError(bb.BBHandledException):
|
|
|
|
"""
|
|
|
|
Exception raised when layer configuration is incorrect
|
|
|
|
"""
|
|
|
|
|
2010-12-08 19:30:33 +00:00
|
|
|
class state:
|
2013-10-06 12:42:39 +00:00
|
|
|
initial, parsing, running, shutdown, forceshutdown, stopped, error = range(7)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2011-06-01 14:37:07 +00:00
|
|
|
|
|
|
|
class SkippedPackage:
|
|
|
|
def __init__(self, info = None, reason = None):
|
2011-07-25 13:54:41 +00:00
|
|
|
self.pn = None
|
2011-06-01 14:37:07 +00:00
|
|
|
self.skipreason = None
|
|
|
|
self.provides = None
|
|
|
|
self.rprovides = None
|
|
|
|
|
|
|
|
if info:
|
2011-07-25 13:54:41 +00:00
|
|
|
self.pn = info.pn
|
2011-06-01 14:37:07 +00:00
|
|
|
self.skipreason = info.skipreason
|
|
|
|
self.provides = info.provides
|
|
|
|
self.rprovides = info.rprovides
|
|
|
|
elif reason:
|
|
|
|
self.skipreason = reason
|
|
|
|
|
2013-09-18 12:15:47 +00:00
|
|
|
|
|
|
|
class CookerFeatures(object):
|
2014-03-26 15:07:59 +00:00
|
|
|
_feature_list = [HOB_EXTRA_CACHES, SEND_DEPENDS_TREE, BASEDATASTORE_TRACKING, SEND_SANITYEVENTS] = range(4)
|
2013-09-18 12:15:47 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self._features=set()
|
|
|
|
|
|
|
|
def setFeature(self, f):
|
|
|
|
# validate we got a request for a feature we support
|
|
|
|
if f not in CookerFeatures._feature_list:
|
|
|
|
return
|
|
|
|
self._features.add(f)
|
|
|
|
|
|
|
|
def __contains__(self, f):
|
|
|
|
return f in self._features
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self._features.__iter__()
|
|
|
|
|
|
|
|
def next(self):
|
|
|
|
return self._features.next()
|
|
|
|
|
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
#============================================================================#
|
|
|
|
# BBCooker
|
|
|
|
#============================================================================#
|
|
|
|
class BBCooker:
|
|
|
|
"""
|
|
|
|
Manages one bitbake build run
|
|
|
|
"""
|
|
|
|
|
2014-03-28 11:09:19 +00:00
|
|
|
def __init__(self, configuration, featureSet = []):
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache = None
|
2011-06-01 14:37:07 +00:00
|
|
|
self.skiplist = {}
|
2013-09-18 12:15:47 +00:00
|
|
|
self.featureset = CookerFeatures()
|
2014-03-28 11:09:19 +00:00
|
|
|
for f in featureSet:
|
|
|
|
self.featureset.setFeature(f)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2007-04-01 15:04:49 +00:00
|
|
|
self.configuration = configuration
|
|
|
|
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
self.configwatcher = pyinotify.WatchManager()
|
2015-01-15 09:39:34 +00:00
|
|
|
self.configwatcher.bbseen = []
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications)
|
|
|
|
self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \
|
|
|
|
pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \
|
|
|
|
pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO
|
|
|
|
self.watcher = pyinotify.WatchManager()
|
2015-01-15 09:39:34 +00:00
|
|
|
self.watcher.bbseen = []
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
self.notifier = pyinotify.Notifier(self.watcher, self.notifications)
|
|
|
|
|
|
|
|
|
2013-12-02 17:48:40 +00:00
|
|
|
self.initConfigurationData()
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
self.baseconfig_valid = True
|
|
|
|
self.parsecache_valid = False
|
2007-04-01 15:04:49 +00:00
|
|
|
|
2011-11-08 17:52:44 +00:00
|
|
|
# Take a lock so only one copy of bitbake can run against a given build
|
|
|
|
# directory at a time
|
2013-05-30 12:26:58 +00:00
|
|
|
lockfile = self.data.expand("${TOPDIR}/bitbake.lock")
|
2011-11-08 17:52:44 +00:00
|
|
|
self.lock = bb.utils.lockfile(lockfile, False, False)
|
|
|
|
if not self.lock:
|
|
|
|
bb.fatal("Only one copy of bitbake should be run against a build directory")
|
2013-11-25 21:21:26 +00:00
|
|
|
try:
|
|
|
|
self.lock.seek(0)
|
|
|
|
self.lock.truncate()
|
|
|
|
if len(configuration.interface) >= 2:
|
|
|
|
self.lock.write("%s:%s\n" % (configuration.interface[0], configuration.interface[1]));
|
|
|
|
self.lock.flush()
|
|
|
|
except:
|
|
|
|
pass
|
2011-11-08 17:52:44 +00:00
|
|
|
|
2007-08-20 07:48:43 +00:00
|
|
|
# TOSTOP must not be set or our children will hang when they output
|
|
|
|
fd = sys.stdout.fileno()
|
|
|
|
if os.isatty(fd):
|
|
|
|
import termios
|
|
|
|
tcattr = termios.tcgetattr(fd)
|
|
|
|
if tcattr[3] & termios.TOSTOP:
|
2010-06-10 17:35:31 +00:00
|
|
|
buildlog.info("The terminal had the TOSTOP bit set, clearing...")
|
2007-08-20 07:48:43 +00:00
|
|
|
tcattr[3] = tcattr[3] & ~termios.TOSTOP
|
|
|
|
termios.tcsetattr(fd, termios.TCSANOW, tcattr)
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
self.command = bb.command.Command(self)
|
2010-12-08 19:30:33 +00:00
|
|
|
self.state = state.initial
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2011-06-08 16:23:42 +00:00
|
|
|
self.parser = None
|
|
|
|
|
2014-03-09 17:05:54 +00:00
|
|
|
signal.signal(signal.SIGTERM, self.sigterm_exception)
|
2014-11-17 10:27:36 +00:00
|
|
|
# Let SIGHUP exit as SIGTERM
|
|
|
|
signal.signal(signal.SIGHUP, self.sigterm_exception)
|
2014-03-09 17:05:54 +00:00
|
|
|
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
def config_notifications(self, event):
|
|
|
|
bb.parse.update_cache(event.path)
|
|
|
|
self.baseconfig_valid = False
|
|
|
|
|
|
|
|
def notifications(self, event):
|
|
|
|
bb.parse.update_cache(event.path)
|
|
|
|
self.parsecache_valid = False
|
|
|
|
|
2015-01-14 12:18:27 +00:00
|
|
|
def add_filewatch(self, deps, watcher=None):
|
|
|
|
if not watcher:
|
|
|
|
watcher = self.watcher
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
for i in deps:
|
2015-01-21 11:16:20 +00:00
|
|
|
f = os.path.dirname(i[0])
|
2015-01-15 09:39:34 +00:00
|
|
|
if f in watcher.bbseen:
|
|
|
|
continue
|
|
|
|
watcher.bbseen.append(f)
|
2015-01-14 12:18:27 +00:00
|
|
|
while True:
|
|
|
|
# We try and add watches for files that don't exist but if they did, would influence
|
|
|
|
# the parser. The parent directory of these files may not exist, in which case we need
|
|
|
|
# to watch any parent that does exist for changes.
|
|
|
|
try:
|
|
|
|
watcher.add_watch(f, self.watchmask, quiet=False)
|
|
|
|
break
|
|
|
|
except pyinotify.WatchManagerError as e:
|
|
|
|
if 'ENOENT' in str(e):
|
|
|
|
f = os.path.dirname(f)
|
2015-01-15 09:39:34 +00:00
|
|
|
watcher.bbseen.append(f)
|
2015-01-14 12:18:27 +00:00
|
|
|
continue
|
|
|
|
raise
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
|
2014-03-09 17:05:54 +00:00
|
|
|
def sigterm_exception(self, signum, stackframe):
|
2014-11-17 10:27:36 +00:00
|
|
|
if signum == signal.SIGTERM:
|
|
|
|
bb.warn("Cooker recieved SIGTERM, shutting down...")
|
|
|
|
elif signum == signal.SIGHUP:
|
|
|
|
bb.warn("Cooker recieved SIGHUP, shutting down...")
|
2014-03-09 17:05:54 +00:00
|
|
|
self.state = state.forceshutdown
|
|
|
|
|
2014-03-09 17:02:08 +00:00
|
|
|
def setFeatures(self, features):
|
2014-04-01 11:24:49 +00:00
|
|
|
# we only accept a new feature set if we're in state initial, so we can reset without problems
|
2014-11-27 14:59:21 +00:00
|
|
|
if self.state != state.initial and self.state != state.error:
|
2014-04-01 11:24:49 +00:00
|
|
|
raise Exception("Illegal state for feature set change")
|
2014-03-09 17:02:08 +00:00
|
|
|
original_featureset = list(self.featureset)
|
|
|
|
for feature in features:
|
|
|
|
self.featureset.setFeature(feature)
|
|
|
|
bb.debug(1, "Features set %s (was %s)" % (original_featureset, list(self.featureset)))
|
2014-11-27 14:59:21 +00:00
|
|
|
if (original_featureset != list(self.featureset)) and self.state != state.error:
|
2014-03-09 17:02:08 +00:00
|
|
|
self.reset()
|
|
|
|
|
2012-01-06 09:02:22 +00:00
|
|
|
def initConfigurationData(self):
|
2013-09-13 16:31:09 +00:00
|
|
|
|
|
|
|
self.state = state.initial
|
|
|
|
self.caches_array = []
|
2013-09-18 12:15:47 +00:00
|
|
|
|
2013-12-02 17:48:40 +00:00
|
|
|
if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
|
|
|
|
self.enableDataTracking()
|
|
|
|
|
2013-09-18 12:15:47 +00:00
|
|
|
all_extra_cache_names = []
|
|
|
|
# We hardcode all known cache types in a single place, here.
|
|
|
|
if CookerFeatures.HOB_EXTRA_CACHES in self.featureset:
|
|
|
|
all_extra_cache_names.append("bb.cache_extra:HobRecipeInfo")
|
|
|
|
|
|
|
|
caches_name_array = ['bb.cache:CoreRecipeInfo'] + all_extra_cache_names
|
2013-09-13 16:31:09 +00:00
|
|
|
|
|
|
|
# At least CoreRecipeInfo will be loaded, so caches_array will never be empty!
|
|
|
|
# This is the entry point, no further check needed!
|
|
|
|
for var in caches_name_array:
|
|
|
|
try:
|
|
|
|
module_name, cache_name = var.split(':')
|
|
|
|
module = __import__(module_name, fromlist=(cache_name,))
|
2013-09-18 12:15:47 +00:00
|
|
|
self.caches_array.append(getattr(module, cache_name))
|
2013-09-13 16:31:09 +00:00
|
|
|
except ImportError as exc:
|
|
|
|
logger.critical("Unable to import extra RecipeInfo '%s' from '%s': %s" % (cache_name, module_name, exc))
|
|
|
|
sys.exit("FATAL: Failed to import extra cache class '%s'." % cache_name)
|
|
|
|
|
2013-09-13 16:30:18 +00:00
|
|
|
self.databuilder = bb.cookerdata.CookerDataBuilder(self.configuration, False)
|
2013-05-20 22:00:31 +00:00
|
|
|
self.databuilder.parseBaseConfiguration()
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data = self.databuilder.data
|
|
|
|
self.data_hash = self.databuilder.data_hash
|
2011-07-14 22:25:59 +00:00
|
|
|
|
2014-12-09 11:57:38 +00:00
|
|
|
|
|
|
|
# we log all events to a file if so directed
|
|
|
|
if self.configuration.writeeventlog:
|
|
|
|
import json, pickle
|
|
|
|
DEFAULT_EVENTFILE = self.configuration.writeeventlog
|
|
|
|
class EventLogWriteHandler():
|
|
|
|
|
|
|
|
class EventWriter():
|
|
|
|
def __init__(self, cooker):
|
|
|
|
self.file_inited = None
|
|
|
|
self.cooker = cooker
|
|
|
|
self.event_queue = []
|
|
|
|
|
|
|
|
def init_file(self):
|
|
|
|
try:
|
|
|
|
# delete the old log
|
|
|
|
os.remove(DEFAULT_EVENTFILE)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# write current configuration data
|
|
|
|
with open(DEFAULT_EVENTFILE, "w") as f:
|
|
|
|
f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])}))
|
|
|
|
|
|
|
|
def write_event(self, event):
|
|
|
|
with open(DEFAULT_EVENTFILE, "a") as f:
|
|
|
|
try:
|
|
|
|
f.write("%s\n" % json.dumps({"class":event.__module__ + "." + event.__class__.__name__, "vars":json.dumps(pickle.dumps(event)) }))
|
|
|
|
except Exception as e:
|
|
|
|
import traceback
|
|
|
|
print(e, traceback.format_exc(e))
|
|
|
|
|
|
|
|
|
|
|
|
def send(self, event):
|
|
|
|
event_class = event.__module__ + "." + event.__class__.__name__
|
|
|
|
|
|
|
|
# init on bb.event.BuildStarted
|
|
|
|
if self.file_inited is None:
|
|
|
|
if event_class == "bb.event.BuildStarted":
|
|
|
|
self.init_file()
|
|
|
|
self.file_inited = True
|
|
|
|
|
|
|
|
# write pending events
|
|
|
|
for e in self.event_queue:
|
|
|
|
self.write_event(e)
|
|
|
|
|
|
|
|
# also write the current event
|
|
|
|
self.write_event(event)
|
|
|
|
|
|
|
|
else:
|
|
|
|
# queue all events until the file is inited
|
|
|
|
self.event_queue.append(event)
|
|
|
|
|
|
|
|
else:
|
|
|
|
# we have the file, just write the event
|
|
|
|
self.write_event(event)
|
|
|
|
|
|
|
|
# set our handler's event processor
|
|
|
|
event = EventWriter(self) # self is the cooker here
|
|
|
|
|
|
|
|
|
|
|
|
# set up cooker features for this mock UI handler
|
|
|
|
|
|
|
|
# we need to write the dependency tree in the log
|
|
|
|
self.featureset.setFeature(CookerFeatures.SEND_DEPENDS_TREE)
|
|
|
|
# register the log file writer as UI Handler
|
|
|
|
bb.event.register_UIHhandler(EventLogWriteHandler())
|
|
|
|
|
|
|
|
|
2013-09-13 16:31:09 +00:00
|
|
|
#
|
|
|
|
# Special updated configuration we use for firing events
|
|
|
|
#
|
|
|
|
self.event_data = bb.data.createCopy(self.data)
|
|
|
|
bb.data.update_data(self.event_data)
|
|
|
|
bb.parse.init_parser(self.event_data)
|
|
|
|
|
2013-11-14 13:56:30 +00:00
|
|
|
if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
|
|
|
|
self.disableDataTracking()
|
|
|
|
|
2013-12-02 17:48:40 +00:00
|
|
|
def enableDataTracking(self):
|
|
|
|
self.configuration.tracking = True
|
2014-03-28 11:06:18 +00:00
|
|
|
if hasattr(self, "data"):
|
|
|
|
self.data.enableTracking()
|
2013-12-02 17:48:40 +00:00
|
|
|
|
|
|
|
def disableDataTracking(self):
|
|
|
|
self.configuration.tracking = False
|
2014-03-28 11:06:18 +00:00
|
|
|
if hasattr(self, "data"):
|
|
|
|
self.data.disableTracking()
|
2013-11-14 13:56:30 +00:00
|
|
|
|
2013-07-29 11:44:58 +00:00
|
|
|
def modifyConfigurationVar(self, var, val, default_file, op):
|
|
|
|
if op == "append":
|
|
|
|
self.appendConfigurationVar(var, val, default_file)
|
|
|
|
elif op == "set":
|
2013-09-27 14:10:41 +00:00
|
|
|
self.saveConfigurationVar(var, val, default_file, "=")
|
|
|
|
elif op == "earlyAssign":
|
|
|
|
self.saveConfigurationVar(var, val, default_file, "?=")
|
|
|
|
|
2013-07-29 11:44:58 +00:00
|
|
|
|
|
|
|
def appendConfigurationVar(self, var, val, default_file):
|
|
|
|
#add append var operation to the end of default_file
|
2013-09-02 11:18:25 +00:00
|
|
|
default_file = bb.cookerdata.findConfigFile(default_file, self.data)
|
2013-07-29 11:44:58 +00:00
|
|
|
|
2013-11-12 16:12:17 +00:00
|
|
|
total = "#added by hob"
|
2013-07-29 11:44:58 +00:00
|
|
|
total += "\n%s += \"%s\"\n" % (var, val)
|
|
|
|
|
2013-11-12 16:12:17 +00:00
|
|
|
with open(default_file, 'a') as f:
|
2013-07-29 11:44:58 +00:00
|
|
|
f.write(total)
|
|
|
|
|
|
|
|
#add to history
|
2014-11-12 11:42:39 +00:00
|
|
|
loginfo = {"op":"append", "file":default_file, "line":total.count("\n")}
|
2013-07-29 11:44:58 +00:00
|
|
|
self.data.appendVar(var, val, **loginfo)
|
|
|
|
|
2013-09-27 14:10:41 +00:00
|
|
|
def saveConfigurationVar(self, var, val, default_file, op):
|
2013-01-25 14:10:12 +00:00
|
|
|
|
|
|
|
replaced = False
|
|
|
|
#do not save if nothing changed
|
2013-05-30 12:26:58 +00:00
|
|
|
if str(val) == self.data.getVar(var):
|
2013-01-25 14:10:12 +00:00
|
|
|
return
|
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
conf_files = self.data.varhistory.get_variable_files(var)
|
2013-01-25 14:10:12 +00:00
|
|
|
|
|
|
|
#format the value when it is a list
|
|
|
|
if isinstance(val, list):
|
|
|
|
listval = ""
|
|
|
|
for value in val:
|
|
|
|
listval += "%s " % value
|
|
|
|
val = listval
|
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
topdir = self.data.getVar("TOPDIR")
|
2013-01-25 14:10:12 +00:00
|
|
|
|
|
|
|
#comment or replace operations made on var
|
|
|
|
for conf_file in conf_files:
|
|
|
|
if topdir in conf_file:
|
|
|
|
with open(conf_file, 'r') as f:
|
|
|
|
contents = f.readlines()
|
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
lines = self.data.varhistory.get_variable_lines(var, conf_file)
|
2013-01-25 14:10:12 +00:00
|
|
|
for line in lines:
|
|
|
|
total = ""
|
|
|
|
i = 0
|
|
|
|
for c in contents:
|
|
|
|
total += c
|
|
|
|
i = i + 1
|
|
|
|
if i==int(line):
|
|
|
|
end_index = len(total)
|
|
|
|
index = total.rfind(var, 0, end_index)
|
|
|
|
|
|
|
|
begin_line = total.count("\n",0,index)
|
|
|
|
end_line = int(line)
|
|
|
|
|
|
|
|
#check if the variable was saved before in the same way
|
|
|
|
#if true it replace the place where the variable was declared
|
|
|
|
#else it comments it
|
2013-09-27 14:10:41 +00:00
|
|
|
if contents[begin_line-1]== "#added by hob\n":
|
|
|
|
contents[begin_line] = "%s %s \"%s\"\n" % (var, op, val)
|
2013-01-25 14:10:12 +00:00
|
|
|
replaced = True
|
|
|
|
else:
|
|
|
|
for ii in range(begin_line, end_line):
|
|
|
|
contents[ii] = "#" + contents[ii]
|
|
|
|
|
|
|
|
with open(conf_file, 'w') as f:
|
2013-11-12 16:12:17 +00:00
|
|
|
f.writelines(contents)
|
2013-01-25 14:10:12 +00:00
|
|
|
|
|
|
|
if replaced == False:
|
|
|
|
#remove var from history
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data.varhistory.del_var_history(var)
|
2013-01-25 14:10:12 +00:00
|
|
|
|
|
|
|
#add var to the end of default_file
|
2013-09-02 11:18:25 +00:00
|
|
|
default_file = bb.cookerdata.findConfigFile(default_file, self.data)
|
2013-01-25 14:10:12 +00:00
|
|
|
|
|
|
|
#add the variable on a single line, to be easy to replace the second time
|
2013-11-12 16:12:17 +00:00
|
|
|
total = "\n#added by hob"
|
2013-09-27 14:10:41 +00:00
|
|
|
total += "\n%s %s \"%s\"\n" % (var, op, val)
|
2013-01-25 14:10:12 +00:00
|
|
|
|
2013-11-12 16:12:17 +00:00
|
|
|
with open(default_file, 'a') as f:
|
2013-01-25 14:10:12 +00:00
|
|
|
f.write(total)
|
|
|
|
|
|
|
|
#add to history
|
2014-11-12 11:42:39 +00:00
|
|
|
loginfo = {"op":"set", "file":default_file, "line":total.count("\n")}
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data.setVar(var, val, **loginfo)
|
2013-01-25 14:10:12 +00:00
|
|
|
|
2013-10-04 13:19:45 +00:00
|
|
|
def removeConfigurationVar(self, var):
|
|
|
|
conf_files = self.data.varhistory.get_variable_files(var)
|
|
|
|
topdir = self.data.getVar("TOPDIR")
|
|
|
|
|
|
|
|
for conf_file in conf_files:
|
|
|
|
if topdir in conf_file:
|
|
|
|
with open(conf_file, 'r') as f:
|
|
|
|
contents = f.readlines()
|
|
|
|
|
|
|
|
lines = self.data.varhistory.get_variable_lines(var, conf_file)
|
|
|
|
for line in lines:
|
|
|
|
total = ""
|
|
|
|
i = 0
|
|
|
|
for c in contents:
|
|
|
|
total += c
|
|
|
|
i = i + 1
|
|
|
|
if i==int(line):
|
|
|
|
end_index = len(total)
|
|
|
|
index = total.rfind(var, 0, end_index)
|
|
|
|
|
|
|
|
begin_line = total.count("\n",0,index)
|
|
|
|
|
|
|
|
#check if the variable was saved before in the same way
|
2013-10-07 11:28:55 +00:00
|
|
|
if contents[begin_line-1]== "#added by hob\n":
|
2013-10-04 13:19:45 +00:00
|
|
|
contents[begin_line-1] = contents[begin_line] = "\n"
|
|
|
|
else:
|
|
|
|
contents[begin_line] = "\n"
|
|
|
|
#remove var from history
|
|
|
|
self.data.varhistory.del_var_history(var, conf_file, line)
|
2014-03-25 13:02:10 +00:00
|
|
|
#remove variable
|
|
|
|
self.data.delVar(var)
|
2013-10-04 13:19:45 +00:00
|
|
|
|
|
|
|
with open(conf_file, 'w') as f:
|
2013-11-12 16:12:17 +00:00
|
|
|
f.writelines(contents)
|
2013-10-04 13:19:45 +00:00
|
|
|
|
2013-06-20 14:21:15 +00:00
|
|
|
def createConfigFile(self, name):
|
|
|
|
path = os.getcwd()
|
|
|
|
confpath = os.path.join(path, "conf", name)
|
|
|
|
open(confpath, 'w').close()
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def parseConfiguration(self):
|
2012-02-28 13:37:41 +00:00
|
|
|
# Set log file verbosity
|
2013-05-30 12:26:58 +00:00
|
|
|
verboselogs = bb.utils.to_boolean(self.data.getVar("BB_VERBOSE_LOGS", "0"))
|
2012-02-28 13:37:41 +00:00
|
|
|
if verboselogs:
|
|
|
|
bb.msg.loggerVerboseLogs = True
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2007-09-02 14:10:08 +00:00
|
|
|
# Change nice level if we're asked to
|
2013-05-30 12:26:58 +00:00
|
|
|
nice = self.data.getVar("BB_NICE_LEVEL", True)
|
2007-09-02 14:10:08 +00:00
|
|
|
if nice:
|
|
|
|
curnice = os.nice(0)
|
|
|
|
nice = int(nice) - curnice
|
2010-06-10 17:35:31 +00:00
|
|
|
buildlog.verbose("Renice to %s " % os.nice(nice))
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
if self.recipecache:
|
|
|
|
del self.recipecache
|
|
|
|
self.recipecache = bb.cache.CacheData(self.caches_array)
|
2012-08-21 17:11:45 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
self.handleCollections( self.data.getVar("BBFILE_COLLECTIONS", True) )
|
2012-08-21 17:11:45 +00:00
|
|
|
|
2015-01-21 10:49:01 +00:00
|
|
|
def updateConfigOpts(self, options, environment):
|
2014-09-23 11:58:22 +00:00
|
|
|
for o in options:
|
|
|
|
setattr(self.configuration, o, options[o])
|
2015-01-21 10:49:01 +00:00
|
|
|
clean = True
|
|
|
|
for k in bb.utils.approved_variables():
|
|
|
|
if k in environment and k not in self.configuration.env:
|
|
|
|
logger.debug(1, "Updating environment variable %s to %s" % (k, environment[k]))
|
|
|
|
self.configuration.env[k] = environment[k]
|
|
|
|
clean = False
|
|
|
|
if k in self.configuration.env and k not in environment:
|
|
|
|
logger.debug(1, "Updating environment variable %s (deleted)" % (k))
|
|
|
|
del self.configuration.env[k]
|
|
|
|
clean = False
|
|
|
|
if k not in self.configuration.env and k not in environment:
|
|
|
|
continue
|
|
|
|
if environment[k] != self.configuration.env[k]:
|
|
|
|
logger.debug(1, "Updating environment variable %s to %s" % (k, environment[k]))
|
|
|
|
self.configuration.env[k] = environment[k]
|
|
|
|
clean = False
|
|
|
|
if not clean:
|
|
|
|
logger.debug(1, "Base environment change, triggering reparse")
|
|
|
|
self.baseconfig_valid = False
|
|
|
|
self.reset()
|
2014-09-23 11:58:22 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def runCommands(self, server, data, abort):
|
|
|
|
"""
|
|
|
|
Run any queued asynchronous command
|
|
|
|
This is done by the idle handler so it runs in true context rather than
|
|
|
|
tied to any UI.
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.command.runAsyncCommand()
|
2007-08-20 07:48:43 +00:00
|
|
|
|
2007-04-01 15:04:49 +00:00
|
|
|
def showVersions(self):
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
pkg_pn = self.recipecache.pkg_pn
|
2013-05-30 12:26:58 +00:00
|
|
|
(latest_versions, preferred_versions) = bb.providers.findProviders(self.data, self.recipecache, pkg_pn)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2012-09-19 03:00:33 +00:00
|
|
|
logger.plain("%-35s %25s %25s", "Recipe Name", "Latest Version", "Preferred Version")
|
|
|
|
logger.plain("%-35s %25s %25s\n", "===========", "==============", "=================")
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2009-06-11 20:10:04 +00:00
|
|
|
for p in sorted(pkg_pn):
|
2007-01-08 23:53:01 +00:00
|
|
|
pref = preferred_versions[p]
|
|
|
|
latest = latest_versions[p]
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
prefstr = pref[0][0] + ":" + pref[0][1] + '-' + pref[0][2]
|
|
|
|
lateststr = latest[0][0] + ":" + latest[0][1] + "-" + latest[0][2]
|
|
|
|
|
|
|
|
if pref == latest:
|
2007-01-08 23:53:01 +00:00
|
|
|
prefstr = ""
|
|
|
|
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.plain("%-35s %25s %25s", p, lateststr, prefstr)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def showEnvironment(self, buildfile = None, pkgs_to_build = []):
|
2008-01-06 16:51:51 +00:00
|
|
|
"""
|
2014-07-22 21:54:42 +00:00
|
|
|
Show the outer or per-recipe environment
|
2008-01-06 16:51:51 +00:00
|
|
|
"""
|
|
|
|
fn = None
|
|
|
|
envdata = None
|
|
|
|
|
|
|
|
if buildfile:
|
2011-08-10 13:15:38 +00:00
|
|
|
# Parse the configuration here. We need to do it explicitly here since
|
|
|
|
# this showEnvironment() code path doesn't use the cache
|
|
|
|
self.parseConfiguration()
|
|
|
|
|
2011-12-01 23:11:24 +00:00
|
|
|
fn, cls = bb.cache.Cache.virtualfn2realfn(buildfile)
|
|
|
|
fn = self.matchFile(fn)
|
|
|
|
fn = bb.cache.Cache.realfn2virtual(fn, cls)
|
2008-01-06 16:51:51 +00:00
|
|
|
elif len(pkgs_to_build) == 1:
|
2013-05-30 12:26:58 +00:00
|
|
|
ignore = self.data.getVar("ASSUME_PROVIDED", True) or ""
|
bitbake: print clear message for "bitbake -e ASSUME_PROVIDED"
"bitbake -e ASSUME_PROVIDED" should fail, but the error message wasn't
clear enough in the past:
$ bitbake -e bzip2-native
[snip]
ERROR: Command execution failed: Traceback (most recent call last):
File "/buildarea/lyang1/poky/bitbake/lib/bb/command.py", line 94, in
runAsyncCommand
commandmethod(self.cmds_async, self, options)
File "/buildarea/lyang1/poky/bitbake/lib/bb/command.py", line 323, in
showEnvironmentTarget
command.cooker.showEnvironment(None, pkg)
File "/buildarea/lyang1/poky/bitbake/lib/bb/cooker.py", line 325, in
showEnvironment
fnid = taskdata.build_targets[targetid][0]
KeyError: 0
[snip]
With this patch, the massage will be:
[snip]
ERROR: bzip2-native is in ASSUME_PROVIDED
ERROR: Command execution failed: Exited with 1
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
[YOCTO #3392]
(Bitbake rev: f31447dac92454c822d4ebb7dd48e96c6c69dde4)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-11-06 12:18:42 +00:00
|
|
|
if pkgs_to_build[0] in set(ignore.split()):
|
|
|
|
bb.fatal("%s is in ASSUME_PROVIDED" % pkgs_to_build[0])
|
|
|
|
|
2013-09-16 22:50:56 +00:00
|
|
|
taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, None, self.configuration.abort)
|
2008-01-06 16:51:51 +00:00
|
|
|
|
|
|
|
targetid = taskdata.getbuild_id(pkgs_to_build[0])
|
|
|
|
fnid = taskdata.build_targets[targetid][0]
|
|
|
|
fn = taskdata.fn_index[fnid]
|
|
|
|
else:
|
2013-05-30 12:26:58 +00:00
|
|
|
envdata = self.data
|
2008-01-06 16:51:51 +00:00
|
|
|
|
|
|
|
if fn:
|
2007-01-08 23:53:01 +00:00
|
|
|
try:
|
2013-05-30 12:26:58 +00:00
|
|
|
envdata = bb.cache.Cache.loadDataFull(fn, self.collection.get_file_appends(fn), self.data)
|
2011-06-14 23:44:58 +00:00
|
|
|
except Exception as e:
|
2010-06-10 17:35:31 +00:00
|
|
|
parselog.exception("Unable to read %s", fn)
|
2010-01-20 18:46:02 +00:00
|
|
|
raise
|
|
|
|
|
2013-01-18 11:45:22 +00:00
|
|
|
# Display history
|
|
|
|
with closing(StringIO()) as env:
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data.inchistory.emit(env)
|
2013-01-18 11:45:22 +00:00
|
|
|
logger.plain(env.getvalue())
|
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
# emit variables and shell functions
|
2010-06-10 17:35:31 +00:00
|
|
|
data.update_data(envdata)
|
|
|
|
with closing(StringIO()) as env:
|
|
|
|
data.emit_env(env, envdata, True)
|
|
|
|
logger.plain(env.getvalue())
|
2010-06-16 13:53:24 +00:00
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
# emit the metadata which isnt valid shell
|
2010-01-20 18:46:02 +00:00
|
|
|
data.expandKeys(envdata)
|
2008-01-06 16:51:51 +00:00
|
|
|
for e in envdata.keys():
|
|
|
|
if data.getVarFlag( e, 'python', envdata ):
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.plain("\npython %s () {\n%s}\n", e, data.getVar(e, envdata, 1))
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-09-16 22:50:56 +00:00
|
|
|
|
|
|
|
def buildTaskData(self, pkgs_to_build, task, abort):
|
2007-01-08 23:53:01 +00:00
|
|
|
"""
|
2011-01-07 12:00:09 +00:00
|
|
|
Prepare a runqueue and taskdata object for iteration over pkgs_to_build
|
2007-01-08 23:53:01 +00:00
|
|
|
"""
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.TreeDataPreparationStarted(), self.data)
|
2013-05-10 15:09:36 +00:00
|
|
|
|
2013-09-16 22:50:56 +00:00
|
|
|
# A task of None means use the default task
|
|
|
|
if task is None:
|
2010-01-20 18:46:02 +00:00
|
|
|
task = self.configuration.cmd
|
|
|
|
|
2013-09-16 22:50:56 +00:00
|
|
|
fulltargetlist = self.checkPackages(pkgs_to_build)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
localdata = data.createCopy(self.data)
|
2007-01-08 23:53:01 +00:00
|
|
|
bb.data.update_data(localdata)
|
|
|
|
bb.data.expandKeys(localdata)
|
2013-09-16 22:50:56 +00:00
|
|
|
taskdata = bb.taskdata.TaskData(abort, skiplist=self.skiplist)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2012-02-23 13:47:16 +00:00
|
|
|
current = 0
|
2013-09-16 22:50:56 +00:00
|
|
|
runlist = []
|
|
|
|
for k in fulltargetlist:
|
2014-01-27 14:37:04 +00:00
|
|
|
ktask = task
|
|
|
|
if ":do_" in k:
|
|
|
|
k2 = k.split(":do_")
|
|
|
|
k = k2[0]
|
|
|
|
ktask = k2[1]
|
2013-05-13 18:53:26 +00:00
|
|
|
taskdata.add_provider(localdata, self.recipecache, k)
|
2012-02-23 13:47:16 +00:00
|
|
|
current += 1
|
2014-01-27 14:37:04 +00:00
|
|
|
runlist.append([k, "do_%s" % ktask])
|
2013-09-16 22:50:56 +00:00
|
|
|
bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(fulltargetlist)), self.data)
|
2013-05-13 18:53:26 +00:00
|
|
|
taskdata.add_unresolved(localdata, self.recipecache)
|
2013-09-16 22:50:56 +00:00
|
|
|
bb.event.fire(bb.event.TreeDataPreparationCompleted(len(fulltargetlist)), self.data)
|
|
|
|
return taskdata, runlist, fulltargetlist
|
|
|
|
|
|
|
|
def prepareTreeData(self, pkgs_to_build, task):
|
|
|
|
"""
|
|
|
|
Prepare a runqueue and taskdata object for iteration over pkgs_to_build
|
|
|
|
"""
|
|
|
|
|
|
|
|
# We set abort to False here to prevent unbuildable targets raising
|
|
|
|
# an exception when we're just generating data
|
|
|
|
taskdata, runlist, pkgs_to_build = self.buildTaskData(pkgs_to_build, task, False)
|
|
|
|
|
2011-07-21 19:08:58 +00:00
|
|
|
return runlist, taskdata
|
2014-12-09 11:57:38 +00:00
|
|
|
|
2013-03-05 15:36:22 +00:00
|
|
|
######## WARNING : this function requires cache_extra to be enabled ########
|
2011-01-07 12:00:09 +00:00
|
|
|
|
2011-07-21 19:08:58 +00:00
|
|
|
def generateTaskDepTreeData(self, pkgs_to_build, task):
|
2011-01-07 12:00:09 +00:00
|
|
|
"""
|
2011-07-21 19:08:58 +00:00
|
|
|
Create a dependency graph of pkgs_to_build including reverse dependency
|
|
|
|
information.
|
2011-01-07 12:00:09 +00:00
|
|
|
"""
|
2011-07-21 19:08:58 +00:00
|
|
|
runlist, taskdata = self.prepareTreeData(pkgs_to_build, task)
|
2013-05-30 12:26:58 +00:00
|
|
|
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
|
2011-07-21 19:08:58 +00:00
|
|
|
rq.rqdata.prepare()
|
2013-09-18 12:15:48 +00:00
|
|
|
return self.buildDependTree(rq, taskdata)
|
2011-01-07 12:00:09 +00:00
|
|
|
|
2013-09-18 12:15:48 +00:00
|
|
|
|
|
|
|
def buildDependTree(self, rq, taskdata):
|
2010-03-24 23:56:12 +00:00
|
|
|
seen_fnids = []
|
2010-01-20 18:46:02 +00:00
|
|
|
depend_tree = {}
|
|
|
|
depend_tree["depends"] = {}
|
|
|
|
depend_tree["tdepends"] = {}
|
|
|
|
depend_tree["pn"] = {}
|
|
|
|
depend_tree["rdepends-pn"] = {}
|
|
|
|
depend_tree["packages"] = {}
|
|
|
|
depend_tree["rdepends-pkg"] = {}
|
|
|
|
depend_tree["rrecs-pkg"] = {}
|
2013-11-01 15:58:29 +00:00
|
|
|
depend_tree["layer-priorities"] = self.recipecache.bbfile_config_priorities
|
2008-01-06 23:06:42 +00:00
|
|
|
|
2010-11-19 20:39:22 +00:00
|
|
|
for task in xrange(len(rq.rqdata.runq_fnid)):
|
2010-08-18 10:30:53 +00:00
|
|
|
taskname = rq.rqdata.runq_task[task]
|
|
|
|
fnid = rq.rqdata.runq_fnid[task]
|
2007-01-08 23:53:01 +00:00
|
|
|
fn = taskdata.fn_index[fnid]
|
2013-05-13 18:53:26 +00:00
|
|
|
pn = self.recipecache.pkg_fn[fn]
|
|
|
|
version = "%s:%s-%s" % self.recipecache.pkg_pepvpr[fn]
|
2010-01-20 18:46:02 +00:00
|
|
|
if pn not in depend_tree["pn"]:
|
|
|
|
depend_tree["pn"][pn] = {}
|
|
|
|
depend_tree["pn"][pn]["filename"] = fn
|
|
|
|
depend_tree["pn"][pn]["version"] = version
|
2013-11-01 15:58:29 +00:00
|
|
|
depend_tree["pn"][pn]["inherits"] = self.recipecache.inherits.get(fn, None)
|
2013-09-18 12:15:50 +00:00
|
|
|
|
|
|
|
# if we have extra caches, list all attributes they bring in
|
|
|
|
extra_info = []
|
|
|
|
for cache_class in self.caches_array:
|
|
|
|
if type(cache_class) is type and issubclass(cache_class, bb.cache.RecipeInfoCommon) and hasattr(cache_class, 'cachefields'):
|
|
|
|
cachefields = getattr(cache_class, 'cachefields', [])
|
|
|
|
extra_info = extra_info + cachefields
|
|
|
|
|
|
|
|
# for all attributes stored, add them to the dependency tree
|
|
|
|
for ei in extra_info:
|
|
|
|
depend_tree["pn"][pn][ei] = vars(self.recipecache)[ei][fn]
|
|
|
|
|
|
|
|
|
2010-08-18 10:30:53 +00:00
|
|
|
for dep in rq.rqdata.runq_depends[task]:
|
|
|
|
depfn = taskdata.fn_index[rq.rqdata.runq_fnid[dep]]
|
2013-05-13 18:53:26 +00:00
|
|
|
deppn = self.recipecache.pkg_fn[depfn]
|
2010-08-18 10:30:53 +00:00
|
|
|
dotname = "%s.%s" % (pn, rq.rqdata.runq_task[task])
|
2010-01-20 18:46:02 +00:00
|
|
|
if not dotname in depend_tree["tdepends"]:
|
|
|
|
depend_tree["tdepends"][dotname] = []
|
2010-08-18 10:30:53 +00:00
|
|
|
depend_tree["tdepends"][dotname].append("%s.%s" % (deppn, rq.rqdata.runq_task[dep]))
|
2007-01-08 23:53:01 +00:00
|
|
|
if fnid not in seen_fnids:
|
|
|
|
seen_fnids.append(fnid)
|
|
|
|
packages = []
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
depend_tree["depends"][pn] = []
|
|
|
|
for dep in taskdata.depids[fnid]:
|
|
|
|
depend_tree["depends"][pn].append(taskdata.build_names_index[dep])
|
|
|
|
|
|
|
|
depend_tree["rdepends-pn"][pn] = []
|
|
|
|
for rdep in taskdata.rdepids[fnid]:
|
2010-03-24 23:56:12 +00:00
|
|
|
depend_tree["rdepends-pn"][pn].append(taskdata.run_names_index[rdep])
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
rdepends = self.recipecache.rundeps[fn]
|
2007-01-08 23:53:01 +00:00
|
|
|
for package in rdepends:
|
2010-01-20 18:46:02 +00:00
|
|
|
depend_tree["rdepends-pkg"][package] = []
|
2010-11-16 20:01:51 +00:00
|
|
|
for rdepend in rdepends[package]:
|
2010-01-20 18:46:02 +00:00
|
|
|
depend_tree["rdepends-pkg"][package].append(rdepend)
|
2007-01-08 23:53:01 +00:00
|
|
|
packages.append(package)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
rrecs = self.recipecache.runrecs[fn]
|
2007-01-08 23:53:01 +00:00
|
|
|
for package in rrecs:
|
2010-01-20 18:46:02 +00:00
|
|
|
depend_tree["rrecs-pkg"][package] = []
|
2010-11-16 20:01:51 +00:00
|
|
|
for rdepend in rrecs[package]:
|
2010-01-20 18:46:02 +00:00
|
|
|
depend_tree["rrecs-pkg"][package].append(rdepend)
|
2007-01-08 23:53:01 +00:00
|
|
|
if not package in packages:
|
|
|
|
packages.append(package)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
for package in packages:
|
2010-01-20 18:46:02 +00:00
|
|
|
if package not in depend_tree["packages"]:
|
|
|
|
depend_tree["packages"][package] = {}
|
|
|
|
depend_tree["packages"][package]["pn"] = pn
|
|
|
|
depend_tree["packages"][package]["filename"] = fn
|
|
|
|
depend_tree["packages"][package]["version"] = version
|
|
|
|
|
|
|
|
return depend_tree
|
|
|
|
|
2013-03-05 15:36:22 +00:00
|
|
|
######## WARNING : this function requires cache_extra to be enabled ########
|
2012-02-29 14:15:17 +00:00
|
|
|
def generatePkgDepTreeData(self, pkgs_to_build, task):
|
2011-07-21 19:08:58 +00:00
|
|
|
"""
|
|
|
|
Create a dependency tree of pkgs_to_build, returning the data.
|
|
|
|
"""
|
|
|
|
_, taskdata = self.prepareTreeData(pkgs_to_build, task)
|
|
|
|
tasks_fnid = []
|
|
|
|
if len(taskdata.tasks_name) != 0:
|
|
|
|
for task in xrange(len(taskdata.tasks_name)):
|
|
|
|
tasks_fnid.append(taskdata.tasks_fnid[task])
|
|
|
|
|
|
|
|
seen_fnids = []
|
|
|
|
depend_tree = {}
|
|
|
|
depend_tree["depends"] = {}
|
|
|
|
depend_tree["pn"] = {}
|
|
|
|
depend_tree["rdepends-pn"] = {}
|
|
|
|
depend_tree["rdepends-pkg"] = {}
|
2012-02-23 13:47:14 +00:00
|
|
|
depend_tree["rrecs-pkg"] = {}
|
2011-07-21 19:08:58 +00:00
|
|
|
|
2013-09-18 12:15:50 +00:00
|
|
|
# if we have extra caches, list all attributes they bring in
|
|
|
|
extra_info = []
|
|
|
|
for cache_class in self.caches_array:
|
|
|
|
if type(cache_class) is type and issubclass(cache_class, bb.cache.RecipeInfoCommon) and hasattr(cache_class, 'cachefields'):
|
|
|
|
cachefields = getattr(cache_class, 'cachefields', [])
|
|
|
|
extra_info = extra_info + cachefields
|
|
|
|
|
2011-07-21 19:08:58 +00:00
|
|
|
for task in xrange(len(tasks_fnid)):
|
|
|
|
fnid = tasks_fnid[task]
|
|
|
|
fn = taskdata.fn_index[fnid]
|
2013-05-13 18:53:26 +00:00
|
|
|
pn = self.recipecache.pkg_fn[fn]
|
2013-09-18 12:15:50 +00:00
|
|
|
|
2011-07-21 19:08:58 +00:00
|
|
|
if pn not in depend_tree["pn"]:
|
|
|
|
depend_tree["pn"][pn] = {}
|
|
|
|
depend_tree["pn"][pn]["filename"] = fn
|
2013-09-18 12:15:50 +00:00
|
|
|
version = "%s:%s-%s" % self.recipecache.pkg_pepvpr[fn]
|
2011-07-21 19:08:58 +00:00
|
|
|
depend_tree["pn"][pn]["version"] = version
|
2013-09-18 12:15:50 +00:00
|
|
|
rdepends = self.recipecache.rundeps[fn]
|
|
|
|
rrecs = self.recipecache.runrecs[fn]
|
|
|
|
depend_tree["pn"][pn]["inherits"] = self.recipecache.inherits.get(fn, None)
|
|
|
|
|
|
|
|
# for all extra attributes stored, add them to the dependency tree
|
|
|
|
for ei in extra_info:
|
|
|
|
depend_tree["pn"][pn][ei] = vars(self.recipecache)[ei][fn]
|
2011-07-21 19:08:58 +00:00
|
|
|
|
|
|
|
if fnid not in seen_fnids:
|
|
|
|
seen_fnids.append(fnid)
|
|
|
|
|
|
|
|
depend_tree["depends"][pn] = []
|
|
|
|
for dep in taskdata.depids[fnid]:
|
2012-02-29 14:15:17 +00:00
|
|
|
item = taskdata.build_names_index[dep]
|
|
|
|
pn_provider = ""
|
|
|
|
targetid = taskdata.getbuild_id(item)
|
|
|
|
if targetid in taskdata.build_targets and taskdata.build_targets[targetid]:
|
2012-02-29 14:15:18 +00:00
|
|
|
id = taskdata.build_targets[targetid][0]
|
|
|
|
fn_provider = taskdata.fn_index[id]
|
2013-05-13 18:53:26 +00:00
|
|
|
pn_provider = self.recipecache.pkg_fn[fn_provider]
|
2012-02-23 13:47:14 +00:00
|
|
|
else:
|
2012-02-29 14:15:17 +00:00
|
|
|
pn_provider = item
|
|
|
|
depend_tree["depends"][pn].append(pn_provider)
|
2011-07-21 19:08:58 +00:00
|
|
|
|
|
|
|
depend_tree["rdepends-pn"][pn] = []
|
|
|
|
for rdep in taskdata.rdepids[fnid]:
|
2012-02-29 14:15:19 +00:00
|
|
|
item = taskdata.run_names_index[rdep]
|
|
|
|
pn_rprovider = ""
|
|
|
|
targetid = taskdata.getrun_id(item)
|
|
|
|
if targetid in taskdata.run_targets and taskdata.run_targets[targetid]:
|
|
|
|
id = taskdata.run_targets[targetid][0]
|
|
|
|
fn_rprovider = taskdata.fn_index[id]
|
2013-05-13 18:53:26 +00:00
|
|
|
pn_rprovider = self.recipecache.pkg_fn[fn_rprovider]
|
2012-02-29 14:15:19 +00:00
|
|
|
else:
|
|
|
|
pn_rprovider = item
|
|
|
|
depend_tree["rdepends-pn"][pn].append(pn_rprovider)
|
2011-07-21 19:08:58 +00:00
|
|
|
|
2012-03-13 05:45:58 +00:00
|
|
|
depend_tree["rdepends-pkg"].update(rdepends)
|
|
|
|
depend_tree["rrecs-pkg"].update(rrecs)
|
|
|
|
|
2011-07-21 19:08:58 +00:00
|
|
|
return depend_tree
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
def generateDepTreeEvent(self, pkgs_to_build, task):
|
|
|
|
"""
|
|
|
|
Create a task dependency graph of pkgs_to_build.
|
|
|
|
Generate an event with the result
|
|
|
|
"""
|
2011-07-21 19:08:58 +00:00
|
|
|
depgraph = self.generateTaskDepTreeData(pkgs_to_build, task)
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.DepTreeGenerated(depgraph), self.data)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
def generateDotGraphFiles(self, pkgs_to_build, task):
|
|
|
|
"""
|
|
|
|
Create a task dependency graph of pkgs_to_build.
|
|
|
|
Save the result to a set of .dot files.
|
|
|
|
"""
|
|
|
|
|
2011-07-21 19:08:58 +00:00
|
|
|
depgraph = self.generateTaskDepTreeData(pkgs_to_build, task)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
# Prints a flattened form of package-depends below where subpackages of a package are merged into the main pn
|
|
|
|
depends_file = file('pn-depends.dot', 'w' )
|
2012-06-21 02:28:54 +00:00
|
|
|
buildlist_file = file('pn-buildlist', 'w' )
|
2010-04-10 02:46:14 +00:00
|
|
|
print("digraph depends {", file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for pn in depgraph["pn"]:
|
|
|
|
fn = depgraph["pn"][pn]["filename"]
|
|
|
|
version = depgraph["pn"][pn]["version"]
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn), file=depends_file)
|
2012-06-21 02:28:54 +00:00
|
|
|
print("%s" % pn, file=buildlist_file)
|
|
|
|
buildlist_file.close()
|
|
|
|
logger.info("PN build list saved to 'pn-buildlist'")
|
2010-01-20 18:46:02 +00:00
|
|
|
for pn in depgraph["depends"]:
|
|
|
|
for depend in depgraph["depends"][pn]:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" -> "%s"' % (pn, depend), file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for pn in depgraph["rdepends-pn"]:
|
|
|
|
for rdepend in depgraph["rdepends-pn"][pn]:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" -> "%s" [style=dashed]' % (pn, rdepend), file=depends_file)
|
|
|
|
print("}", file=depends_file)
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.info("PN dependencies saved to 'pn-depends.dot'")
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
depends_file = file('package-depends.dot', 'w' )
|
2010-04-10 02:46:14 +00:00
|
|
|
print("digraph depends {", file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for package in depgraph["packages"]:
|
|
|
|
pn = depgraph["packages"][package]["pn"]
|
|
|
|
fn = depgraph["packages"][package]["filename"]
|
|
|
|
version = depgraph["packages"][package]["version"]
|
|
|
|
if package == pn:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn), file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
else:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" [label="%s(%s) %s\\n%s"]' % (package, package, pn, version, fn), file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for depend in depgraph["depends"][pn]:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" -> "%s"' % (package, depend), file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for package in depgraph["rdepends-pkg"]:
|
|
|
|
for rdepend in depgraph["rdepends-pkg"][package]:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" -> "%s" [style=dashed]' % (package, rdepend), file=depends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for package in depgraph["rrecs-pkg"]:
|
|
|
|
for rdepend in depgraph["rrecs-pkg"][package]:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" -> "%s" [style=dashed]' % (package, rdepend), file=depends_file)
|
|
|
|
print("}", file=depends_file)
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.info("Package dependencies saved to 'package-depends.dot'")
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
tdepends_file = file('task-depends.dot', 'w' )
|
2010-04-10 02:46:14 +00:00
|
|
|
print("digraph depends {", file=tdepends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for task in depgraph["tdepends"]:
|
|
|
|
(pn, taskname) = task.rsplit(".", 1)
|
|
|
|
fn = depgraph["pn"][pn]["filename"]
|
|
|
|
version = depgraph["pn"][pn]["version"]
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s.%s" [label="%s %s\\n%s\\n%s"]' % (pn, taskname, pn, taskname, version, fn), file=tdepends_file)
|
2010-01-20 18:46:02 +00:00
|
|
|
for dep in depgraph["tdepends"][task]:
|
2010-04-10 02:46:14 +00:00
|
|
|
print('"%s" -> "%s"' % (task, dep), file=tdepends_file)
|
|
|
|
print("}", file=tdepends_file)
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.info("Task dependencies saved to 'task-depends.dot'")
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2011-07-02 15:15:30 +00:00
|
|
|
def show_appends_with_no_recipes( self ):
|
2013-05-10 14:35:39 +00:00
|
|
|
appends_without_recipes = [self.collection.appendlist[recipe]
|
2013-11-21 17:50:41 +00:00
|
|
|
for recipe in self.collection.appendlist
|
|
|
|
if recipe not in self.collection.appliedappendlist]
|
2011-07-02 15:15:30 +00:00
|
|
|
if appends_without_recipes:
|
|
|
|
appendlines = (' %s' % append
|
|
|
|
for appends in appends_without_recipes
|
|
|
|
for append in appends)
|
|
|
|
msg = 'No recipes available for:\n%s' % '\n'.join(appendlines)
|
|
|
|
warn_only = data.getVar("BB_DANGLINGAPPENDS_WARNONLY", \
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data, False) or "no"
|
2011-07-02 15:15:30 +00:00
|
|
|
if warn_only.lower() in ("1", "yes", "true"):
|
|
|
|
bb.warn(msg)
|
|
|
|
else:
|
|
|
|
bb.fatal(msg)
|
|
|
|
|
2013-05-10 15:26:03 +00:00
|
|
|
def handlePrefProviders(self):
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
localdata = data.createCopy(self.data)
|
2007-01-08 23:53:01 +00:00
|
|
|
bb.data.update_data(localdata)
|
|
|
|
bb.data.expandKeys(localdata)
|
|
|
|
|
|
|
|
# Handle PREFERRED_PROVIDERS
|
2011-11-25 14:57:53 +00:00
|
|
|
for p in (localdata.getVar('PREFERRED_PROVIDERS', True) or "").split():
|
2007-09-02 14:10:08 +00:00
|
|
|
try:
|
|
|
|
(providee, provider) = p.split(':')
|
|
|
|
except:
|
2010-06-10 17:35:31 +00:00
|
|
|
providerlog.critical("Malformed option in PREFERRED_PROVIDERS variable: %s" % p)
|
2007-09-02 14:10:08 +00:00
|
|
|
continue
|
2013-05-13 18:53:26 +00:00
|
|
|
if providee in self.recipecache.preferred and self.recipecache.preferred[providee] != provider:
|
|
|
|
providerlog.error("conflicting preferences for %s: both %s and %s specified", providee, provider, self.recipecache.preferred[providee])
|
|
|
|
self.recipecache.preferred[providee] = provider
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2012-01-06 09:02:28 +00:00
|
|
|
def findCoreBaseFiles(self, subdir, configfile):
|
2013-05-30 12:26:58 +00:00
|
|
|
corebase = self.data.getVar('COREBASE', True) or ""
|
2012-01-06 09:02:28 +00:00
|
|
|
paths = []
|
|
|
|
for root, dirs, files in os.walk(corebase + '/' + subdir):
|
|
|
|
for d in dirs:
|
|
|
|
configfilepath = os.path.join(root, d, configfile)
|
|
|
|
if os.path.exists(configfilepath):
|
|
|
|
paths.append(os.path.join(root, d))
|
|
|
|
|
|
|
|
if paths:
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.CoreBaseFilesFound(paths), self.data)
|
2012-01-06 09:02:28 +00:00
|
|
|
|
2011-07-01 06:02:51 +00:00
|
|
|
def findConfigFilePath(self, configfile):
|
2011-08-09 16:23:36 +00:00
|
|
|
"""
|
|
|
|
Find the location on disk of configfile and if it exists and was parsed by BitBake
|
|
|
|
emit the ConfigFilePathFound event with the path to the file.
|
|
|
|
"""
|
2013-09-02 11:18:25 +00:00
|
|
|
path = bb.cookerdata.findConfigFile(configfile, self.data)
|
2011-08-09 16:23:36 +00:00
|
|
|
if not path:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Generate a list of parsed configuration files by searching the files
|
|
|
|
# listed in the __depends and __base_depends variables with a .conf suffix.
|
|
|
|
conffiles = []
|
2013-05-30 12:26:58 +00:00
|
|
|
dep_files = self.data.getVar('__base_depends') or []
|
|
|
|
dep_files = dep_files + (self.data.getVar('__depends') or [])
|
2011-08-09 16:23:36 +00:00
|
|
|
|
|
|
|
for f in dep_files:
|
|
|
|
if f[0].endswith(".conf"):
|
|
|
|
conffiles.append(f[0])
|
|
|
|
|
|
|
|
_, conf, conffile = path.rpartition("conf/")
|
|
|
|
match = os.path.join(conf, conffile)
|
|
|
|
# Try and find matches for conf/conffilename.conf as we don't always
|
|
|
|
# have the full path to the file.
|
|
|
|
for cfg in conffiles:
|
|
|
|
if cfg.endswith(match):
|
|
|
|
bb.event.fire(bb.event.ConfigFilePathFound(path),
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data)
|
2011-08-09 16:23:36 +00:00
|
|
|
break
|
2011-07-01 06:02:51 +00:00
|
|
|
|
2011-07-01 06:02:52 +00:00
|
|
|
def findFilesMatchingInDir(self, filepattern, directory):
|
|
|
|
"""
|
|
|
|
Searches for files matching the regex 'pattern' which are children of
|
|
|
|
'directory' in each BBPATH. i.e. to find all rootfs package classes available
|
|
|
|
to BitBake one could call findFilesMatchingInDir(self, 'rootfs_', 'classes')
|
2011-07-13 16:06:41 +00:00
|
|
|
or to find all machine configuration files one could call:
|
2011-07-01 06:02:52 +00:00
|
|
|
findFilesMatchingInDir(self, 'conf/machines', 'conf')
|
|
|
|
"""
|
|
|
|
|
|
|
|
matches = []
|
|
|
|
p = re.compile(re.escape(filepattern))
|
2013-05-30 12:26:58 +00:00
|
|
|
bbpaths = self.data.getVar('BBPATH', True).split(':')
|
2011-07-01 06:02:52 +00:00
|
|
|
for path in bbpaths:
|
|
|
|
dirpath = os.path.join(path, directory)
|
|
|
|
if os.path.exists(dirpath):
|
|
|
|
for root, dirs, files in os.walk(dirpath):
|
|
|
|
for f in files:
|
|
|
|
if p.search(f):
|
|
|
|
matches.append(f)
|
|
|
|
|
2011-07-13 16:06:41 +00:00
|
|
|
if matches:
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data)
|
2011-07-01 06:02:52 +00:00
|
|
|
|
2011-01-04 20:28:20 +00:00
|
|
|
def findConfigFiles(self, varname):
|
|
|
|
"""
|
|
|
|
Find config files which are appropriate values for varname.
|
|
|
|
i.e. MACHINE, DISTRO
|
|
|
|
"""
|
|
|
|
possible = []
|
|
|
|
var = varname.lower()
|
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
data = self.data
|
2011-01-04 20:28:20 +00:00
|
|
|
# iterate configs
|
2011-11-25 14:57:53 +00:00
|
|
|
bbpaths = data.getVar('BBPATH', True).split(':')
|
2011-01-04 20:28:20 +00:00
|
|
|
for path in bbpaths:
|
|
|
|
confpath = os.path.join(path, "conf", var)
|
|
|
|
if os.path.exists(confpath):
|
|
|
|
for root, dirs, files in os.walk(confpath):
|
|
|
|
# get all child files, these are appropriate values
|
|
|
|
for f in files:
|
|
|
|
val, sep, end = f.rpartition('.')
|
|
|
|
if end == 'conf':
|
|
|
|
possible.append(val)
|
|
|
|
|
2011-07-13 16:06:41 +00:00
|
|
|
if possible:
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.ConfigFilesFound(var, possible), self.data)
|
2011-01-04 20:28:20 +00:00
|
|
|
|
2011-01-07 11:45:00 +00:00
|
|
|
def findInheritsClass(self, klass):
|
|
|
|
"""
|
|
|
|
Find all recipes which inherit the specified class
|
|
|
|
"""
|
2011-01-04 20:08:51 +00:00
|
|
|
pkg_list = []
|
2011-01-04 20:28:20 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
for pfn in self.recipecache.pkg_fn:
|
|
|
|
inherits = self.recipecache.inherits.get(pfn, None)
|
2011-01-04 20:08:51 +00:00
|
|
|
if inherits and inherits.count(klass) > 0:
|
2013-05-13 18:53:26 +00:00
|
|
|
pkg_list.append(self.recipecache.pkg_fn[pfn])
|
2011-01-04 20:08:51 +00:00
|
|
|
|
|
|
|
return pkg_list
|
|
|
|
|
2012-02-29 14:15:17 +00:00
|
|
|
def generateTargetsTree(self, klass=None, pkgs=[]):
|
2011-01-04 20:08:51 +00:00
|
|
|
"""
|
|
|
|
Generate a dependency tree of buildable targets
|
|
|
|
Generate an event with the result
|
|
|
|
"""
|
2011-07-01 06:02:54 +00:00
|
|
|
# if the caller hasn't specified a pkgs list default to universe
|
2011-07-01 06:02:49 +00:00
|
|
|
if not len(pkgs):
|
2011-07-01 06:02:54 +00:00
|
|
|
pkgs = ['universe']
|
2011-01-04 20:08:51 +00:00
|
|
|
# if inherited_class passed ensure all recipes which inherit the
|
|
|
|
# specified class are included in pkgs
|
|
|
|
if klass:
|
2011-01-07 11:45:00 +00:00
|
|
|
extra_pkgs = self.findInheritsClass(klass)
|
2011-01-04 20:08:51 +00:00
|
|
|
pkgs = pkgs + extra_pkgs
|
|
|
|
|
|
|
|
# generate a dependency tree for all our packages
|
2012-02-29 14:15:17 +00:00
|
|
|
tree = self.generatePkgDepTreeData(pkgs, 'build')
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.TargetsTreeGenerated(tree), self.data)
|
2011-01-04 20:08:51 +00:00
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
def buildWorldTargetList(self):
|
|
|
|
"""
|
|
|
|
Build package list for "bitbake world"
|
|
|
|
"""
|
2010-06-10 17:35:31 +00:00
|
|
|
parselog.debug(1, "collating packages for \"world\"")
|
2013-05-13 18:53:26 +00:00
|
|
|
for f in self.recipecache.possible_world:
|
2007-01-08 23:53:01 +00:00
|
|
|
terminal = True
|
2013-05-13 18:53:26 +00:00
|
|
|
pn = self.recipecache.pkg_fn[f]
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
for p in self.recipecache.pn_provides[pn]:
|
2007-01-08 23:53:01 +00:00
|
|
|
if p.startswith('virtual/'):
|
2010-06-10 17:35:31 +00:00
|
|
|
parselog.debug(2, "World build skipping %s due to %s provider starting with virtual/", f, p)
|
2007-01-08 23:53:01 +00:00
|
|
|
terminal = False
|
|
|
|
break
|
2013-05-13 18:53:26 +00:00
|
|
|
for pf in self.recipecache.providers[p]:
|
|
|
|
if self.recipecache.pkg_fn[pf] != pn:
|
2010-06-10 17:35:31 +00:00
|
|
|
parselog.debug(2, "World build skipping %s due to both us and %s providing %s", f, pf, p)
|
2007-01-08 23:53:01 +00:00
|
|
|
terminal = False
|
|
|
|
break
|
|
|
|
if terminal:
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.world_target.add(pn)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
|
|
|
def interactiveMode( self ):
|
|
|
|
"""Drop off into a shell"""
|
|
|
|
try:
|
|
|
|
from bb import shell
|
2010-06-10 17:35:31 +00:00
|
|
|
except ImportError:
|
|
|
|
parselog.exception("Interactive mode not available")
|
|
|
|
sys.exit(1)
|
2007-01-08 23:53:01 +00:00
|
|
|
else:
|
|
|
|
shell.start( self )
|
|
|
|
|
|
|
|
|
|
|
|
def handleCollections( self, collections ):
|
|
|
|
"""Handle collections"""
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = False
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.bbfile_config_priorities = []
|
2007-01-08 23:53:01 +00:00
|
|
|
if collections:
|
2011-06-29 18:37:39 +00:00
|
|
|
collection_priorities = {}
|
|
|
|
collection_depends = {}
|
2007-01-08 23:53:01 +00:00
|
|
|
collection_list = collections.split()
|
2011-06-29 18:37:39 +00:00
|
|
|
min_prio = 0
|
2007-01-08 23:53:01 +00:00
|
|
|
for c in collection_list:
|
2011-06-29 18:37:39 +00:00
|
|
|
# Get collection priority if defined explicitly
|
2013-05-30 12:26:58 +00:00
|
|
|
priority = self.data.getVar("BBFILE_PRIORITY_%s" % c, True)
|
2011-06-29 18:37:39 +00:00
|
|
|
if priority:
|
|
|
|
try:
|
|
|
|
prio = int(priority)
|
|
|
|
except ValueError:
|
|
|
|
parselog.error("invalid value for BBFILE_PRIORITY_%s: \"%s\"", c, priority)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2011-06-29 18:37:39 +00:00
|
|
|
if min_prio == 0 or prio < min_prio:
|
|
|
|
min_prio = prio
|
|
|
|
collection_priorities[c] = prio
|
|
|
|
else:
|
|
|
|
collection_priorities[c] = None
|
|
|
|
|
|
|
|
# Check dependencies and store information for priority calculation
|
2013-05-30 12:26:58 +00:00
|
|
|
deps = self.data.getVar("LAYERDEPENDS_%s" % c, True)
|
2011-06-29 18:37:39 +00:00
|
|
|
if deps:
|
|
|
|
depnamelist = []
|
|
|
|
deplist = deps.split()
|
|
|
|
for dep in deplist:
|
|
|
|
depsplit = dep.split(':')
|
|
|
|
if len(depsplit) > 1:
|
|
|
|
try:
|
|
|
|
depver = int(depsplit[1])
|
|
|
|
except ValueError:
|
|
|
|
parselog.error("invalid version value in LAYERDEPENDS_%s: \"%s\"", c, dep)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2011-06-29 18:37:39 +00:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
depver = None
|
|
|
|
dep = depsplit[0]
|
|
|
|
depnamelist.append(dep)
|
|
|
|
|
|
|
|
if dep in collection_list:
|
|
|
|
if depver:
|
2013-05-30 12:26:58 +00:00
|
|
|
layerver = self.data.getVar("LAYERVERSION_%s" % dep, True)
|
2011-06-29 18:37:39 +00:00
|
|
|
if layerver:
|
|
|
|
try:
|
|
|
|
lver = int(layerver)
|
|
|
|
except ValueError:
|
|
|
|
parselog.error("invalid value for LAYERVERSION_%s: \"%s\"", c, layerver)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2011-06-29 18:37:39 +00:00
|
|
|
continue
|
2013-05-09 21:14:06 +00:00
|
|
|
if lver != depver:
|
2012-09-25 15:25:28 +00:00
|
|
|
parselog.error("Layer '%s' depends on version %d of layer '%s', but version %d is enabled in your configuration", c, depver, dep, lver)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2011-06-29 18:37:39 +00:00
|
|
|
else:
|
2012-09-25 15:25:28 +00:00
|
|
|
parselog.error("Layer '%s' depends on version %d of layer '%s', which exists in your configuration but does not specify a version", c, depver, dep)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2011-06-29 18:37:39 +00:00
|
|
|
else:
|
2012-09-25 15:25:28 +00:00
|
|
|
parselog.error("Layer '%s' depends on layer '%s', but this layer is not enabled in your configuration", c, dep)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2011-06-29 18:37:39 +00:00
|
|
|
collection_depends[c] = depnamelist
|
|
|
|
else:
|
|
|
|
collection_depends[c] = []
|
|
|
|
|
|
|
|
# Recursively work out collection priorities based on dependencies
|
|
|
|
def calc_layer_priority(collection):
|
|
|
|
if not collection_priorities[collection]:
|
|
|
|
max_depprio = min_prio
|
|
|
|
for dep in collection_depends[collection]:
|
|
|
|
calc_layer_priority(dep)
|
|
|
|
depprio = collection_priorities[dep]
|
|
|
|
if depprio > max_depprio:
|
|
|
|
max_depprio = depprio
|
|
|
|
max_depprio += 1
|
|
|
|
parselog.debug(1, "Calculated priority of layer %s as %d", collection, max_depprio)
|
|
|
|
collection_priorities[collection] = max_depprio
|
|
|
|
|
|
|
|
# Calculate all layer priorities using calc_layer_priority and store in bbfile_config_priorities
|
|
|
|
for c in collection_list:
|
|
|
|
calc_layer_priority(c)
|
2013-05-30 12:26:58 +00:00
|
|
|
regex = self.data.getVar("BBFILE_PATTERN_%s" % c, True)
|
2007-01-08 23:53:01 +00:00
|
|
|
if regex == None:
|
2010-06-10 17:35:31 +00:00
|
|
|
parselog.error("BBFILE_PATTERN_%s not defined" % c)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2007-01-08 23:53:01 +00:00
|
|
|
continue
|
|
|
|
try:
|
|
|
|
cre = re.compile(regex)
|
|
|
|
except re.error:
|
2010-06-10 17:35:31 +00:00
|
|
|
parselog.error("BBFILE_PATTERN_%s \"%s\" is not a valid regular expression", c, regex)
|
2012-02-24 18:36:42 +00:00
|
|
|
errors = True
|
2007-01-08 23:53:01 +00:00
|
|
|
continue
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.bbfile_config_priorities.append((c, regex, cre, collection_priorities[c]))
|
2012-02-24 18:36:42 +00:00
|
|
|
if errors:
|
|
|
|
# We've already printed the actual error(s)
|
|
|
|
raise CollectionError("Errors during parsing layer configuration")
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2007-04-01 15:04:49 +00:00
|
|
|
def buildSetVars(self):
|
|
|
|
"""
|
|
|
|
Setup any variables needed before starting a build
|
|
|
|
"""
|
2013-05-30 12:26:58 +00:00
|
|
|
if not self.data.getVar("BUILDNAME"):
|
|
|
|
self.data.setVar("BUILDNAME", time.strftime('%Y%m%d%H%M'))
|
|
|
|
self.data.setVar("BUILDSTART", time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime()))
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2011-05-27 14:11:49 +00:00
|
|
|
def matchFiles(self, bf):
|
2007-01-08 23:53:01 +00:00
|
|
|
"""
|
2010-01-20 18:46:02 +00:00
|
|
|
Find the .bb files which match the expression in 'buildfile'.
|
2007-01-08 23:53:01 +00:00
|
|
|
"""
|
2011-05-27 14:11:49 +00:00
|
|
|
if bf.startswith("/") or bf.startswith("../"):
|
|
|
|
bf = os.path.abspath(bf)
|
2013-05-10 14:35:39 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
self.collection = CookerCollectFiles(self.recipecache.bbfile_config_priorities)
|
2013-05-30 12:26:58 +00:00
|
|
|
filelist, masked = self.collection.collect_bbfiles(self.data, self.event_data)
|
2007-04-01 15:04:49 +00:00
|
|
|
try:
|
|
|
|
os.stat(bf)
|
2012-05-24 12:56:34 +00:00
|
|
|
bf = os.path.abspath(bf)
|
2010-01-20 18:46:02 +00:00
|
|
|
return [bf]
|
2007-04-01 15:04:49 +00:00
|
|
|
except OSError:
|
2011-05-27 14:11:49 +00:00
|
|
|
regexp = re.compile(bf)
|
2007-04-01 15:04:49 +00:00
|
|
|
matches = []
|
|
|
|
for f in filelist:
|
|
|
|
if regexp.search(f) and os.path.isfile(f):
|
|
|
|
matches.append(f)
|
2010-01-20 18:46:02 +00:00
|
|
|
return matches
|
2007-08-12 23:06:49 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def matchFile(self, buildfile):
|
|
|
|
"""
|
|
|
|
Find the .bb file which matches the expression in 'buildfile'.
|
|
|
|
Raise an error if multiple files
|
|
|
|
"""
|
|
|
|
matches = self.matchFiles(buildfile)
|
|
|
|
if len(matches) != 1:
|
2012-01-13 17:01:51 +00:00
|
|
|
if matches:
|
|
|
|
msg = "Unable to match '%s' to a specific recipe file - %s matches found:" % (buildfile, len(matches))
|
|
|
|
if matches:
|
|
|
|
for f in matches:
|
|
|
|
msg += "\n %s" % f
|
|
|
|
parselog.error(msg)
|
|
|
|
else:
|
|
|
|
parselog.error("Unable to find any recipe file matching '%s'" % buildfile)
|
|
|
|
raise NoSpecificMatch
|
2010-01-20 18:46:02 +00:00
|
|
|
return matches[0]
|
|
|
|
|
|
|
|
def buildFile(self, buildfile, task):
|
2007-08-12 23:06:49 +00:00
|
|
|
"""
|
|
|
|
Build the file matching regexp buildfile
|
|
|
|
"""
|
|
|
|
|
2011-07-22 15:38:50 +00:00
|
|
|
# Too many people use -b because they think it's how you normally
|
|
|
|
# specify a target to be built, so show a warning
|
|
|
|
bb.warn("Buildfile specified, dependencies will not be handled. If this is not what you want, do not use -b / --buildfile.")
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
# Parse the configuration here. We need to do it explicitly here since
|
|
|
|
# buildFile() doesn't use the cache
|
|
|
|
self.parseConfiguration()
|
|
|
|
|
|
|
|
# If we are told to do the None task then query the default task
|
|
|
|
if (task == None):
|
|
|
|
task = self.configuration.cmd
|
|
|
|
|
2011-04-04 21:37:59 +00:00
|
|
|
fn, cls = bb.cache.Cache.virtualfn2realfn(buildfile)
|
2011-05-27 14:11:49 +00:00
|
|
|
fn = self.matchFile(fn)
|
2010-03-21 22:02:56 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
self.buildSetVars()
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
infos = bb.cache.Cache.parse(fn, self.collection.get_file_appends(fn), \
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data,
|
2011-06-03 00:21:44 +00:00
|
|
|
self.caches_array)
|
2011-04-04 21:37:59 +00:00
|
|
|
infos = dict(infos)
|
|
|
|
|
2011-05-27 14:11:49 +00:00
|
|
|
fn = bb.cache.Cache.realfn2virtual(fn, cls)
|
2011-04-04 21:37:59 +00:00
|
|
|
try:
|
2011-06-03 00:22:40 +00:00
|
|
|
info_array = infos[fn]
|
2011-04-04 21:37:59 +00:00
|
|
|
except KeyError:
|
|
|
|
bb.fatal("%s does not exist" % fn)
|
2012-08-22 15:14:38 +00:00
|
|
|
|
|
|
|
if info_array[0].skipped:
|
|
|
|
bb.fatal("%s was skipped: %s" % (fn, info_array[0].skipreason))
|
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.add_from_recipeinfo(fn, info_array)
|
2008-03-03 22:01:45 +00:00
|
|
|
|
|
|
|
# Tweak some variables
|
2011-06-03 00:22:40 +00:00
|
|
|
item = info_array[0].pn
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.ignored_dependencies = set()
|
|
|
|
self.recipecache.bbfile_priority[fn] = 1
|
2008-03-03 22:01:45 +00:00
|
|
|
|
|
|
|
# Remove external dependencies
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.task_deps[fn]['depends'] = {}
|
|
|
|
self.recipecache.deps[fn] = []
|
|
|
|
self.recipecache.rundeps[fn] = []
|
|
|
|
self.recipecache.runrecs[fn] = []
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2012-06-18 15:45:35 +00:00
|
|
|
# Invalidate task for target if force mode active
|
2007-04-01 15:04:49 +00:00
|
|
|
if self.configuration.force:
|
2012-06-18 15:45:35 +00:00
|
|
|
logger.verbose("Invalidate task %s, %s", task, fn)
|
2013-05-13 18:53:26 +00:00
|
|
|
bb.parse.siggen.invalidate_task('do_%s' % task, self.recipecache, fn)
|
2007-04-01 15:04:49 +00:00
|
|
|
|
2008-03-03 22:01:45 +00:00
|
|
|
# Setup taskdata structure
|
2010-01-20 18:46:02 +00:00
|
|
|
taskdata = bb.taskdata.TaskData(self.configuration.abort)
|
2013-05-30 12:26:58 +00:00
|
|
|
taskdata.add_provider(self.data, self.recipecache, item)
|
2007-04-01 15:04:49 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
buildname = self.data.getVar("BUILDNAME")
|
|
|
|
bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.event_data)
|
2008-03-03 22:01:45 +00:00
|
|
|
|
|
|
|
# Execute the runqueue
|
2010-01-20 18:46:02 +00:00
|
|
|
runlist = [[item, "do_%s" % task]]
|
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
def buildFileIdle(server, rq, abort):
|
|
|
|
|
2013-11-19 16:46:41 +00:00
|
|
|
msg = None
|
2013-09-13 16:31:54 +00:00
|
|
|
if abort or self.state == state.forceshutdown:
|
2010-01-20 18:46:02 +00:00
|
|
|
rq.finish_runqueue(True)
|
2013-11-19 16:46:41 +00:00
|
|
|
msg = "Forced shutdown"
|
2010-12-08 19:30:33 +00:00
|
|
|
elif self.state == state.shutdown:
|
2010-01-20 18:46:02 +00:00
|
|
|
rq.finish_runqueue(False)
|
2013-11-19 16:46:41 +00:00
|
|
|
msg = "Stopped build"
|
2008-05-19 20:41:58 +00:00
|
|
|
failures = 0
|
2010-01-20 18:46:02 +00:00
|
|
|
try:
|
|
|
|
retval = rq.execute_runqueue()
|
2010-06-10 22:09:55 +00:00
|
|
|
except runqueue.TaskFailure as exc:
|
2010-09-10 01:03:40 +00:00
|
|
|
failures += len(exc.args)
|
2010-01-20 18:46:02 +00:00
|
|
|
retval = False
|
2011-06-08 16:23:42 +00:00
|
|
|
except SystemExit as exc:
|
|
|
|
self.command.finishAsyncCommand()
|
|
|
|
return False
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
if not retval:
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runq_fnid), buildname, item, failures), self.event_data)
|
2013-11-19 16:46:41 +00:00
|
|
|
self.command.finishAsyncCommand(msg)
|
2010-01-20 18:46:02 +00:00
|
|
|
return False
|
2010-08-18 16:37:15 +00:00
|
|
|
if retval is True:
|
|
|
|
return True
|
2011-02-15 23:18:39 +00:00
|
|
|
return retval
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2013-05-20 21:54:30 +00:00
|
|
|
self.configuration.server_register_idlecallback(buildFileIdle, rq)
|
2007-04-01 15:04:49 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def buildTargets(self, targets, task):
|
2007-04-01 15:04:49 +00:00
|
|
|
"""
|
|
|
|
Attempt to build the targets specified
|
|
|
|
"""
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def buildTargetsIdle(server, rq, abort):
|
2013-11-19 16:46:41 +00:00
|
|
|
msg = None
|
2013-09-13 16:31:54 +00:00
|
|
|
if abort or self.state == state.forceshutdown:
|
2010-01-20 18:46:02 +00:00
|
|
|
rq.finish_runqueue(True)
|
2013-11-19 16:46:41 +00:00
|
|
|
msg = "Forced shutdown"
|
2010-12-08 19:30:33 +00:00
|
|
|
elif self.state == state.shutdown:
|
2010-01-20 18:46:02 +00:00
|
|
|
rq.finish_runqueue(False)
|
2013-11-19 16:46:41 +00:00
|
|
|
msg = "Stopped build"
|
2008-05-19 20:41:58 +00:00
|
|
|
failures = 0
|
2010-01-20 18:46:02 +00:00
|
|
|
try:
|
|
|
|
retval = rq.execute_runqueue()
|
2010-06-10 22:09:55 +00:00
|
|
|
except runqueue.TaskFailure as exc:
|
2010-09-10 01:03:40 +00:00
|
|
|
failures += len(exc.args)
|
2010-01-20 18:46:02 +00:00
|
|
|
retval = False
|
2011-06-08 16:23:42 +00:00
|
|
|
except SystemExit as exc:
|
|
|
|
self.command.finishAsyncCommand()
|
|
|
|
return False
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
if not retval:
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runq_fnid), buildname, targets, failures), self.data)
|
2013-11-19 16:46:41 +00:00
|
|
|
self.command.finishAsyncCommand(msg)
|
2010-12-01 16:59:04 +00:00
|
|
|
return False
|
2010-08-18 16:37:15 +00:00
|
|
|
if retval is True:
|
|
|
|
return True
|
2011-02-15 23:18:39 +00:00
|
|
|
return retval
|
2007-04-01 15:04:49 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
self.buildSetVars()
|
2007-04-01 15:04:49 +00:00
|
|
|
|
2013-09-16 22:50:56 +00:00
|
|
|
taskdata, runlist, fulltargetlist = self.buildTaskData(targets, task, self.configuration.abort)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-09-16 22:50:56 +00:00
|
|
|
buildname = self.data.getVar("BUILDNAME")
|
|
|
|
bb.event.fire(bb.event.BuildStarted(buildname, fulltargetlist), self.data)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
rq = bb.runqueue.RunQueue(self, self.data, self.recipecache, taskdata, runlist)
|
2013-09-16 22:50:56 +00:00
|
|
|
if 'universe' in targets:
|
2012-02-13 11:41:31 +00:00
|
|
|
rq.rqdata.warn_multi_bb = True
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-20 21:54:30 +00:00
|
|
|
self.configuration.server_register_idlecallback(buildTargetsIdle, rq)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-09-18 12:15:51 +00:00
|
|
|
|
|
|
|
def getAllKeysWithFlags(self, flaglist):
|
|
|
|
dump = {}
|
|
|
|
for k in self.data.keys():
|
|
|
|
try:
|
|
|
|
v = self.data.getVar(k, True)
|
|
|
|
if not k.startswith("__") and not isinstance(v, bb.data_smart.DataSmart):
|
2013-11-14 13:56:30 +00:00
|
|
|
dump[k] = {
|
|
|
|
'v' : v ,
|
|
|
|
'history' : self.data.varhistory.variable(k),
|
|
|
|
}
|
2013-09-18 12:15:51 +00:00
|
|
|
for d in flaglist:
|
|
|
|
dump[k][d] = self.data.getVarFlag(k, d)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
return dump
|
|
|
|
|
|
|
|
|
2013-07-29 10:02:24 +00:00
|
|
|
def generateNewImage(self, image, base_image, package_queue, timestamp, description):
|
2012-12-12 11:51:51 +00:00
|
|
|
'''
|
2013-07-29 09:55:06 +00:00
|
|
|
Create a new image with a "require"/"inherit" base_image statement
|
2012-12-12 11:51:51 +00:00
|
|
|
'''
|
2013-07-29 09:55:06 +00:00
|
|
|
if timestamp:
|
|
|
|
image_name = os.path.splitext(image)[0]
|
|
|
|
timestr = time.strftime("-%Y%m%d-%H%M%S")
|
|
|
|
dest = image_name + str(timestr) + ".bb"
|
|
|
|
else:
|
|
|
|
if not image.endswith(".bb"):
|
|
|
|
dest = image + ".bb"
|
|
|
|
else:
|
|
|
|
dest = image
|
2012-12-12 11:51:51 +00:00
|
|
|
|
2014-04-01 10:59:05 +00:00
|
|
|
basename = False
|
2013-07-25 07:45:28 +00:00
|
|
|
if base_image:
|
|
|
|
with open(base_image, 'r') as f:
|
|
|
|
require_line = f.readline()
|
2014-04-01 10:59:05 +00:00
|
|
|
p = re.compile("IMAGE_BASENAME *=")
|
|
|
|
for line in f:
|
|
|
|
if p.search(line):
|
|
|
|
basename = True
|
2013-07-25 07:45:28 +00:00
|
|
|
|
2012-12-12 11:51:51 +00:00
|
|
|
with open(dest, "w") as imagefile:
|
2013-07-29 09:55:06 +00:00
|
|
|
if base_image is None:
|
2014-03-12 12:03:49 +00:00
|
|
|
imagefile.write("inherit core-image\n")
|
2013-07-29 09:55:06 +00:00
|
|
|
else:
|
2013-07-25 07:45:28 +00:00
|
|
|
topdir = self.data.getVar("TOPDIR")
|
|
|
|
if topdir in base_image:
|
|
|
|
base_image = require_line.split()[1]
|
2013-07-29 09:55:06 +00:00
|
|
|
imagefile.write("require " + base_image + "\n")
|
2013-07-16 13:35:22 +00:00
|
|
|
image_install = "IMAGE_INSTALL = \""
|
2012-12-12 11:51:51 +00:00
|
|
|
for package in package_queue:
|
2013-07-16 13:35:22 +00:00
|
|
|
image_install += str(package) + " "
|
|
|
|
image_install += "\"\n"
|
|
|
|
imagefile.write(image_install)
|
2012-12-12 11:51:51 +00:00
|
|
|
|
2013-07-29 10:02:24 +00:00
|
|
|
description_var = "DESCRIPTION = \"" + description + "\"\n"
|
|
|
|
imagefile.write(description_var)
|
|
|
|
|
2014-04-01 10:59:05 +00:00
|
|
|
if basename:
|
|
|
|
# If this is overwritten in a inherited image, reset it to default
|
|
|
|
image_basename = "IMAGE_BASENAME = \"${PN}\"\n"
|
|
|
|
imagefile.write(image_basename)
|
|
|
|
|
2012-12-12 11:51:51 +00:00
|
|
|
self.state = state.initial
|
2013-07-29 09:55:06 +00:00
|
|
|
if timestamp:
|
|
|
|
return timestr
|
2012-12-12 11:51:51 +00:00
|
|
|
|
2013-08-26 12:41:03 +00:00
|
|
|
# This is called for all async commands when self.state != running
|
2011-08-10 01:27:51 +00:00
|
|
|
def updateCache(self):
|
|
|
|
if self.state == state.running:
|
2010-01-20 18:46:02 +00:00
|
|
|
return
|
2008-10-17 09:46:35 +00:00
|
|
|
|
2015-01-08 09:41:03 +00:00
|
|
|
if self.state in (state.shutdown, state.forceshutdown, state.error):
|
2014-01-21 15:59:36 +00:00
|
|
|
if hasattr(self.parser, 'shutdown'):
|
|
|
|
self.parser.shutdown(clean=False, force = True)
|
2013-09-13 16:34:42 +00:00
|
|
|
raise bb.BBHandledException()
|
2011-06-08 16:23:42 +00:00
|
|
|
|
2010-12-08 19:30:33 +00:00
|
|
|
if self.state != state.parsing:
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
for n in [self.confignotifier, self.notifier]:
|
|
|
|
if n.check_events(timeout=0):
|
|
|
|
# read notified events and enqeue them
|
|
|
|
n.read_events()
|
|
|
|
n.process_events()
|
|
|
|
if not self.baseconfig_valid:
|
|
|
|
logger.debug(1, "Reloading base configuration data")
|
|
|
|
self.initConfigurationData()
|
|
|
|
self.baseconfig_valid = True
|
|
|
|
self.parsecache_valid = False
|
|
|
|
|
|
|
|
if self.state != state.parsing and not self.parsecache_valid:
|
2010-01-20 18:46:02 +00:00
|
|
|
self.parseConfiguration ()
|
2014-03-26 15:07:59 +00:00
|
|
|
if CookerFeatures.SEND_SANITYEVENTS in self.featureset:
|
|
|
|
bb.event.fire(bb.event.SanityCheck(False), self.data)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
ignore = self.data.getVar("ASSUME_PROVIDED", True) or ""
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.ignored_dependencies = set(ignore.split())
|
2010-03-24 23:56:12 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
for dep in self.configuration.extra_assume_provided:
|
2013-05-13 18:53:26 +00:00
|
|
|
self.recipecache.ignored_dependencies.add(dep)
|
2010-03-24 23:56:12 +00:00
|
|
|
|
2013-05-13 18:53:26 +00:00
|
|
|
self.collection = CookerCollectFiles(self.recipecache.bbfile_config_priorities)
|
2013-05-30 12:26:58 +00:00
|
|
|
(filelist, masked) = self.collection.collect_bbfiles(self.data, self.event_data)
|
2013-05-10 14:35:39 +00:00
|
|
|
|
2013-05-30 12:26:58 +00:00
|
|
|
self.data.renameVar("__depends", "__base_depends")
|
2015-01-14 12:18:27 +00:00
|
|
|
self.add_filewatch(self.data.getVar("__base_depends"), self.configwatcher)
|
2009-07-29 13:33:14 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
self.parser = CookerParser(self, filelist, masked)
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
self.parsecache_valid = True
|
|
|
|
|
|
|
|
self.state = state.parsing
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
if not self.parser.parse_next():
|
2010-06-10 17:35:31 +00:00
|
|
|
collectlog.debug(1, "parsing complete")
|
2012-08-22 19:33:39 +00:00
|
|
|
if self.parser.error:
|
2013-09-13 16:34:42 +00:00
|
|
|
raise bb.BBHandledException()
|
2012-08-22 19:33:39 +00:00
|
|
|
self.show_appends_with_no_recipes()
|
2013-05-10 15:26:03 +00:00
|
|
|
self.handlePrefProviders()
|
2014-12-19 10:20:32 +00:00
|
|
|
self.recipecache.bbfile_priority = self.collection.collection_priorities(self.recipecache.pkg_fn, self.data)
|
2010-12-08 19:30:33 +00:00
|
|
|
self.state = state.running
|
2010-01-20 18:46:02 +00:00
|
|
|
return None
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
return True
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
def checkPackages(self, pkgs_to_build):
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-09-18 07:38:44 +00:00
|
|
|
# Return a copy, don't modify the original
|
|
|
|
pkgs_to_build = pkgs_to_build[:]
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
if len(pkgs_to_build) == 0:
|
|
|
|
raise NothingToBuild
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-11-14 14:57:54 +00:00
|
|
|
ignore = (self.data.getVar("ASSUME_PROVIDED", True) or "").split()
|
|
|
|
for pkg in pkgs_to_build:
|
|
|
|
if pkg in ignore:
|
|
|
|
parselog.warn("Explicit target \"%s\" is in ASSUME_PROVIDED, ignoring" % pkg)
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
if 'world' in pkgs_to_build:
|
|
|
|
self.buildWorldTargetList()
|
|
|
|
pkgs_to_build.remove('world')
|
2013-05-13 18:53:26 +00:00
|
|
|
for t in self.recipecache.world_target:
|
2010-01-20 18:46:02 +00:00
|
|
|
pkgs_to_build.append(t)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2011-04-21 18:44:45 +00:00
|
|
|
if 'universe' in pkgs_to_build:
|
2012-02-13 11:41:31 +00:00
|
|
|
parselog.warn("The \"universe\" target is only intended for testing and may produce errors.")
|
2011-04-21 18:44:45 +00:00
|
|
|
parselog.debug(1, "collating packages for \"universe\"")
|
|
|
|
pkgs_to_build.remove('universe')
|
2013-05-13 18:53:26 +00:00
|
|
|
for t in self.recipecache.universe_target:
|
2011-04-21 18:44:45 +00:00
|
|
|
pkgs_to_build.append(t)
|
|
|
|
|
2010-01-20 18:46:02 +00:00
|
|
|
return pkgs_to_build
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pre_serve(self):
|
|
|
|
# Empty the environment. The environment will be populated as
|
|
|
|
# necessary from the data store.
|
|
|
|
#bb.utils.empty_environment()
|
|
|
|
try:
|
2013-06-07 17:13:04 +00:00
|
|
|
self.prhost = prserv.serv.auto_start(self.data)
|
2013-05-10 14:35:39 +00:00
|
|
|
except prserv.serv.PRServiceConfigError:
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.event.fire(CookerExit(), self.event_data)
|
2013-10-06 12:42:39 +00:00
|
|
|
self.state = state.error
|
2013-05-10 14:35:39 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
def post_serve(self):
|
2013-05-30 12:26:58 +00:00
|
|
|
prserv.serv.auto_shutdown(self.data)
|
|
|
|
bb.event.fire(CookerExit(), self.event_data)
|
2013-05-10 14:35:39 +00:00
|
|
|
|
2013-09-13 16:31:54 +00:00
|
|
|
def shutdown(self, force = False):
|
|
|
|
if force:
|
|
|
|
self.state = state.forceshutdown
|
|
|
|
else:
|
|
|
|
self.state = state.shutdown
|
2013-05-10 14:35:39 +00:00
|
|
|
|
2013-09-13 16:32:53 +00:00
|
|
|
def finishcommand(self):
|
|
|
|
self.state = state.initial
|
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
def reset(self):
|
2013-12-02 17:48:40 +00:00
|
|
|
self.initConfigurationData()
|
2013-05-10 14:35:39 +00:00
|
|
|
|
|
|
|
def server_main(cooker, func, *args):
|
|
|
|
cooker.pre_serve()
|
|
|
|
|
|
|
|
if cooker.configuration.profile:
|
|
|
|
try:
|
|
|
|
import cProfile as profile
|
|
|
|
except:
|
|
|
|
import profile
|
|
|
|
prof = profile.Profile()
|
|
|
|
|
|
|
|
ret = profile.Profile.runcall(prof, func, *args)
|
|
|
|
|
|
|
|
prof.dump_stats("profile.log")
|
|
|
|
bb.utils.process_profilelog("profile.log")
|
|
|
|
print("Raw profiling information saved to profile.log and processed statistics to profile.log.processed")
|
|
|
|
|
|
|
|
else:
|
|
|
|
ret = func(*args)
|
|
|
|
|
|
|
|
cooker.post_serve()
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
class CookerExit(bb.event.Event):
|
|
|
|
"""
|
|
|
|
Notify clients of the Cooker shutdown
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
bb.event.Event.__init__(self)
|
|
|
|
|
|
|
|
|
|
|
|
class CookerCollectFiles(object):
|
|
|
|
def __init__(self, priorities):
|
|
|
|
self.appendlist = {}
|
2013-11-21 17:50:41 +00:00
|
|
|
self.appliedappendlist = []
|
2013-05-10 14:35:39 +00:00
|
|
|
self.bbfile_config_priorities = priorities
|
|
|
|
|
|
|
|
def calc_bbfile_priority( self, filename, matched = None ):
|
|
|
|
for _, _, regex, pri in self.bbfile_config_priorities:
|
|
|
|
if regex.match(filename):
|
|
|
|
if matched != None:
|
|
|
|
if not regex in matched:
|
|
|
|
matched.add(regex)
|
|
|
|
return pri
|
|
|
|
return 0
|
|
|
|
|
2013-05-10 14:52:47 +00:00
|
|
|
def get_bbfiles(self):
|
2007-01-08 23:53:01 +00:00
|
|
|
"""Get list of default .bb files by reading out the current directory"""
|
2013-05-10 14:52:47 +00:00
|
|
|
path = os.getcwd()
|
2007-01-08 23:53:01 +00:00
|
|
|
contents = os.listdir(path)
|
|
|
|
bbfiles = []
|
|
|
|
for f in contents:
|
2013-05-10 14:52:47 +00:00
|
|
|
if f.endswith(".bb"):
|
|
|
|
bbfiles.append(os.path.abspath(os.path.join(path, f)))
|
2007-01-08 23:53:01 +00:00
|
|
|
return bbfiles
|
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
def find_bbfiles(self, path):
|
2010-07-16 14:10:22 +00:00
|
|
|
"""Find all the .bb and .bbappend files in a directory"""
|
2007-04-01 15:04:49 +00:00
|
|
|
found = []
|
|
|
|
for dir, dirs, files in os.walk(path):
|
|
|
|
for ignored in ('SCCS', 'CVS', '.svn'):
|
|
|
|
if ignored in dirs:
|
|
|
|
dirs.remove(ignored)
|
2014-08-22 11:45:11 +00:00
|
|
|
found += [os.path.join(dir, f) for f in files if (f.endswith(['.bb', '.bbappend']))]
|
2007-04-01 15:04:49 +00:00
|
|
|
|
|
|
|
return found
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
def collect_bbfiles(self, config, eventdata):
|
2007-01-08 23:53:01 +00:00
|
|
|
"""Collect all available .bb build files"""
|
2013-05-10 15:16:26 +00:00
|
|
|
masked = 0
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-06-10 17:35:31 +00:00
|
|
|
collectlog.debug(1, "collecting .bb files")
|
2010-07-16 14:10:22 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
files = (config.getVar( "BBFILES", True) or "").split()
|
|
|
|
config.setVar("BBFILES", " ".join(files))
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2011-06-01 10:09:34 +00:00
|
|
|
# Sort files by priority
|
|
|
|
files.sort( key=lambda fileitem: self.calc_bbfile_priority(fileitem) )
|
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
if not len(files):
|
|
|
|
files = self.get_bbfiles()
|
|
|
|
|
|
|
|
if not len(files):
|
2010-06-10 17:35:31 +00:00
|
|
|
collectlog.error("no recipe files to build, check your BBPATH and BBFILES?")
|
2013-05-10 14:35:39 +00:00
|
|
|
bb.event.fire(CookerExit(), eventdata)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2011-05-27 14:13:54 +00:00
|
|
|
# Can't use set here as order is important
|
|
|
|
newfiles = []
|
2007-01-08 23:53:01 +00:00
|
|
|
for f in files:
|
|
|
|
if os.path.isdir(f):
|
|
|
|
dirfiles = self.find_bbfiles(f)
|
2011-05-27 14:13:54 +00:00
|
|
|
for g in dirfiles:
|
|
|
|
if g not in newfiles:
|
|
|
|
newfiles.append(g)
|
2009-05-11 21:41:17 +00:00
|
|
|
else:
|
|
|
|
globbed = glob.glob(f)
|
|
|
|
if not globbed and os.path.exists(f):
|
|
|
|
globbed = [f]
|
2011-05-27 14:13:54 +00:00
|
|
|
for g in globbed:
|
|
|
|
if g not in newfiles:
|
|
|
|
newfiles.append(g)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
bbmask = config.getVar('BBMASK', True)
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
if bbmask:
|
|
|
|
try:
|
|
|
|
bbmask_compiled = re.compile(bbmask)
|
|
|
|
except sre_constants.error:
|
2010-06-10 17:35:31 +00:00
|
|
|
collectlog.critical("BBMASK is not a valid regular expression, ignoring.")
|
|
|
|
return list(newfiles), 0
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
bbfiles = []
|
|
|
|
bbappend = []
|
2009-05-11 21:41:17 +00:00
|
|
|
for f in newfiles:
|
2010-07-16 14:10:22 +00:00
|
|
|
if bbmask and bbmask_compiled.search(f):
|
2010-06-10 17:35:31 +00:00
|
|
|
collectlog.debug(1, "skipping masked file %s", f)
|
2007-01-08 23:53:01 +00:00
|
|
|
masked += 1
|
|
|
|
continue
|
2010-07-16 14:10:22 +00:00
|
|
|
if f.endswith('.bb'):
|
|
|
|
bbfiles.append(f)
|
|
|
|
elif f.endswith('.bbappend'):
|
|
|
|
bbappend.append(f)
|
|
|
|
else:
|
2010-06-10 17:35:31 +00:00
|
|
|
collectlog.debug(1, "skipping %s: unknown file extension", f)
|
2010-07-16 14:10:22 +00:00
|
|
|
|
|
|
|
# Build a list of .bbappend files for each .bb file
|
|
|
|
for f in bbappend:
|
|
|
|
base = os.path.basename(f).replace('.bbappend', '.bb')
|
|
|
|
if not base in self.appendlist:
|
|
|
|
self.appendlist[base] = []
|
2011-07-25 18:48:58 +00:00
|
|
|
if f not in self.appendlist[base]:
|
|
|
|
self.appendlist[base].append(f)
|
2010-09-28 15:24:55 +00:00
|
|
|
|
2011-06-29 18:37:37 +00:00
|
|
|
# Find overlayed recipes
|
|
|
|
# bbfiles will be in priority order which makes this easy
|
|
|
|
bbfile_seen = dict()
|
|
|
|
self.overlayed = defaultdict(list)
|
|
|
|
for f in reversed(bbfiles):
|
|
|
|
base = os.path.basename(f)
|
|
|
|
if base not in bbfile_seen:
|
|
|
|
bbfile_seen[base] = f
|
|
|
|
else:
|
|
|
|
topfile = bbfile_seen[base]
|
|
|
|
self.overlayed[topfile].append(f)
|
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
return (bbfiles, masked)
|
|
|
|
|
|
|
|
def get_file_appends(self, fn):
|
|
|
|
"""
|
|
|
|
Returns a list of .bbappend files to apply to fn
|
|
|
|
"""
|
2013-11-21 17:50:41 +00:00
|
|
|
filelist = []
|
2010-07-16 14:10:22 +00:00
|
|
|
f = os.path.basename(fn)
|
2013-11-21 17:50:41 +00:00
|
|
|
for bbappend in self.appendlist:
|
2013-11-29 05:19:11 +00:00
|
|
|
if (bbappend == f) or ('%' in bbappend and bbappend.startswith(f[:bbappend.index('%')])):
|
2013-11-21 17:50:41 +00:00
|
|
|
self.appliedappendlist.append(bbappend)
|
|
|
|
for filename in self.appendlist[bbappend]:
|
|
|
|
filelist.append(filename)
|
|
|
|
return filelist
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2014-12-19 10:20:32 +00:00
|
|
|
def collection_priorities(self, pkgfns, d):
|
2011-01-07 13:54:50 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
priorities = {}
|
2011-07-14 22:25:59 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
# Calculate priorities for each file
|
|
|
|
matched = set()
|
|
|
|
for p in pkgfns:
|
|
|
|
realfn, cls = bb.cache.Cache.virtualfn2realfn(p)
|
|
|
|
priorities[p] = self.calc_bbfile_priority(realfn, matched)
|
2014-12-09 11:57:38 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
# Don't show the warning if the BBFILE_PATTERN did match .bbappend files
|
|
|
|
unmatched = set()
|
2014-12-09 11:57:38 +00:00
|
|
|
for _, _, regex, pri in self.bbfile_config_priorities:
|
2013-05-10 14:35:39 +00:00
|
|
|
if not regex in matched:
|
|
|
|
unmatched.add(regex)
|
2010-11-13 13:23:54 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
def findmatch(regex):
|
|
|
|
for bbfile in self.appendlist:
|
|
|
|
for append in self.appendlist[bbfile]:
|
|
|
|
if regex.match(append):
|
|
|
|
return True
|
|
|
|
return False
|
2010-11-13 13:23:54 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
for unmatch in unmatched.copy():
|
|
|
|
if findmatch(unmatch):
|
|
|
|
unmatched.remove(unmatch)
|
2010-11-13 13:23:54 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
for collection, pattern, regex, _ in self.bbfile_config_priorities:
|
|
|
|
if regex in unmatched:
|
2014-12-19 10:20:32 +00:00
|
|
|
if d.getVar('BBFILE_PATTERN_IGNORE_EMPTY_%s' % collection, True) != '1':
|
|
|
|
collectlog.warn("No bb files matched BBFILE_PATTERN_%s '%s'" % (collection, pattern))
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2013-05-10 14:35:39 +00:00
|
|
|
return priorities
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2011-02-23 11:09:07 +00:00
|
|
|
class ParsingFailure(Exception):
|
|
|
|
def __init__(self, realexception, recipe):
|
|
|
|
self.realexception = realexception
|
|
|
|
self.recipe = recipe
|
2011-05-05 23:50:34 +00:00
|
|
|
Exception.__init__(self, realexception, recipe)
|
2011-02-23 11:09:07 +00:00
|
|
|
|
2013-03-06 15:32:35 +00:00
|
|
|
class Feeder(multiprocessing.Process):
|
|
|
|
def __init__(self, jobs, to_parsers, quit):
|
|
|
|
self.quit = quit
|
|
|
|
self.jobs = jobs
|
|
|
|
self.to_parsers = to_parsers
|
|
|
|
multiprocessing.Process.__init__(self)
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
quit = self.quit.get_nowait()
|
|
|
|
except Queue.Empty:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if quit == 'cancel':
|
|
|
|
self.to_parsers.cancel_join_thread()
|
|
|
|
break
|
|
|
|
|
|
|
|
try:
|
|
|
|
job = self.jobs.pop()
|
|
|
|
except IndexError:
|
|
|
|
break
|
|
|
|
|
|
|
|
try:
|
|
|
|
self.to_parsers.put(job, timeout=0.5)
|
|
|
|
except Queue.Full:
|
|
|
|
self.jobs.insert(0, job)
|
|
|
|
continue
|
|
|
|
|
|
|
|
class Parser(multiprocessing.Process):
|
2013-09-15 08:57:02 +00:00
|
|
|
def __init__(self, jobs, results, quit, init, profile):
|
2013-03-06 15:32:35 +00:00
|
|
|
self.jobs = jobs
|
|
|
|
self.results = results
|
|
|
|
self.quit = quit
|
|
|
|
self.init = init
|
|
|
|
multiprocessing.Process.__init__(self)
|
2013-05-23 09:49:57 +00:00
|
|
|
self.context = bb.utils.get_context().copy()
|
2013-05-23 09:50:30 +00:00
|
|
|
self.handlers = bb.event.get_class_handlers().copy()
|
2013-09-15 08:57:02 +00:00
|
|
|
self.profile = profile
|
2013-03-06 15:32:35 +00:00
|
|
|
|
|
|
|
def run(self):
|
2013-09-15 08:57:02 +00:00
|
|
|
|
|
|
|
if not self.profile:
|
|
|
|
self.realrun()
|
|
|
|
return
|
|
|
|
|
|
|
|
try:
|
|
|
|
import cProfile as profile
|
|
|
|
except:
|
|
|
|
import profile
|
|
|
|
prof = profile.Profile()
|
|
|
|
try:
|
|
|
|
profile.Profile.runcall(prof, self.realrun)
|
|
|
|
finally:
|
|
|
|
logfile = "profile-parse-%s.log" % multiprocessing.current_process().name
|
|
|
|
prof.dump_stats(logfile)
|
|
|
|
bb.utils.process_profilelog(logfile)
|
|
|
|
print("Raw profiling information saved to %s and processed statistics to %s.processed" % (logfile, logfile))
|
|
|
|
|
|
|
|
def realrun(self):
|
2013-03-06 15:32:35 +00:00
|
|
|
if self.init:
|
|
|
|
self.init()
|
|
|
|
|
|
|
|
pending = []
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
self.quit.get_nowait()
|
|
|
|
except Queue.Empty:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
self.results.cancel_join_thread()
|
|
|
|
break
|
|
|
|
|
|
|
|
if pending:
|
|
|
|
result = pending.pop()
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
job = self.jobs.get(timeout=0.25)
|
|
|
|
except Queue.Empty:
|
|
|
|
continue
|
|
|
|
|
|
|
|
if job is None:
|
|
|
|
break
|
|
|
|
result = self.parse(*job)
|
|
|
|
|
|
|
|
try:
|
|
|
|
self.results.put(result, timeout=0.25)
|
|
|
|
except Queue.Full:
|
|
|
|
pending.append(result)
|
|
|
|
|
|
|
|
def parse(self, filename, appends, caches_array):
|
|
|
|
try:
|
2013-05-23 09:49:57 +00:00
|
|
|
# Reset our environment and handlers to the original settings
|
|
|
|
bb.utils.set_context(self.context.copy())
|
2013-05-23 09:50:30 +00:00
|
|
|
bb.event.set_class_handlers(self.handlers.copy())
|
2013-03-06 15:32:35 +00:00
|
|
|
return True, bb.cache.Cache.parse(filename, appends, self.cfg, caches_array)
|
|
|
|
except Exception as exc:
|
|
|
|
tb = sys.exc_info()[2]
|
|
|
|
exc.recipe = filename
|
|
|
|
exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3))
|
|
|
|
return True, exc
|
|
|
|
# Need to turn BaseExceptions into Exceptions here so we gracefully shutdown
|
|
|
|
# and for example a worker thread doesn't just exit on its own in response to
|
|
|
|
# a SystemExit event for example.
|
|
|
|
except BaseException as exc:
|
|
|
|
return True, ParsingFailure(exc, filename)
|
2010-12-07 18:00:22 +00:00
|
|
|
|
2010-11-19 03:21:54 +00:00
|
|
|
class CookerParser(object):
|
2010-01-20 18:46:02 +00:00
|
|
|
def __init__(self, cooker, filelist, masked):
|
|
|
|
self.filelist = filelist
|
|
|
|
self.cooker = cooker
|
2013-05-30 12:26:58 +00:00
|
|
|
self.cfgdata = cooker.data
|
|
|
|
self.cfghash = cooker.data_hash
|
2010-01-20 18:46:02 +00:00
|
|
|
|
|
|
|
# Accounting statistics
|
|
|
|
self.parsed = 0
|
|
|
|
self.cached = 0
|
|
|
|
self.error = 0
|
|
|
|
self.masked = masked
|
|
|
|
|
|
|
|
self.skipped = 0
|
|
|
|
self.virtuals = 0
|
2010-11-19 03:21:54 +00:00
|
|
|
self.total = len(filelist)
|
2010-01-20 18:46:02 +00:00
|
|
|
|
2010-11-19 03:21:54 +00:00
|
|
|
self.current = 0
|
2010-11-23 14:20:08 +00:00
|
|
|
self.num_processes = int(self.cfgdata.getVar("BB_NUMBER_PARSE_THREADS", True) or
|
|
|
|
multiprocessing.cpu_count())
|
2007-01-08 23:53:01 +00:00
|
|
|
|
2012-02-23 13:47:13 +00:00
|
|
|
self.bb_cache = bb.cache.Cache(self.cfgdata, self.cfghash, cooker.caches_array)
|
2010-11-19 03:21:54 +00:00
|
|
|
self.fromcache = []
|
2010-12-07 18:00:22 +00:00
|
|
|
self.willparse = []
|
2010-11-19 03:21:54 +00:00
|
|
|
for filename in self.filelist:
|
2013-05-10 14:35:39 +00:00
|
|
|
appends = self.cooker.collection.get_file_appends(filename)
|
2011-07-06 16:54:49 +00:00
|
|
|
if not self.bb_cache.cacheValid(filename, appends):
|
2011-06-03 00:21:44 +00:00
|
|
|
self.willparse.append((filename, appends, cooker.caches_array))
|
2010-11-19 03:21:54 +00:00
|
|
|
else:
|
|
|
|
self.fromcache.append((filename, appends))
|
2010-11-30 15:25:13 +00:00
|
|
|
self.toparse = self.total - len(self.fromcache)
|
2010-12-03 17:39:11 +00:00
|
|
|
self.progress_chunk = max(self.toparse / 100, 1)
|
2010-11-19 03:21:54 +00:00
|
|
|
|
2010-12-07 18:00:22 +00:00
|
|
|
self.start()
|
2012-03-11 14:13:05 +00:00
|
|
|
self.haveshutdown = False
|
2010-12-07 18:00:22 +00:00
|
|
|
|
|
|
|
def start(self):
|
2011-02-16 22:50:50 +00:00
|
|
|
self.results = self.load_cached()
|
2013-03-06 15:32:35 +00:00
|
|
|
self.processes = []
|
2011-02-16 22:50:50 +00:00
|
|
|
if self.toparse:
|
|
|
|
bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata)
|
2013-03-06 15:32:35 +00:00
|
|
|
def init():
|
|
|
|
Parser.cfg = self.cfgdata
|
|
|
|
multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cfgdata,), exitpriority=1)
|
|
|
|
multiprocessing.util.Finalize(None, bb.fetch.fetcher_parse_save, args=(self.cfgdata,), exitpriority=1)
|
|
|
|
|
|
|
|
self.feeder_quit = multiprocessing.Queue(maxsize=1)
|
|
|
|
self.parser_quit = multiprocessing.Queue(maxsize=self.num_processes)
|
|
|
|
self.jobs = multiprocessing.Queue(maxsize=self.num_processes)
|
|
|
|
self.result_queue = multiprocessing.Queue()
|
|
|
|
self.feeder = Feeder(self.willparse, self.jobs, self.feeder_quit)
|
|
|
|
self.feeder.start()
|
|
|
|
for i in range(0, self.num_processes):
|
2013-09-15 08:57:02 +00:00
|
|
|
parser = Parser(self.jobs, self.result_queue, self.parser_quit, init, self.cooker.configuration.profile)
|
2013-03-06 15:32:35 +00:00
|
|
|
parser.start()
|
|
|
|
self.processes.append(parser)
|
|
|
|
|
|
|
|
self.results = itertools.chain(self.results, self.parse_generator())
|
2012-01-09 18:31:32 +00:00
|
|
|
|
|
|
|
def shutdown(self, clean=True, force=False):
|
2011-02-16 22:50:50 +00:00
|
|
|
if not self.toparse:
|
|
|
|
return
|
2012-03-11 14:13:05 +00:00
|
|
|
if self.haveshutdown:
|
|
|
|
return
|
|
|
|
self.haveshutdown = True
|
2011-02-16 22:50:50 +00:00
|
|
|
|
2010-12-07 18:00:22 +00:00
|
|
|
if clean:
|
|
|
|
event = bb.event.ParseCompleted(self.cached, self.parsed,
|
|
|
|
self.skipped, self.masked,
|
|
|
|
self.virtuals, self.error,
|
|
|
|
self.total)
|
2012-07-23 16:26:06 +00:00
|
|
|
|
2010-12-07 18:00:22 +00:00
|
|
|
bb.event.fire(event, self.cfgdata)
|
2013-03-06 15:32:35 +00:00
|
|
|
self.feeder_quit.put(None)
|
|
|
|
for process in self.processes:
|
|
|
|
self.jobs.put(None)
|
2010-12-07 18:00:22 +00:00
|
|
|
else:
|
2013-03-06 15:32:35 +00:00
|
|
|
self.feeder_quit.put('cancel')
|
|
|
|
|
|
|
|
self.parser_quit.cancel_join_thread()
|
|
|
|
for process in self.processes:
|
|
|
|
self.parser_quit.put(None)
|
|
|
|
|
|
|
|
self.jobs.cancel_join_thread()
|
|
|
|
|
|
|
|
for process in self.processes:
|
|
|
|
if force:
|
|
|
|
process.join(.1)
|
|
|
|
process.terminate()
|
|
|
|
else:
|
|
|
|
process.join()
|
|
|
|
self.feeder.join()
|
2010-12-07 18:00:22 +00:00
|
|
|
|
2010-11-23 17:46:49 +00:00
|
|
|
sync = threading.Thread(target=self.bb_cache.sync)
|
|
|
|
sync.start()
|
2011-06-08 16:23:42 +00:00
|
|
|
multiprocessing.util.Finalize(None, sync.join, exitpriority=-100)
|
2013-05-30 12:26:58 +00:00
|
|
|
bb.codeparser.parser_cache_savemerge(self.cooker.data)
|
|
|
|
bb.fetch.fetcher_parse_done(self.cooker.data)
|
2010-12-07 18:00:22 +00:00
|
|
|
|
|
|
|
def load_cached(self):
|
|
|
|
for filename, appends in self.fromcache:
|
|
|
|
cached, infos = self.bb_cache.load(filename, appends, self.cfgdata)
|
|
|
|
yield not cached, infos
|
2010-11-19 03:21:54 +00:00
|
|
|
|
2013-03-06 15:32:35 +00:00
|
|
|
def parse_generator(self):
|
|
|
|
while True:
|
|
|
|
if self.parsed >= self.toparse:
|
|
|
|
break
|
|
|
|
|
|
|
|
try:
|
|
|
|
result = self.result_queue.get(timeout=0.25)
|
|
|
|
except Queue.Empty:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
value = result[1]
|
|
|
|
if isinstance(value, BaseException):
|
|
|
|
raise value
|
|
|
|
else:
|
|
|
|
yield result
|
|
|
|
|
2010-11-19 03:21:54 +00:00
|
|
|
def parse_next(self):
|
2012-05-30 16:17:15 +00:00
|
|
|
result = []
|
|
|
|
parsed = None
|
2010-12-07 18:00:22 +00:00
|
|
|
try:
|
|
|
|
parsed, result = self.results.next()
|
|
|
|
except StopIteration:
|
2010-11-19 03:21:54 +00:00
|
|
|
self.shutdown()
|
2010-01-20 18:46:02 +00:00
|
|
|
return False
|
2012-08-22 21:40:14 +00:00
|
|
|
except bb.BBHandledException as exc:
|
|
|
|
self.error += 1
|
|
|
|
logger.error('Failed to parse recipe: %s' % exc.recipe)
|
|
|
|
self.shutdown(clean=False)
|
|
|
|
return False
|
2011-05-05 23:50:34 +00:00
|
|
|
except ParsingFailure as exc:
|
2012-07-23 16:26:06 +00:00
|
|
|
self.error += 1
|
2012-02-23 17:38:07 +00:00
|
|
|
logger.error('Unable to parse %s: %s' %
|
2011-05-05 23:50:34 +00:00
|
|
|
(exc.recipe, bb.exceptions.to_string(exc.realexception)))
|
2012-02-23 17:38:07 +00:00
|
|
|
self.shutdown(clean=False)
|
2012-08-22 19:33:39 +00:00
|
|
|
return False
|
2012-05-30 16:17:16 +00:00
|
|
|
except bb.parse.ParseError as exc:
|
2012-07-23 16:26:06 +00:00
|
|
|
self.error += 1
|
2012-02-23 17:38:07 +00:00
|
|
|
logger.error(str(exc))
|
2012-01-31 17:47:07 +00:00
|
|
|
self.shutdown(clean=False)
|
2012-08-22 19:33:39 +00:00
|
|
|
return False
|
2012-05-30 16:17:16 +00:00
|
|
|
except bb.data_smart.ExpansionError as exc:
|
2012-07-23 16:26:06 +00:00
|
|
|
self.error += 1
|
2012-05-30 16:17:16 +00:00
|
|
|
_, value, _ = sys.exc_info()
|
|
|
|
logger.error('ExpansionError during parsing %s: %s', value.recipe, str(exc))
|
|
|
|
self.shutdown(clean=False)
|
2012-08-22 19:33:39 +00:00
|
|
|
return False
|
2011-05-06 14:15:34 +00:00
|
|
|
except SyntaxError as exc:
|
2012-07-23 16:26:06 +00:00
|
|
|
self.error += 1
|
2011-05-06 14:15:34 +00:00
|
|
|
logger.error('Unable to parse %s', exc.recipe)
|
2012-02-23 17:38:07 +00:00
|
|
|
self.shutdown(clean=False)
|
2012-08-22 19:33:39 +00:00
|
|
|
return False
|
2011-05-06 14:15:34 +00:00
|
|
|
except Exception as exc:
|
2012-07-23 16:26:06 +00:00
|
|
|
self.error += 1
|
2011-05-05 23:55:33 +00:00
|
|
|
etype, value, tb = sys.exc_info()
|
bitbake: cooker: fix handling of exceptions during exception handling
If an exception occurs during handling another exception we were
getting a useless traceback such as the following, after which
BitBake froze:
ERROR: Command execution failed: Traceback (most recent call last):
File "/home/user/poky/poky/bitbake/lib/bb/command.py", line 84, in runAsyncCommand
self.cooker.updateCache()
File "/home/user/poky/poky/bitbake/lib/bb/cooker.py", line 1207, in updateCache
if not self.parser.parse_next():
File "/home/user/poky/poky/bitbake/lib/bb/cooker.py", line 1694, in parse_next
logger.error('Unable to parse %s', value.recipe,
AttributeError: 'exceptions.TypeError' object has no attribute 'recipe'
Fix this to print an actual traceback of the exception and exit
gracefully (well, as gracefully as possible under the circumstances).
The general fix for [YOCTO #2977].
(Bitbake rev: 675b237a284dff84e972546774b69e2f89afb360)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-09-07 15:22:54 +00:00
|
|
|
if hasattr(value, "recipe"):
|
|
|
|
logger.error('Unable to parse %s', value.recipe,
|
|
|
|
exc_info=(etype, value, exc.traceback))
|
|
|
|
else:
|
|
|
|
# Most likely, an exception occurred during raising an exception
|
|
|
|
import traceback
|
|
|
|
logger.error('Exception during parse: %s' % traceback.format_exc())
|
2010-12-07 18:00:22 +00:00
|
|
|
self.shutdown(clean=False)
|
2012-08-22 19:33:39 +00:00
|
|
|
return False
|
2010-11-19 03:21:54 +00:00
|
|
|
|
|
|
|
self.current += 1
|
2010-12-07 18:00:22 +00:00
|
|
|
self.virtuals += len(result)
|
|
|
|
if parsed:
|
|
|
|
self.parsed += 1
|
|
|
|
if self.parsed % self.progress_chunk == 0:
|
2012-02-23 13:47:16 +00:00
|
|
|
bb.event.fire(bb.event.ParseProgress(self.parsed, self.toparse),
|
2010-12-07 18:00:22 +00:00
|
|
|
self.cfgdata)
|
|
|
|
else:
|
|
|
|
self.cached += 1
|
|
|
|
|
2011-06-03 00:22:40 +00:00
|
|
|
for virtualfn, info_array in result:
|
|
|
|
if info_array[0].skipped:
|
2010-12-07 18:00:22 +00:00
|
|
|
self.skipped += 1
|
2011-06-01 14:37:07 +00:00
|
|
|
self.cooker.skiplist[virtualfn] = SkippedPackage(info_array[0])
|
2013-05-13 18:53:26 +00:00
|
|
|
self.bb_cache.add_info(virtualfn, info_array, self.cooker.recipecache,
|
bitbake: cooker/cache/parse: Implement pyinofity based reconfigure
Memory resident bitbake has one current flaw, changes in the base configuration
are not noticed by bitbake. The parsing cache is also refreshed on each invocation
of bitbake (although the mtime cache is not cleared so its pointless).
This change adds in pyinotify support and adds two different watchers, one
for the base configuration and one for the parsed recipes.
Changes in the latter will trigger a reparse (and an update of the mtime cache).
The former will trigger a complete reload of the configuration.
Note that this code will also correctly handle creation of new configuration files
since the __depends and __base_depends variables already track these for cache
correctness purposes.
We could be a little more clever about parsing cache invalidation, right now we just
invalidate the whole thing and recheck. For now, its better than what we have and doesn't
seem to perform that badly though.
For education and QA purposes I can document a workflow that illustrates this:
$ source oe-init-build-env-memres
$ time bitbake bash
[base configuration is loaded, recipes are parsed, bash builds]
$ time bitbake bash
[command returns quickly since all caches are valid]
$ touch ../meta/classes/gettext.bbclass
$ time bitbake bash
[reparse is triggered, time is longer than above]
$ echo 'FOO = "1"' >> conf/local.conf
$ time bitbake bash
[reparse is triggered, but with a base configuration reload too]
As far as changes go, I like this one a lot, it makes memory resident bitbake
truly usable and may be the tweak we need to make it the default.
The new pyinotify dependency is covered in the previous commit.
(Bitbake rev: 0557d03c170fba8d7efe82be1b9641d0eb229213)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-13 14:13:53 +00:00
|
|
|
parsed=parsed, watcher = self.cooker.add_filewatch)
|
2010-01-20 18:46:02 +00:00
|
|
|
return True
|
2010-11-19 03:21:54 +00:00
|
|
|
|
2010-11-21 18:59:05 +00:00
|
|
|
def reparse(self, filename):
|
|
|
|
infos = self.bb_cache.parse(filename,
|
2013-05-10 14:35:39 +00:00
|
|
|
self.cooker.collection.get_file_appends(filename),
|
2011-06-03 00:21:44 +00:00
|
|
|
self.cfgdata, self.cooker.caches_array)
|
2011-06-03 00:22:40 +00:00
|
|
|
for vfn, info_array in infos:
|
2013-05-13 18:53:26 +00:00
|
|
|
self.cooker.recipecache.add_from_recipeinfo(vfn, info_array)
|