[yocto] [PATCH 4/8] yocto-bsp: add kernel interface
Darren Hart
dvhart at linux.intel.com
Fri Mar 2 09:11:25 PST 2012
On 03/01/2012 11:01 PM, tom.zanussi at intel.com wrote:
> From: Tom Zanussi <tom.zanussi at intel.com>
>
> Yocto BSP kernel-related functions, for interacting with the kernel
> tools and implementing the machinery behind the 'yocto-kernel'
> command.
>
> Signed-off-by: Tom Zanussi <tom.zanussi at intel.com>
> ---
> scripts/lib/bsp/kernel.py | 679 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 679 insertions(+), 0 deletions(-)
> create mode 100644 scripts/lib/bsp/kernel.py
>
> diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py
> new file mode 100644
> index 0000000..1b88b2f
> --- /dev/null
> +++ b/scripts/lib/bsp/kernel.py
> @@ -0,0 +1,679 @@
> +# ex:ts=4:sw=4:sts=4:et
> +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
> +#
> +# Copyright 2012 Intel Corporation
> +# Authored-by: Tom Zanussi <tom.zanussi at intel.com>
> +#
> +# 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.
> +
> +import sys
> +import os
> +import shutil
> +from tags import *
> +import glob
> +
> +
> +def find_bblayers(scripts_path):
> + """
> + Find and return a sanitized list of the layers found in BBLAYERS.
> + """
> + bblayers_conf = os.path.join(scripts_path, "../build/conf/bblayers.conf")
> +
> + layers = []
> +
> + f = open(bblayers_conf, "r")
> + lines = f.readlines()
> + for line in lines:
> + line = line.strip()
> + in_bblayers = False
> + if line.startswith("BBLAYERS"):
> + in_bblayers = True
> + if line.startswith("/"):
> + if line.endswith("\\"):
> + line = line[:-1].strip()
> + layers.append(line)
This does not appear to handle something like:
BBLAYERS = " \
/path/to/layer1 \
/path/to/layer2"
Need to strip the " from the end of the last line.
Also doesn't handle:
BBLAYERS += "/path/to/layer3"
As it looks for lines starting with / and doesn't handle the " as
mentioned above.
> + f.close()
> +
> + return layers
> +
> +
> +def find_meta_layer(scripts_path):
> + """
> + Find and return the meta layer in BBLAYERS.
> + """
> + layers = find_bblayers(scripts_path)
> +
> + for layer in layers:
> + if layer.endswith("meta"):
> + return layer
> +
> + return None
I wonder if you could just use the bitbake-layers show-layers command?
$ bitbake-layers show-layers
Parsing recipes..WARNING: No recipes available for:
/home/dvhart/source/poky/layers/poky-extras/meta-kernel-dev/recipes-kernel/linux/linux-yocto_2.6.34.bbappend
/home/dvhart/source/poky/layers/meta-intel/meta-fri2/recipes-kernel/linux/linux-yocto-tiny_3.2.bbappend
/home/dvhart/source/poky/layers/poky-extras/meta-kernel-dev/recipes-kernel/linux/linux-yocto-rt_2.6.34.bbappend
done.
layer path priority
==========================================================================
meta /home/dvhart/source/poky/meta 5
meta-yocto /home/dvhart/source/poky/meta-yocto 5
meta-intel /home/dvhart/source/poky/layers/meta-intel 5
meta-fri2
/home/dvhart/source/poky/layers/meta-intel/meta-fri2 5
meta-kernel-dev
/home/dvhart/source/poky/layers/poky-extras/meta-kernel-dev 0
It's slow as snot in January in Toronto, but it avoids having to
re-implement all the bblayers parsing and the various corner cases that
bitbake already handles...
> +
> +def find_bsp_layer(scripts_path, machine):
> + """
> + Find and return a machine's BSP layer in BBLAYERS.
> + """
> + layers = find_bblayers(scripts_path)
> +
> + for layer in layers:
> + if machine in layer:
> + return layer
> +
> + print "Unable to find the BSP layer for machine %s." % machine
> + print "Please make sure it is listed in bblayers.conf"
> + sys.exit(1)
You would probably need to cache the result of the bitbake-layers as it
is way to slow to use repeatedly like you need to here...
The rest looks good to me.
--
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
More information about the yocto
mailing list