All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: tom.zanussi@intel.com
Cc: yocto@yoctoproject.org
Subject: Re: [PATCH 4/8] yocto-bsp: add kernel interface
Date: Fri, 02 Mar 2012 09:11:25 -0800	[thread overview]
Message-ID: <4F50FF3D.7080802@linux.intel.com> (raw)
In-Reply-To: <a0c47b85cdeb6d65e1ab924db684cf1d80fb0dda.1330663414.git.tom.zanussi@intel.com>



On 03/01/2012 11:01 PM, tom.zanussi@intel.com wrote:
> From: Tom Zanussi <tom.zanussi@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@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@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


  reply	other threads:[~2012-03-02 17:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02  7:01 [PATCH 0/8] Yocto BSP tools tom.zanussi
2012-03-02  7:01 ` [PATCH 1/8] yocto-bsp: add BSP template files tom.zanussi
2012-03-02 16:35   ` Darren Hart
2012-03-02 17:19     ` Tom Zanussi
2012-03-02  7:01 ` [PATCH 2/8] yocto-bsp-tools: add bsp library tom.zanussi
2012-03-02 16:41   ` Darren Hart
2012-03-02  7:01 ` [PATCH 3/8] yocto-bsp: add templating engine tom.zanussi
2012-03-02 16:57   ` Darren Hart
2012-03-02 17:22     ` Tom Zanussi
2012-03-02  7:01 ` [PATCH 4/8] yocto-bsp: add kernel interface tom.zanussi
2012-03-02 17:11   ` Darren Hart [this message]
2012-03-02 17:34     ` Tom Zanussi
2012-03-02  7:01 ` [PATCH 5/8] yocto-bsp-tools: add help/usage tom.zanussi
2012-03-02 17:17   ` Darren Hart
2012-03-02  7:01 ` [PATCH 6/8] yocto-bsp: add some useful constants tom.zanussi
2012-03-02 17:18   ` Darren Hart
2012-03-02  7:01 ` [PATCH 7/8] yocto-bsp: new script tom.zanussi
2012-03-02 17:20   ` Darren Hart
2012-03-02  7:01 ` [PATCH 8/8] yocto-kernel: " tom.zanussi
2012-03-02 17:23   ` Darren Hart
2012-03-02 17:27     ` Tom Zanussi
2012-03-02 16:24 ` [PATCH 0/8] Yocto BSP tools Darren Hart
2012-03-02 17:02   ` Tom Zanussi
2012-03-02 17:15     ` Darren Hart
  -- strict thread matches above, loose matches on Subject: below --
2012-03-17  5:30 [PATCH 1/8] yocto-bsp: add BSP template files tom.zanussi
2012-03-17  5:30 ` [PATCH 0/8] Yocto BSP tools, version 2 tom.zanussi
2012-03-17  5:30   ` [PATCH 4/8] yocto-bsp: add kernel interface tom.zanussi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F50FF3D.7080802@linux.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=tom.zanussi@intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.