Skip to contentSkip to conversation

RFC: new 'yocto-layer' tool for creating generic Yocto layers

PATCH In review [email protected] 4 participants 21 messages Dec 17, 2012 – Jan 2, 2013

lore
Share & tools
lore
#0 lore raw

cover RFC: new 'yocto-layer' tool for creating generic Yocto layers

From: Tom Zanussi <[email protected]>

Since I've been doing kind of similar work lately for the 'custom kernel' support for yocto-bsp and have gotten several requests lately (mainly from Darren in support of the new kernel documentation) for something like this, I decided to just go ahead and try to quickly implement a general-purpose layer-generation tool based on the BSP-generation code used in the yocto-bsp tool.

There's actually an enhancement request bug for this already in the Yocto bugzilla, but it doesn't contain many details:

Bug 3094 - Add a layer generation tool:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=3094

So anyway, this is my initial take on what that bug means. It's an RFC for a couple reasons, first that I'd like to get comments on whether this is actually what's needed for a 'layer generation tool', and second, because I still need to do some cleanup of the refactored code, but don't want to waste much time on it if it's not really what's needed.

Below are a couple examples of how it's used - you really have to try it yourself to see what's generated - I don't want to post tarballs or such on the list and it's simple to generate and look at the layers.

The first case is just a very simple layer with a layer.conf and README - basically the simplest layer you can create, and which exists mainly because even that is easy to get wrong. As with the yocto-bsp tool, the script queries the user for a couple items, here we just take the defaults, which are a priority of 6 for the layer and no other components such as example recipes:

[trz@empanada build]$ yocto-layer create simplestlayer
Please enter the layer priority you'd like to use for the layer: [default: 6] Would you like to have an example recipe created? (y/n) [default: n] Would you like to have an example bbappend file created? (y/n) [default: n]

New layer created in meta-simplestlayer.

Don't forget to add it to your BBLAYERS (for details see meta-simplestlayer\README).

[trz@empanada build]$ find .
.
./meta-simplestlayer
./meta-simplestlayer/conf
./meta-simplestlayer/conf/layer.conf
./meta-simplestlayer/README
./meta-simplestlayer/COPYING.MIT

In the second case, we tell the tool that we do want an example .bb and and an example .bbappend. We're queried for the recipe name that we want our recipe to have, and for the .bbappend, the name of the base recipe and its version. Below you can see the files it generates - please look at the files themselves to see the contents. For the recipe example, it generates a recipe based on the example in the Yocto manual, and my own helloworld.c code (untested so far which is also why this is an RFC). For the .bbappend example, it just creates an empty .patch file with some instructions on what to do to modify the parent recipe with a patch:

[trz@empanada build]$ yocto-layer create mylayer
Please enter the layer priority you'd like to use for the layer: [default: 6]
Would you like to have an example recipe created? (y/n) [default: n] y
Please enter the name you'd like to use for your example recipe: [default: example] flork
Would you like to have an example bbappend file created? (y/n) [default: n] y
Please enter the name you'd like to use for your bbappend file: [default: example] chork
Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1] 0.22.3

New layer created in meta-mylayer.

Don't forget to add it to your BBLAYERS (for details see meta-mylayer\README).

[trz@empanada build]$ find .
.
./meta-mylayer
./meta-mylayer/recipes-example
./meta-mylayer/recipes-example/example ./meta-mylayer/recipes-example/example/flork-0.1 ./meta-mylayer/recipes-example/example/flork-0.1/helloworld.c ./meta-mylayer/recipes-example/example/flork-0.1/example.patch ./meta-mylayer/recipes-example/example/flork_0.1.bb ./meta-mylayer/conf
./meta-mylayer/conf/layer.conf
./meta-mylayer/recipes-example-bbappend ./meta-mylayer/recipes-example-bbappend/example-bbappend ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork-0.22.3 ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork-0.22.3/example.patch ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork_0.22.3.bbappend ./meta-mylayer/README
./meta-mylayer/COPYING.MIT

Please try it and look at the generated code - any comments or suggestions are welcome.

Thanks,

Tom

The following changes since commit da598d4f0fcf6faa62055084a51d70d735399d33:

eglibc: fix checksums of fetched patches (2012-12-13 18:02:21 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/yocto-layer-rfc
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/yocto-layer-rfc

Tom Zanussi (5):
scripts/lib/bsp/engine.py: add yocto_layer_create()
yocto-layer: new script
yocto-layer: add help/usage
yocto-layer: add 'layer' template data scripts/lib/bsp/engine.py: refactor bsp-creation code

 scripts/lib/bsp/engine.py                          |  86 +++++++-
 scripts/lib/bsp/help.py                            | 228 +++++++++++++++++++++
 .../bsp/substrate/target/arch/layer/COPYING.MIT    |  17 ++
 scripts/lib/bsp/substrate/target/arch/layer/README |  64 ++++++
 .../substrate/target/arch/layer/conf/layer.conf    |  10 +
 .../target/arch/layer/layer-questions.noinstall    |  14 ++
 .../example.patch"                                 |  12 ++
 ..._name}}_{{=example_bbappend_version}}.bbappend" |   8 +
 .../{{=example_recipe_name}}-0.1/example.patch"    |  12 ++
 .../{{=example_recipe_name}}-0.1/helloworld.c"     |   6 +
 .../example/{{=example_recipe_name}}_0.1.bb"       |  23 +++
 scripts/yocto-layer                                | 142 +++++++++++++
 12 files changed, 612 insertions(+), 10 deletions(-)
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/README
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}-{{=example_bbappend_version}}/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"
 create mode 100755 scripts/yocto-layer
Signature · 1 line
1.7.11.4
#1 lore raw

PATCH 1/5 scripts/lib/bsp/engine.py: add yocto_layer_create()

From: Tom Zanussi <[email protected]>

Add a new yocto_layer_create() function that will be used to generate a generic yocto layer (for the new 'yocto-layer' command).

---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
scripts/lib/bsp/engine.py +56 -0
index 8985544..d406e79 100644
@@ -1352,6 +1352,62 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    if os.path.exists(bsp_output_dir):
+        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+        sys.exit(1)
+
+    properties = None
+
+    if properties_file:
+        try:
+            infile = open(properties_file, "r")
+        except IOError:
+            print "Couldn't open properties file %s for reading, exiting" % properties_file
+            sys.exit(1)
+
+        properties = json.load(infile)
+
+    os.mkdir(bsp_output_dir)
+
+    context = create_context(machine, arch, scripts_path)
+    target_files = expand_targets(context, bsp_output_dir)
+
+    input_lines = gather_inputlines(target_files)
+
+    program_lines = []
+
+    gen_program_header_lines(program_lines)
+
+    gen_initial_property_vals(input_lines, program_lines)
+
+    if properties:
+        gen_supplied_property_vals(properties, program_lines)
+
+    gen_program_machine_lines(machine, program_lines)
+
+    if not properties:
+        gen_program_input_lines(input_lines, program_lines, context)
+
+    gen_program_lines(target_files, program_lines)
+
+    run_program_lines(program_lines, codedump)
+
+    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
     """
     Create bsp
Signature · 1 line
1.7.11.4
#2 lore raw

PATCH 2/5 yocto-layer: new script

From: Tom Zanussi <[email protected]>

Implementation of the 'yocto-layer' command-line tool, for creating generic layers and listing their input properties.

---
 scripts/yocto-layer | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100755 scripts/yocto-layer
scripts/yocto-layer new file +142 -0
new file mode 100755
index 0000000..f759275
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# Copyright (c) 2012, Intel Corporation.
+# All rights reserved.
+#
+# 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.
+#
+# DESCRIPTION
+# 'yocto-layer' is the Yocto Tool that helps users create a new Yocto
+# layer.  Invoking it without any arguments will display help screens
+# for the 'yocto-layer' command and list the available 'yocto-layer'
+# subcommands.  Invoking a subcommand without any arguments will
+# likewise display help screens for the specified subcommand.  Please
+# use that interface for detailed help.
+#
+# AUTHORS
+# Tom Zanussi <tom.zanussi (at] intel.com>
+#
+
+__version__ = "0.1.0"
+
+import os
+import sys
+import optparse
+import logging
+
+scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
+lib_path = scripts_path + '/lib'
+sys.path = sys.path + [lib_path]
+
+from bsp.help import *
+from bsp.engine import *
+
+
+def yocto_layer_create_subcommand(args, usage_str):
+    """
+    Command-line handling for layer creation.  The real work is done by
+    bsp.engine.yocto_layer_create()
+    """
+    parser = optparse.OptionParser(usage = usage_str)
+
+    parser.add_option("-o", "--outdir", dest = "outdir", action = "store",
+                      help = "name of layer dir to create")
+    parser.add_option("-i", "--infile", dest = "properties_file", action = "store",
+                      help = "name of file containing the values for layer input properties as a JSON file")
+    parser.add_option("-c", "--codedump", dest = "codedump", action = "store_true",
+                      default = False, help = "dump the generated code to layergen.out")
+    (options, args) = parser.parse_args(args)
+
+    if len(args) != 1:
+        logging.error("Wrong number of arguments, exiting\n")
+        parser.print_help()
+        sys.exit(1)
+
+    layer_name = args[0]
+
+    if options.outdir:
+        layer_output_dir = options.outdir
+    else:
+        layer_output_dir = "meta-" + layer_name
+
+    yocto_layer_create(layer_name, scripts_path, layer_output_dir, options.codedump, options.properties_file)
+
+
+def yocto_layer_list_subcommand(args, usage_str):
+    """
+    Command-line handling for listing available layer properties and
+    values.  The real work is done by bsp.engine.yocto_layer_list()
+    """
+    parser = optparse.OptionParser(usage = usage_str)
+
+    parser.add_option("-o", "--outfile", action = "store", dest = "properties_file",
+                      help = "dump the possible values for layer properties to a JSON file")
+
+    (options, args) = parser.parse_args(args)
+
+    if not yocto_layer_list(args, scripts_path, options.properties_file):
+        logging.error("Bad list arguments, exiting\n")
+        parser.print_help()
+        sys.exit(1)
+
+
+subcommands = {
+    "create": [yocto_layer_create_subcommand,
+               yocto_layer_create_usage,
+               yocto_layer_create_help],
+    "list":   [yocto_layer_list_subcommand,
+               yocto_layer_list_usage,
+               yocto_layer_list_help],
+}
+
+
+def start_logging(loglevel):
+    logging.basicConfig(filname = 'yocto-layer.log', filemode = 'w', level=loglevel)
+
+
+def main():
+    parser = optparse.OptionParser(version = "yocto-layer version %s" % __version__,
+                                   usage = yocto_layer_usage)
+
+    parser.disable_interspersed_args()
+    parser.add_option("-D", "--debug", dest = "debug", action = "store_true",
+                      default = False, help = "output debug information")
+
+    (options, args) = parser.parse_args()
+
+    loglevel = logging.INFO
+    if options.debug:
+        loglevel = logging.DEBUG
+    start_logging(loglevel)
+
+    if len(args):
+        if args[0] == "help":
+            if len(args) == 1:
+                parser.print_help()
+                sys.exit(1)
+
+    invoke_subcommand(args, parser, yocto_layer_help_usage, subcommands)
+
+
+if __name__ == "__main__":
+    try:
+        ret = main()
+    except Exception:
+        ret = 1
+        import traceback
+        traceback.print_exc(5)
+    sys.exit(ret)
+
Signature · 1 line
1.7.11.4
#3 lore raw

Re: [PATCH 2/5] yocto-layer: new script

Quoted 4 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Implementation of the 'yocto-layer' command-line tool, for creating generic layers and listing their input properties.

No specific comments below, looks good.

Would the final version also include a removal of similar code from yocto-bsp, such that yocto-bsp would call yocto-layer? I'm thinking about reducing code duplication. I guess not as this is mostly just argument parsing and all the logic is already abstracted into bsp.engine?

Thanks,

Darren

Quoted 156 lines
---
 scripts/yocto-layer | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100755 scripts/yocto-layer
scripts/yocto-layer new file +142 -0
new file mode 100755
index 0000000..f759275
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# Copyright (c) 2012, Intel Corporation.
+# All rights reserved.
+#
+# 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.
+#
+# DESCRIPTION
+# 'yocto-layer' is the Yocto Tool that helps users create a new Yocto
+# layer.  Invoking it without any arguments will display help screens
+# for the 'yocto-layer' command and list the available 'yocto-layer'
+# subcommands.  Invoking a subcommand without any arguments will
+# likewise display help screens for the specified subcommand.  Please
+# use that interface for detailed help.
+#
+# AUTHORS
+# Tom Zanussi <tom.zanussi (at] intel.com>
+#
+
+__version__ = "0.1.0"
+
+import os
+import sys
+import optparse
+import logging
+
+scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
+lib_path = scripts_path + '/lib'
+sys.path = sys.path + [lib_path]
+
+from bsp.help import *
+from bsp.engine import *
+
+
+def yocto_layer_create_subcommand(args, usage_str):
+    """
+    Command-line handling for layer creation.  The real work is done by
+    bsp.engine.yocto_layer_create()
+    """
+    parser = optparse.OptionParser(usage = usage_str)
+
+    parser.add_option("-o", "--outdir", dest = "outdir", action = "store",
+                      help = "name of layer dir to create")
+    parser.add_option("-i", "--infile", dest = "properties_file", action = "store",
+                      help = "name of file containing the values for layer input properties as a JSON file")
+    parser.add_option("-c", "--codedump", dest = "codedump", action = "store_true",
+                      default = False, help = "dump the generated code to layergen.out")
+    (options, args) = parser.parse_args(args)
+
+    if len(args) != 1:
+        logging.error("Wrong number of arguments, exiting\n")
+        parser.print_help()
+        sys.exit(1)
+
+    layer_name = args[0]
+
+    if options.outdir:
+        layer_output_dir = options.outdir
+    else:
+        layer_output_dir = "meta-" + layer_name
+
+    yocto_layer_create(layer_name, scripts_path, layer_output_dir, options.codedump, options.properties_file)
+
+
+def yocto_layer_list_subcommand(args, usage_str):
+    """
+    Command-line handling for listing available layer properties and
+    values.  The real work is done by bsp.engine.yocto_layer_list()
+    """
+    parser = optparse.OptionParser(usage = usage_str)
+
+    parser.add_option("-o", "--outfile", action = "store", dest = "properties_file",
+                      help = "dump the possible values for layer properties to a JSON file")
+
+    (options, args) = parser.parse_args(args)
+
+    if not yocto_layer_list(args, scripts_path, options.properties_file):
+        logging.error("Bad list arguments, exiting\n")
+        parser.print_help()
+        sys.exit(1)
+
+
+subcommands = {
+    "create": [yocto_layer_create_subcommand,
+               yocto_layer_create_usage,
+               yocto_layer_create_help],
+    "list":   [yocto_layer_list_subcommand,
+               yocto_layer_list_usage,
+               yocto_layer_list_help],
+}
+
+
+def start_logging(loglevel):
+    logging.basicConfig(filname = 'yocto-layer.log', filemode = 'w', level=loglevel)
+
+
+def main():
+    parser = optparse.OptionParser(version = "yocto-layer version %s" % __version__,
+                                   usage = yocto_layer_usage)
+
+    parser.disable_interspersed_args()
+    parser.add_option("-D", "--debug", dest = "debug", action = "store_true",
+                      default = False, help = "output debug information")
+
+    (options, args) = parser.parse_args()
+
+    loglevel = logging.INFO
+    if options.debug:
+        loglevel = logging.DEBUG
+    start_logging(loglevel)
+
+    if len(args):
+        if args[0] == "help":
+            if len(args) == 1:
+                parser.print_help()
+                sys.exit(1)
+
+    invoke_subcommand(args, parser, yocto_layer_help_usage, subcommands)
+
+
+if __name__ == "__main__":
+    try:
+        ret = main()
+    except Exception:
+        ret = 1
+        import traceback
+        traceback.print_exc(5)
+    sys.exit(ret)
+
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#4 lore raw

PATCH 3/5 yocto-layer: add help/usage

In reply to [email protected]

From: Tom Zanussi <[email protected]>

This is essentially 'the documentation' for the yocto-layer tool.

---
 scripts/lib/bsp/help.py | 228 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 228 insertions(+)
scripts/lib/bsp/help.py +228 -0
index 3a1f52c..eac172a 100644
@@ -595,6 +595,234 @@ DESCRIPTION
 """
 
 ##
+# yocto-layer help and usage strings
+##
+
+yocto_layer_usage = """
+
+ Create a generic Yocto layer.
+
+ usage: yocto-layer [--version] [--help] COMMAND [ARGS]
+
+ Current 'yocto-layer' commands are:
+    create            Create a new generic Yocto layer
+    list              List available values for input options and properties
+
+ See 'yocto-layer help COMMAND' for more information on a specific command.
+"""
+
+yocto_layer_help_usage = """
+
+ usage: yocto-layer help <subcommand>
+
+ This command displays detailed help for the specified subcommand.
+"""
+
+yocto_layer_create_usage = """
+
+ Create a new generic Yocto layer
+
+ usage: yocto-layer create <layer-name> [-o <DIRNAME> | --outdir <DIRNAME>]
+            [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
+
+ This command creates a generic Yocto layer based on the specified
+ parameters.  The new layer will be a new Yocto layer contained by
+ default within the top-level directory specified as
+ 'meta-layer-name'.  The -o option can be used to place the layer in a
+ directory with a different name and location.
+
+ NOTE: Once created, you should add your new layer to your
+ bblayers.conf file in order for it to be subsequently seen and
+ modified by the yocto-kernel tool.  Instructions for doing this can
+ be found in the README file generated in the layer's top-level
+ directory.
+
+ See 'yocto layer help create' for more detailed instructions.
+"""
+
+yocto_layer_create_help = """
+
+NAME
+    yocto-layer create - Create a new generic Yocto layer
+
+SYNOPSIS
+    yocto-layer create <layer-name> [-o <DIRNAME> | --outdir <DIRNAME>]
+        [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
+
+DESCRIPTION
+    This command creates a generic Yocto layer based on the specified
+    parameters.  The new layer will be a new Yocto layer contained by
+    default within the top-level directory specified as
+    'meta-layer-name'.  The -o option can be used to place the layer
+    in a directory with a different name and location.
+
+    The layer-specific properties that define the values that will be
+    used to generate the layer can be specified on the command-line
+    using the -i option and supplying a JSON object consisting of the
+    set of name:value pairs needed by the layer.
+
+    If the -i option is not used, the user will be interactively
+    prompted for each of the required property values, which will then
+    be used as values for layer generation.
+
+    The set of properties available can be listed using the
+    'yocto-layer list' command.
+
+    Specifying -c causes the Python code generated and executed to
+    create the layer to be dumped to the 'bspgen.out' file in the
+    current directory, and is useful for debugging.
+
+    NOTE: Once created, you should add your new layer to your
+    bblayers.conf file in order for it to be subsequently seen and
+    modified by the yocto-kernel tool.  Instructions for doing this
+    can be found in the README file generated in the layer's top-level
+    directory.
+
+    For example, assuming your poky repo is at /path/to/poky, your new
+    layer is at /path/to/poky/meta-mylayer, and your build directory
+    is /path/to/build:
+
+    $ gedit /path/to/build/conf/bblayers.conf
+
+    BBLAYERS ?= " \\
+      /path/to/poky/meta \\
+      /path/to/poky/meta-yocto \\
+      /path/to/poky/meta-mylayer \\
+      "
+"""
+
+yocto_layer_list_usage = """
+
+ usage: yocto-layer list properties
+                [-o <JSON PROPERTY FILE> | --outfile <JSON PROPERTY_FILE>]
+        yocto-layer list property <xxx>
+                [-o <JSON PROPERTY FILE> | --outfile <JSON PROPERTY_FILE>]
+
+ This command enumerates the complete set of possible values for a
+ specified option or property needed by the layer creation process.
+
+ The first form enumerates all the possible properties that exist and
+ must have values specified for them in the 'yocto-layer create'
+ command.
+
+ The second form enumerates all the possible values that exist and can
+ be specified for any of the enumerable properties in the 'yocto-layer
+ create' command.
+
+ See 'yocto-layer help list' for more details.
+"""
+
+yocto_layer_list_help = """
+
+NAME
+    yocto-layer list - List available values for layer input options and properties
+
+SYNOPSIS
+    yocto-layer list properties
+            [--o <JSON PROPERTY FILE> | -outfile <JSON PROPERTY_FILE>]
+    yocto-layer list property <xxx>
+            [--o <JSON PROPERTY FILE> | -outfile <JSON PROPERTY_FILE>]
+
+DESCRIPTION
+    This command enumerates the complete set of possible values for a
+    specified option or property needed by the layer creation process.
+
+    The first form enumerates all the possible properties that exist
+    and must have values specified for them in the 'yocto-layer
+    create' command.  This command is mainly meant to aid the
+    development of user interface alternatives to the default
+    text-based prompting interface.  If the -o option is specified,
+    the list of properties, in addition to being displayed, will be
+    written to the specified file as a JSON object.  In this case, the
+    object will consist of the set of name:value pairs corresponding
+    to the (possibly nested) dictionary of properties defined by the
+    input statements used by the BSP.  Some example output for the
+    'list properties' command:
+
+    $ yocto-layer list properties
+    "example_bbappend_name" : {
+        "default" : example
+        "msg" : Please enter the name you'd like to use for your bbappend file:
+        "type" : edit
+        "prio" : 20
+        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
+    }
+    "create_example_recipe" : {
+        "default" : n
+        "msg" : Would you like to have an example recipe created? (y/n)
+        "type" : boolean
+        "prio" : 20
+        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
+    }
+    "example_recipe_name" : {
+        "default" : example
+        "msg" : Please enter the name you'd like to use for your example recipe:
+        "type" : edit
+        "prio" : 20
+        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
+    }
+    "layer_priority" : {
+        "default" : 6
+        "msg" : Please enter the layer priority you'd like to use for the layer:
+        "type" : edit
+        "prio" : 20
+        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
+    }
+    "create_example_bbappend" : {
+        "default" : n
+        "msg" : Would you like to have an example bbappend file created? (y/n)
+        "type" : boolean
+        "prio" : 20
+        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
+    }
+    "example_bbappend_version" : {
+        "default" : 0.1
+        "msg" : Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to):
+        "type" : edit
+        "prio" : 20
+        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
+    }
+
+    Each entry in the output consists of the name of the input element
+    e.g. "layer_priority", followed by the properties defined for that
+    element enclosed in braces.  This information should provide
+    sufficient information to create a complete user interface.  Two
+    features of the scheme provide for conditional input.  First, if a
+    Python "if" statement appears in place of an input element name,
+    the set of enclosed input elements apply and should be presented
+    to the user only if the 'if' statement evaluates to true.  The
+    test in the if statement will always reference another input
+    element in the list, which means that the element being tested
+    should be presented to the user before the elements enclosed by
+    the if block.  Secondly, in a similar way, some elements contain
+    "depends-on" and depends-on-val" tags, which mean that the
+    affected input element should only be presented to the user if the
+    element it depends on has already been presented to the user and
+    the user has selected the specified value for that element.
+
+    The second form enumerates all the possible values that exist and
+    can be specified for any of the enumerable properties in the
+    'yocto-layer create' command.  If the -o option is specified, the
+    list of values for the given property, in addition to being
+    displayed, will be written to the specified file as a JSON object.
+    In this case, the object will consist of the set of name:value
+    pairs corresponding to the array of property values associated
+    with the property.
+
+    $ yocto-layer list property layer_priority
+     [no output - layer_priority is a text field that has no enumerable values]
+
+    The second form as well is meant mainly for developers of
+    alternative interfaces - it allows the developer to fetch the
+    possible values for a given input element on-demand.  This
+    on-demand capability is especially valuable for elements that
+    require relatively expensive remote operations to fulfill, such as
+    the example that returns the set of branches available in a remote
+    git tree above.
+
+"""
+
+##
 # test code
 ##
 
Signature · 1 line
1.7.11.4
#5 lore raw

PATCH 4/5 yocto-layer: add 'layer' template data

In reply to [email protected]

From: Tom Zanussi <[email protected]>

Add a 'layer' target containing all the data that will be used to generate a generic yocto layer.

---
 .../bsp/substrate/target/arch/layer/COPYING.MIT    | 17 ++++++
 scripts/lib/bsp/substrate/target/arch/layer/README | 64 ++++++++++++++++++++++
 .../substrate/target/arch/layer/conf/layer.conf    | 10 ++++
 .../target/arch/layer/layer-questions.noinstall    | 14 +++++
 .../example.patch"                                 | 12 ++++
 ..._name}}_{{=example_bbappend_version}}.bbappend" |  8 +++
 .../{{=example_recipe_name}}-0.1/example.patch"    | 12 ++++
 .../{{=example_recipe_name}}-0.1/helloworld.c"     |  6 ++
 .../example/{{=example_recipe_name}}_0.1.bb"       | 23 ++++++++
 9 files changed, 166 insertions(+)
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/README
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}-{{=example_bbappend_version}}/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"
scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT new file +17 -0
new file mode 100644
index 0000000..89de354
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
scripts/lib/bsp/substrate/target/arch/layer/README new file +64 -0

64 lines not on this page · raw message

scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf new file +10 -0
new file mode 100644
index 0000000..84a9abb
@@ -0,0 +1,10 @@
+# We have a conf and classes directory, add to BBPATH
+BBPATH := "${BBPATH}:${LAYERDIR}"
+
+# We have a recipes directory, add to BBFILES
+BBFILES := "${BBFILES} ${LAYERDIR}/recipes-*/*/*.bb \
+	${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "{{=layer_name}}"
+BBFILE_PATTERN_{{=layer_name}} := "^${LAYERDIR}/"
+BBFILE_PRIORITY_{{=layer_name}} = "{{=layer_priority}}"
scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall new file +14 -0
new file mode 100644
index 0000000..e2a89c3
@@ -0,0 +1,14 @@
+{{ input type:"edit" name:"layer_priority" prio:"20" msg:"Please enter the layer priority you'd like to use for the layer:" default:"6"}}
+
+{{ input type:"boolean" name:"create_example_recipe" prio:"20" msg:"Would you like to have an example recipe created? (y/n)" default:"n"}}
+
+{{ if create_example_recipe == "y": }}
+{{ input type:"edit" name:"example_recipe_name" prio:"20" msg:"Please enter the name you'd like to use for your example recipe:" default:"example"}}
+
+{{ input type:"boolean" name:"create_example_bbappend" prio:"20" msg:"Would you like to have an example bbappend file created? (y/n)" default:"n"}}
+
+{{ if create_example_bbappend == "y": }}
+{{ input type:"edit" name:"example_bbappend_name" prio:"20" msg:"Please enter the name you'd like to use for your bbappend file:" default:"example"}}
+
+{{ if create_example_bbappend == "y": }}
+{{ input type:"edit" name:"example_bbappend_version" prio:"20" msg:"Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to):" default:"0.1"}}
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}-{{=example_bbappend_version}}/example.patch new file +12 -0
new file mode 100644
index 0000000..2000a34
@@ -0,0 +1,12 @@
+#
+# This is a non-functional placeholder file, here for example purposes
+# only.
+#
+# If you had a patch for your recipe, you'd put it in this directory
+# and reference it from your recipe's SRC_URI:
+#
+#  SRC_URI += "file://example.patch"
+#
+# Note that you could also rename the directory containing this patch
+# to remove the version number or simply rename it 'files'.  Doing so
+# allows you to use the same directory for multiple recipes.
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend new file +8 -0
new file mode 100644
index 0000000..2e50ff6
@@ -0,0 +1,8 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
+
+#
+# This .bbappend doesn't yet do anything - replace this text with
+# modifications to the example_0.1.bb recipe, or whatever recipe it is
+# that you want to modify with this .bbappend (make sure you change
+# the recipe name (PN) and version (PV) to match).
+#
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch new file +12 -0
new file mode 100644
index 0000000..2000a34
@@ -0,0 +1,12 @@
+#
+# This is a non-functional placeholder file, here for example purposes
+# only.
+#
+# If you had a patch for your recipe, you'd put it in this directory
+# and reference it from your recipe's SRC_URI:
+#
+#  SRC_URI += "file://example.patch"
+#
+# Note that you could also rename the directory containing this patch
+# to remove the version number or simply rename it 'files'.  Doing so
+# allows you to use the same directory for multiple recipes.
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +6 -0
new file mode 100644
index 0000000..90ce90e
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");
+}
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb new file +23 -0
new file mode 100644
index 0000000..14bf344
@@ -0,0 +1,23 @@
+#
+# This file was derived from the 'Hello World!' example recipe in the
+# Yocto Project Development Manual.
+#
+
+DESCRIPTION = "Simple helloworld application"
+SECTION = "examples"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+PR = "r0"
+
+SRC_URI = "file://helloworld.c"
+
+S = "${WORKDIR}"
+
+do_compile() {
+	     ${CC} helloworld.c -o helloworld
+}
+
+do_install() {
+	     install -d ${D}${bindir}
+	     install -m 0755 helloworld ${D}${bindir}
+}
Signature · 1 line
1.7.11.4
#6 lore raw

Re: [PATCH 4/5] yocto-layer: add 'layer' template data

Quoted 7 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a 'layer' target containing all the data that will be used to generate a generic yocto layer.

---

Great stuff Tom, only one nit below:

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 5

Quoted 10 lines

new file mode 100644
index 0000000..90ce90e

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +5 -0
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");

If you specify a return type of int, you should be returning one:

	return 0;

:-)

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 6

Quoted 1 line
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +1 -0
+}

Looks good otherwise.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#7 lore raw

Re: [PATCH 4/5] yocto-layer: add 'layer' template data

Quoted 25 lines · Darren Hart
Quoted 7 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a 'layer' target containing all the data that will be used to generate a generic yocto layer.

---

Great stuff Tom, only one nit below:

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 5

Quoted 10 lines

new file mode 100644
index 0000000..90ce90e

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +5 -0
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");

If you specify a return type of int, you should be returning one:

Quoted 4 lines
	return 0;

:-)

Hmm, I don't think that's actually necessary for main() - if you don't specify a return value for main(), it should already implicitly return 0 IIRC...

Tom

Quoted 6 lines

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 6

Quoted 1 line
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +1 -0
+}

Looks good otherwise.

#8 lore raw

Re: [PATCH 4/5] yocto-layer: add 'layer' template data

Quoted 26 lines · Tom Zanussi
Quoted 25 lines · Darren Hart
Quoted 7 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a 'layer' target containing all the data that will be used to generate a generic yocto layer.

---

Great stuff Tom, only one nit below:

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 5

Quoted 10 lines

new file mode 100644
index 0000000..90ce90e

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +5 -0
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");

If you specify a return type of int, you should be returning one:

Quoted 8 lines
Quoted 4 lines
	return 0;

:-)

Hmm, I don't think that's actually necessary for main() - if you don't specify a return value for main(), it should already implicitly return 0 IIRC...

Not true - that would be compiler specific and should not be relied on. Always best to be explicit (plus it will eliminate a GCC warning!)

Quoted 7 lines

Tom

Quoted 4 lines

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 6

Quoted 1 line
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +1 -0
+}

Looks good otherwise.

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#9 lore raw

Re: [PATCH 4/5] yocto-layer: add 'layer' template data

Quoted 32 lines · Gary Thomas
Quoted 31 lines · Tom Zanussi
Quoted 29 lines · Darren Hart
Quoted 7 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a 'layer' target containing all the data that will be used to generate a generic yocto layer.

---

Great stuff Tom, only one nit below:

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 5

Quoted 10 lines

new file mode 100644
index 0000000..90ce90e

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +5 -0
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");

If you specify a return type of int, you should be returning one:

	return 0;

:-)

Quoted 7 lines
Quoted 3 lines

Hmm, I don't think that's actually necessary for main() - if you don't specify a return value for main(), it should already implicitly return 0 IIRC...

Not true - that would be compiler specific and should not be relied on. Always best to be explicit (plus it will eliminate a GCC warning!)

Yeah, true, and definitely can't hurt in any case.

Tom

Quoted 8 lines
Quoted 7 lines

Tom

Quoted 4 lines

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 6

Quoted 1 line
scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +1 -0
+}

Looks good otherwise.

#10 lore raw

Re: [PATCH 4/5] yocto-layer: add 'layer' template data

In reply to Tom Zanussi
Quoted 26 lines · Tom Zanussi
Quoted 25 lines · Darren Hart
Quoted 7 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a 'layer' target containing all the data that will be used to generate a generic yocto layer.

---

Great stuff Tom, only one nit below:

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c line 5

Quoted 10 lines

new file mode 100644
index 0000000..90ce90e

scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c new file +5 -0
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");

If you specify a return type of int, you should be returning one:

Quoted 8 lines
Quoted 4 lines
	return 0;

:-)

Hmm, I don't think that's actually necessary for main() - if you don't specify a return value for main(), it should already implicitly return 0 IIRC...

Possibly, but explicit is better IMO. I've been yelled at in certain forums for using the implicit return.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#11 lore raw

PATCH 5/5 scripts/lib/bsp/engine.py: refactor bsp-creation code

In reply to [email protected]

From: Tom Zanussi <[email protected]>

This does a bit of refactoring of the bsp-generation code to make it generically reusable for generating non-bsp layers.

The first user remains the existing yocto-bsp tool; these changes allow a second user, the new yocto-layer tool, to use the same code.

---
 scripts/lib/bsp/engine.py | 120 +++++++++++++++++++++++++---------------------
 1 file changed, 65 insertions(+), 55 deletions(-)
scripts/lib/bsp/engine.py +65 -55
index d406e79..6a13a03 100644
@@ -1039,7 +1039,9 @@ def gen_program_machine_lines(machine, program_lines):
     Use the input values we got from the command line.
     """
     line = "machine = \"" + machine + "\""
+    program_lines.append(line)
 
+    line = "layer_name = \"" + machine + "\""
     program_lines.append(line)
 
 
@@ -1321,10 +1323,13 @@ def capture_context(context):
     return captured_context
 
 
-def expand_targets(context, bsp_output_dir):
+def expand_targets(context, bsp_output_dir, expand_common=True):
     """
     Expand all the tags in both the common and machine-specific
     'targets'.
+
+    If expand_common is False, don't expand the common target (this
+    option is used to create special-purpose layers).
     """
     target_files = []
 
@@ -1336,8 +1341,9 @@ def expand_targets(context, bsp_output_dir):
     bsp_path = lib_path + '/bsp'
     arch_path = bsp_path + '/substrate/target/arch'
 
-    common = os.path.join(arch_path, "common")
-    expand_target(common, target_files, bsp_output_dir)
+    if expand_common:
+        common = os.path.join(arch_path, "common")
+        expand_target(common, target_files, bsp_output_dir)
 
     arches = os.listdir(arch_path)
     if arch not in arches or arch == "common":
@@ -1352,18 +1358,17 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
-def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+def yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file, expand_common=True):
     """
-    Create yocto layer
+    Create bsp
 
-    layer_name - user-defined layer name
+    machine - user-defined machine name
+    arch - the arch the bsp will be based on, must be one in
+           scripts/lib/bsp/substrate/target/arch
     scripts_path - absolute path to yocto /scripts dir
     bsp_output_dir - dirname to create for BSP
     codedump - dump generated code to bspgen.out
     properties_file - use values from here if nonempty i.e no prompting
-
-    arch - the arch for a generic layer is 'generic-layer', defined in
-           scripts/lib/bsp/substrate/target/generic-layer
     """
     if os.path.exists(bsp_output_dir):
         print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
@@ -1383,7 +1388,7 @@ def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, pro
     os.mkdir(bsp_output_dir)
 
     context = create_context(machine, arch, scripts_path)
-    target_files = expand_targets(context, bsp_output_dir)
+    target_files = expand_targets(context, bsp_output_dir, expand_common)
 
     input_lines = gather_inputlines(target_files)
 
@@ -1405,7 +1410,24 @@ def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, pro
 
     run_program_lines(program_lines, codedump)
 
-    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    yocto_common_create(layer_name, "layer", scripts_path, layer_output_dir, codedump, properties_file, False)
+
+    print "\nNew layer created in %s.\n" % (layer_output_dir)
+    print "Don't forget to add it to your BBLAYERS (for details see %s\README)." % (layer_output_dir)
 
 
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
@@ -1420,47 +1442,9 @@ def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, prop
     codedump - dump generated code to bspgen.out
     properties_file - use values from here if nonempty i.e no prompting
     """
-    if os.path.exists(bsp_output_dir):
-        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
-        sys.exit(1)
-
-    properties = None
-
-    if properties_file:
-        try:
-            infile = open(properties_file, "r")
-        except IOError:
-            print "Couldn't open properties file %s for reading, exiting" % properties_file
-            sys.exit(1)
-
-        properties = json.load(infile)
+    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file)
 
-    os.mkdir(bsp_output_dir)
-
-    context = create_context(machine, arch, scripts_path)
-    target_files = expand_targets(context, bsp_output_dir)
-
-    input_lines = gather_inputlines(target_files)
-
-    program_lines = []
-
-    gen_program_header_lines(program_lines)
-
-    gen_initial_property_vals(input_lines, program_lines)
-
-    if properties:
-        gen_supplied_property_vals(properties, program_lines)
-
-    gen_program_machine_lines(machine, program_lines)
-
-    if not properties:
-        gen_program_input_lines(input_lines, program_lines, context)
-
-    gen_program_lines(target_files, program_lines)
-
-    run_program_lines(program_lines, codedump)
-
-    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+    print "\nNew %s BSP created in %s" % (arch, bsp_output_dir)
 
 
 def print_dict(items, indent = 0):
@@ -1508,7 +1492,7 @@ def get_properties(input_lines):
     return properties
 
 
-def yocto_bsp_list_properties(arch, scripts_path, properties_file):
+def yocto_bsp_list_properties(arch, scripts_path, properties_file, expand_common=True):
     """
     List the complete set of properties for all the input items in the
     BSP.  If properties_file is non-null, write the complete set of
@@ -1516,7 +1500,7 @@ def yocto_bsp_list_properties(arch, scripts_path, properties_file):
     nested dictionary.
     """
     context = create_context("unused", arch, scripts_path)
-    target_files = expand_targets(context, "unused")
+    target_files = expand_targets(context, "unused", expand_common)
 
     input_lines = gather_inputlines(target_files)
 
@@ -1605,7 +1589,7 @@ def print_values(type, values_list):
             print "[\"%s\", \"%s\"]" % (value[0], value[1])
 
 
-def yocto_bsp_list_property_values(arch, property, scripts_path, properties_file):
+def yocto_bsp_list_property_values(arch, property, scripts_path, properties_file, expand_common=True):
     """
     List the possible values for a given input property.  If
     properties_file is non-null, write the complete set of properties
@@ -1614,7 +1598,7 @@ def yocto_bsp_list_property_values(arch, property, scripts_path, properties_file
     context = create_context("unused", arch, scripts_path)
     context["name"] = property
 
-    target_files = expand_targets(context, "unused")
+    target_files = expand_targets(context, "unused", expand_common)
 
     input_lines = gather_inputlines(target_files)
 
@@ -1710,6 +1694,32 @@ def yocto_bsp_list(args, scripts_path, properties_file):
     return True
 
 
+def yocto_layer_list(args, scripts_path, properties_file):
+    """
+    Print the complete list of input properties defined by the layer,
+    or the possible values for a particular layer property.
+    """
+    if len(args) < 1:
+        return False
+
+    if len(args) < 1 or len(args) > 2:
+        return False
+
+    if len(args) == 1:
+        if args[0] == "properties":
+            yocto_bsp_list_properties("layer", scripts_path, properties_file, False)
+        else:
+            return False
+
+    if len(args) == 2:
+        if args[0] == "property":
+            yocto_bsp_list_property_values("layer", args[1], scripts_path, properties_file, False)
+        else:
+            return False
+
+    return True
+
+
 def map_standard_kbranch(need_new_kbranch, new_kbranch, existing_kbranch):
     """
     Return the linux-yocto bsp branch to use with the specified
Signature · 1 line
1.7.11.4
#12 lore raw

Re: [PATCH 5/5] scripts/lib/bsp/engine.py: refactor bsp-creation code

Quoted 7 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

This does a bit of refactoring of the bsp-generation code to make it generically reusable for generating non-bsp layers.

The first user remains the existing yocto-bsp tool; these changes allow a second user, the new yocto-layer tool, to use the same code.

Aha, this is what I was looking for earlier - sorry my email search pattern dropped this patch initially.

Just a cursory review, but looks good to me.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#13 lore raw

Re: [PATCH 1/5] scripts/lib/bsp/engine.py: add yocto_layer_create()

In reply to [email protected]
Quoted 4 lines · On 12/17/2012 12:51 PM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a new yocto_layer_create() function that will be used to generate a generic yocto layer (for the new 'yocto-layer' command).

How is a "yocto layer" different from an OpenEmbedded layer? If you insist on "yocto layter", wouldn't "Yocto Project layer" be more accurate.

One of our goals for next year should be to clean up our terminology to reduce confusion in the user community.

Philip

Quoted 74 lines
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
scripts/lib/bsp/engine.py +56 -0
index 8985544..d406e79 100644
@@ -1352,6 +1352,62 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    if os.path.exists(bsp_output_dir):
+        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+        sys.exit(1)
+
+    properties = None
+
+    if properties_file:
+        try:
+            infile = open(properties_file, "r")
+        except IOError:
+            print "Couldn't open properties file %s for reading, exiting" % properties_file
+            sys.exit(1)
+
+        properties = json.load(infile)
+
+    os.mkdir(bsp_output_dir)
+
+    context = create_context(machine, arch, scripts_path)
+    target_files = expand_targets(context, bsp_output_dir)
+
+    input_lines = gather_inputlines(target_files)
+
+    program_lines = []
+
+    gen_program_header_lines(program_lines)
+
+    gen_initial_property_vals(input_lines, program_lines)
+
+    if properties:
+        gen_supplied_property_vals(properties, program_lines)
+
+    gen_program_machine_lines(machine, program_lines)
+
+    if not properties:
+        gen_program_input_lines(input_lines, program_lines, context)
+
+    gen_program_lines(target_files, program_lines)
+
+    run_program_lines(program_lines, codedump)
+
+    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
     """
     Create bsp
#14 lore raw

Re: [PATCH 1/5] scripts/lib/bsp/engine.py: add yocto_layer_create()

Quoted 9 lines · Philip Balister
Quoted 4 lines · On 12/17/2012 12:51 PM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a new yocto_layer_create() function that will be used to generate a generic yocto layer (for the new 'yocto-layer' command).

How is a "yocto layer" different from an OpenEmbedded layer? If you insist on "yocto layter", wouldn't "Yocto Project layer" be more accurate.

Technically it isn't any different, but it's based on the template engine code and templates that make up the 'Yocto BSP Tools', which for various reasons (they create Yocto-compliant BSP layers, something not of interest to OpenEmbedded proper, and it probably doesn't make sense to clutter oe-core with a bunch of 'template data', etc) live in poky and not oe-core.

As such, the new tool is named 'yocto-layer' to match the other existing Yocto BSP tools, 'yocto-bsp' and 'yocto-kernel'.

Tom

Quoted 79 lines

One of our goals for next year should be to clean up our terminology to reduce confusion in the user community.

Philip

Quoted 74 lines
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
scripts/lib/bsp/engine.py +56 -0
index 8985544..d406e79 100644
@@ -1352,6 +1352,62 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    if os.path.exists(bsp_output_dir):
+        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+        sys.exit(1)
+
+    properties = None
+
+    if properties_file:
+        try:
+            infile = open(properties_file, "r")
+        except IOError:
+            print "Couldn't open properties file %s for reading, exiting" % properties_file
+            sys.exit(1)
+
+        properties = json.load(infile)
+
+    os.mkdir(bsp_output_dir)
+
+    context = create_context(machine, arch, scripts_path)
+    target_files = expand_targets(context, bsp_output_dir)
+
+    input_lines = gather_inputlines(target_files)
+
+    program_lines = []
+
+    gen_program_header_lines(program_lines)
+
+    gen_initial_property_vals(input_lines, program_lines)
+
+    if properties:
+        gen_supplied_property_vals(properties, program_lines)
+
+    gen_program_machine_lines(machine, program_lines)
+
+    if not properties:
+        gen_program_input_lines(input_lines, program_lines, context)
+
+    gen_program_lines(target_files, program_lines)
+
+    run_program_lines(program_lines, codedump)
+
+    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
     """
     Create bsp
#15 lore raw

Re: [PATCH 1/5] scripts/lib/bsp/engine.py: add yocto_layer_create()

Quoted 11 lines · Tom Zanussi
Quoted 9 lines · Philip Balister
Quoted 4 lines · On 12/17/2012 12:51 PM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a new yocto_layer_create() function that will be used to generate a generic yocto layer (for the new 'yocto-layer' command).

How is a "yocto layer" different from an OpenEmbedded layer? If you insist on "yocto layter", wouldn't "Yocto Project layer" be more accurate.

Quoted 6 lines

Technically it isn't any different, but it's based on the template engine code and templates that make up the 'Yocto BSP Tools', which for various reasons (they create Yocto-compliant BSP layers, something not of interest to OpenEmbedded proper, and it probably doesn't make sense to clutter oe-core with a bunch of 'template data', etc) live in poky and not oe-core.

Actually, BSP's should work standalone with oe-core, so it is of interest.

Quoted 3 lines

As such, the new tool is named 'yocto-layer' to match the other existing Yocto BSP tools, 'yocto-bsp' and 'yocto-kernel'.

I will now get pedantic. <rday mode on>

The meta-yocto layer functions as a distro layer. So referring to things as yocto this and yocto that, suggests they only work with the meta-yocto layer.

So it doesn't make sense to me to put general purpose tools in a distro layer.

<rday mode off>

Quoted 87 lines

Tom

Quoted 79 lines

One of our goals for next year should be to clean up our terminology to reduce confusion in the user community.

Philip

Quoted 74 lines
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
scripts/lib/bsp/engine.py +56 -0
index 8985544..d406e79 100644
@@ -1352,6 +1352,62 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    if os.path.exists(bsp_output_dir):
+        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+        sys.exit(1)
+
+    properties = None
+
+    if properties_file:
+        try:
+            infile = open(properties_file, "r")
+        except IOError:
+            print "Couldn't open properties file %s for reading, exiting" % properties_file
+            sys.exit(1)
+
+        properties = json.load(infile)
+
+    os.mkdir(bsp_output_dir)
+
+    context = create_context(machine, arch, scripts_path)
+    target_files = expand_targets(context, bsp_output_dir)
+
+    input_lines = gather_inputlines(target_files)
+
+    program_lines = []
+
+    gen_program_header_lines(program_lines)
+
+    gen_initial_property_vals(input_lines, program_lines)
+
+    if properties:
+        gen_supplied_property_vals(properties, program_lines)
+
+    gen_program_machine_lines(machine, program_lines)
+
+    if not properties:
+        gen_program_input_lines(input_lines, program_lines, context)
+
+    gen_program_lines(target_files, program_lines)
+
+    run_program_lines(program_lines, codedump)
+
+    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
     """
     Create bsp
#16 lore raw

Re: [PATCH 1/5] scripts/lib/bsp/engine.py: add yocto_layer_create()

Quoted 27 lines · Philip Balister
Quoted 11 lines · Tom Zanussi
Quoted 9 lines · Philip Balister
Quoted 4 lines · On 12/17/2012 12:51 PM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a new yocto_layer_create() function that will be used to generate a generic yocto layer (for the new 'yocto-layer' command).

How is a "yocto layer" different from an OpenEmbedded layer? If you insist on "yocto layter", wouldn't "Yocto Project layer" be more accurate.

Quoted 6 lines

Technically it isn't any different, but it's based on the template engine code and templates that make up the 'Yocto BSP Tools', which for various reasons (they create Yocto-compliant BSP layers, something not of interest to OpenEmbedded proper, and it probably doesn't make sense to clutter oe-core with a bunch of 'template data', etc) live in poky and not oe-core.

Actually, BSP's should work standalone with oe-core, so it is of interest.

Quoted 3 lines

As such, the new tool is named 'yocto-layer' to match the other existing Yocto BSP tools, 'yocto-bsp' and 'yocto-kernel'.

I will now get pedantic. <rday mode on>

Quoted 9 lines

The meta-yocto layer functions as a distro layer. So referring to things as yocto this and yocto that, suggests they only work with the meta-yocto layer.

So it doesn't make sense to me to put general purpose tools in a distro layer.

<rday mode off>

Right, none of the yocto- tools has anything to do with the meta-yocto layer, so if that's how it's taken, then, yeah, it's misleading.

It wouldn't bother me to do a global search and replace of 'yocto' with 'oe' for the tools - I guess that would imply it would all be moving into oe-core, though. Is that what you're suggesting?

Tom

Quoted 87 lines
Quoted 87 lines

Tom

Quoted 79 lines

One of our goals for next year should be to clean up our terminology to reduce confusion in the user community.

Philip

Quoted 74 lines
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
scripts/lib/bsp/engine.py +56 -0
index 8985544..d406e79 100644
@@ -1352,6 +1352,62 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    if os.path.exists(bsp_output_dir):
+        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+        sys.exit(1)
+
+    properties = None
+
+    if properties_file:
+        try:
+            infile = open(properties_file, "r")
+        except IOError:
+            print "Couldn't open properties file %s for reading, exiting" % properties_file
+            sys.exit(1)
+
+        properties = json.load(infile)
+
+    os.mkdir(bsp_output_dir)
+
+    context = create_context(machine, arch, scripts_path)
+    target_files = expand_targets(context, bsp_output_dir)
+
+    input_lines = gather_inputlines(target_files)
+
+    program_lines = []
+
+    gen_program_header_lines(program_lines)
+
+    gen_initial_property_vals(input_lines, program_lines)
+
+    if properties:
+        gen_supplied_property_vals(properties, program_lines)
+
+    gen_program_machine_lines(machine, program_lines)
+
+    if not properties:
+        gen_program_input_lines(input_lines, program_lines, context)
+
+    gen_program_lines(target_files, program_lines)
+
+    run_program_lines(program_lines, codedump)
+
+    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
     """
     Create bsp
#17 lore raw

Re: [PATCH 1/5] scripts/lib/bsp/engine.py: add yocto_layer_create()

Quoted 38 lines · Tom Zanussi
Quoted 27 lines · Philip Balister
Quoted 11 lines · Tom Zanussi
Quoted 9 lines · Philip Balister
Quoted 4 lines · On 12/17/2012 12:51 PM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Add a new yocto_layer_create() function that will be used to generate a generic yocto layer (for the new 'yocto-layer' command).

How is a "yocto layer" different from an OpenEmbedded layer? If you insist on "yocto layter", wouldn't "Yocto Project layer" be more accurate.

Quoted 6 lines

Technically it isn't any different, but it's based on the template engine code and templates that make up the 'Yocto BSP Tools', which for various reasons (they create Yocto-compliant BSP layers, something not of interest to OpenEmbedded proper, and it probably doesn't make sense to clutter oe-core with a bunch of 'template data', etc) live in poky and not oe-core.

Actually, BSP's should work standalone with oe-core, so it is of interest.

Quoted 3 lines

As such, the new tool is named 'yocto-layer' to match the other existing Yocto BSP tools, 'yocto-bsp' and 'yocto-kernel'.

I will now get pedantic. <rday mode on>

Quoted 9 lines

The meta-yocto layer functions as a distro layer. So referring to things as yocto this and yocto that, suggests they only work with the meta-yocto layer.

So it doesn't make sense to me to put general purpose tools in a distro layer.

<rday mode off>

Quoted 6 lines

Right, none of the yocto- tools has anything to do with the meta-yocto layer, so if that's how it's taken, then, yeah, it's misleading.

It wouldn't bother me to do a global search and replace of 'yocto' with 'oe' for the tools - I guess that would imply it would all be moving into oe-core, though. Is that what you're suggesting?

I am not sure what the best way to clear up terminology is at the moment, and given it is he week before Christmas, a number of people I would like to discuss this with are on holiday, so we can defer the solution until next year.

In the meantime, I have no problem with people getting work done, so I have no objection to the patch moving forward.

Philip

Quoted 94 lines

Tom

Quoted 87 lines
Quoted 87 lines

Tom

Quoted 79 lines

One of our goals for next year should be to clean up our terminology to reduce confusion in the user community.

Philip

Quoted 74 lines
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
scripts/lib/bsp/engine.py +56 -0
index 8985544..d406e79 100644
@@ -1352,6 +1352,62 @@ def expand_targets(context, bsp_output_dir):
     return target_files
 
 
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+    """
+    Create yocto layer
+
+    layer_name - user-defined layer name
+    scripts_path - absolute path to yocto /scripts dir
+    bsp_output_dir - dirname to create for BSP
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from here if nonempty i.e no prompting
+
+    arch - the arch for a generic layer is 'generic-layer', defined in
+           scripts/lib/bsp/substrate/target/generic-layer
+    """
+    if os.path.exists(bsp_output_dir):
+        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+        sys.exit(1)
+
+    properties = None
+
+    if properties_file:
+        try:
+            infile = open(properties_file, "r")
+        except IOError:
+            print "Couldn't open properties file %s for reading, exiting" % properties_file
+            sys.exit(1)
+
+        properties = json.load(infile)
+
+    os.mkdir(bsp_output_dir)
+
+    context = create_context(machine, arch, scripts_path)
+    target_files = expand_targets(context, bsp_output_dir)
+
+    input_lines = gather_inputlines(target_files)
+
+    program_lines = []
+
+    gen_program_header_lines(program_lines)
+
+    gen_initial_property_vals(input_lines, program_lines)
+
+    if properties:
+        gen_supplied_property_vals(properties, program_lines)
+
+    gen_program_machine_lines(machine, program_lines)
+
+    if not properties:
+        gen_program_input_lines(input_lines, program_lines, context)
+
+    gen_program_lines(target_files, program_lines)
+
+    run_program_lines(program_lines, codedump)
+
+    print "New %s BSP created in %s" % (arch, bsp_output_dir)
+
+
 def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file):
     """
     Create bsp
#18 lore raw
In reply to [email protected]
Quoted 33 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Since I've been doing kind of similar work lately for the 'custom kernel' support for yocto-bsp and have gotten several requests lately (mainly from Darren in support of the new kernel documentation) for something like this, I decided to just go ahead and try to quickly implement a general-purpose layer-generation tool based on the BSP-generation code used in the yocto-bsp tool.

There's actually an enhancement request bug for this already in the Yocto bugzilla, but it doesn't contain many details:

Bug 3094 - Add a layer generation tool:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=3094

So anyway, this is my initial take on what that bug means. It's an RFC for a couple reasons, first that I'd like to get comments on whether this is actually what's needed for a 'layer generation tool', and second, because I still need to do some cleanup of the refactored code, but don't want to waste much time on it if it's not really what's needed.

Below are a couple examples of how it's used - you really have to try it yourself to see what's generated - I don't want to post tarballs or such on the list and it's simple to generate and look at the layers.

The first case is just a very simple layer with a layer.conf and README - basically the simplest layer you can create, and which exists mainly because even that is easy to get wrong. As with the yocto-bsp tool, the script queries the user for a couple items, here we just take the defaults, which are a priority of 6 for the layer and no other components such as example recipes:

Quoted 4 lines

[trz@empanada build]$ yocto-layer create simplestlayer
Please enter the layer priority you'd like to use for the layer: [default: 6] Would you like to have an example recipe created? (y/n) [default: n] Would you like to have an example bbappend file created? (y/n) [default: n]

Can these options be specified on the cli? It would be nice for documentation to not have to list all the questions to describe how to accomplish a specific task such as this. e.g.

[trz@empanada build]$ yocto-layer create simplestlayer -p 6 --no-recipe --no-bbappend

Or possibly having defaults to those questions accepted by default unless [-i|--interactive] is specified?

empanada :-) Mmmmmm

Quoted 4 lines

New layer created in meta-simplestlayer.

Don't forget to add it to your BBLAYERS (for details see meta-simplestlayer\README).

Quoted 8 lines

[trz@empanada build]$ find .
.
./meta-simplestlayer
./meta-simplestlayer/conf
./meta-simplestlayer/conf/layer.conf
./meta-simplestlayer/README
./meta-simplestlayer/COPYING.MIT

It might make sense to create a recipes/ directory as well, just to support convention.

Quoted 11 lines

In the second case, we tell the tool that we do want an example .bb and and an example .bbappend. We're queried for the recipe name that we want our recipe to have, and for the .bbappend, the name of the base recipe and its version. Below you can see the files it generates - please look at the files themselves to see the contents. For the recipe example, it generates a recipe based on the example in the Yocto manual, and my own helloworld.c code (untested so far which is also why this is an RFC). For the .bbappend example, it just creates an empty .patch file with some instructions on what to do to modify the parent recipe with a patch:

Quoted 7 lines

[trz@empanada build]$ yocto-layer create mylayer
Please enter the layer priority you'd like to use for the layer: [default: 6]
Would you like to have an example recipe created? (y/n) [default: n] y
Please enter the name you'd like to use for your example recipe: [default: example] flork
Would you like to have an example bbappend file created? (y/n) [default: n] y
Please enter the name you'd like to use for your bbappend file: [default: example] chork
Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1] 0.22.3

Wow, that's quite a bit more than I was asking for... I can imagine that some folks my find that useful.

Quoted 24 lines

New layer created in meta-mylayer.

Don't forget to add it to your BBLAYERS (for details see meta-mylayer\README).

[trz@empanada build]$ find .
.
./meta-mylayer
./meta-mylayer/recipes-example
./meta-mylayer/recipes-example/example ./meta-mylayer/recipes-example/example/flork-0.1 ./meta-mylayer/recipes-example/example/flork-0.1/helloworld.c ./meta-mylayer/recipes-example/example/flork-0.1/example.patch ./meta-mylayer/recipes-example/example/flork_0.1.bb ./meta-mylayer/conf
./meta-mylayer/conf/layer.conf
./meta-mylayer/recipes-example-bbappend ./meta-mylayer/recipes-example-bbappend/example-bbappend ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork-0.22.3 ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork-0.22.3/example.patch ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork_0.22.3.bbappend ./meta-mylayer/README
./meta-mylayer/COPYING.MIT

Quoted 2 lines

Please try it and look at the generated code - any comments or suggestions are welcome.

In concept, looks pretty good to me, and a natural refactoring of yocto-bsp. I'll review the patches independently.

Thanks,

Darren

Quoted 44 lines

Thanks,

Tom

The following changes since commit da598d4f0fcf6faa62055084a51d70d735399d33:

eglibc: fix checksums of fetched patches (2012-12-13 18:02:21 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/yocto-layer-rfc
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/yocto-layer-rfc

Tom Zanussi (5):
scripts/lib/bsp/engine.py: add yocto_layer_create()
yocto-layer: new script
yocto-layer: add help/usage
yocto-layer: add 'layer' template data scripts/lib/bsp/engine.py: refactor bsp-creation code

 scripts/lib/bsp/engine.py                          |  86 +++++++-
 scripts/lib/bsp/help.py                            | 228 +++++++++++++++++++++
 .../bsp/substrate/target/arch/layer/COPYING.MIT    |  17 ++
 scripts/lib/bsp/substrate/target/arch/layer/README |  64 ++++++
 .../substrate/target/arch/layer/conf/layer.conf    |  10 +
 .../target/arch/layer/layer-questions.noinstall    |  14 ++
 .../example.patch"                                 |  12 ++
 ..._name}}_{{=example_bbappend_version}}.bbappend" |   8 +
 .../{{=example_recipe_name}}-0.1/example.patch"    |  12 ++
 .../{{=example_recipe_name}}-0.1/helloworld.c"     |   6 +
 .../example/{{=example_recipe_name}}_0.1.bb"       |  23 +++
 scripts/yocto-layer                                | 142 +++++++++++++
 12 files changed, 612 insertions(+), 10 deletions(-)
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/README
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}-{{=example_bbappend_version}}/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"
 create mode 100755 scripts/yocto-layer
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#19 lore raw
Quoted 44 lines · Darren Hart
Quoted 33 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

Since I've been doing kind of similar work lately for the 'custom kernel' support for yocto-bsp and have gotten several requests lately (mainly from Darren in support of the new kernel documentation) for something like this, I decided to just go ahead and try to quickly implement a general-purpose layer-generation tool based on the BSP-generation code used in the yocto-bsp tool.

There's actually an enhancement request bug for this already in the Yocto bugzilla, but it doesn't contain many details:

Bug 3094 - Add a layer generation tool:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=3094

So anyway, this is my initial take on what that bug means. It's an RFC for a couple reasons, first that I'd like to get comments on whether this is actually what's needed for a 'layer generation tool', and second, because I still need to do some cleanup of the refactored code, but don't want to waste much time on it if it's not really what's needed.

Below are a couple examples of how it's used - you really have to try it yourself to see what's generated - I don't want to post tarballs or such on the list and it's simple to generate and look at the layers.

The first case is just a very simple layer with a layer.conf and README - basically the simplest layer you can create, and which exists mainly because even that is easy to get wrong. As with the yocto-bsp tool, the script queries the user for a couple items, here we just take the defaults, which are a priority of 6 for the layer and no other components such as example recipes:

Quoted 4 lines

[trz@empanada build]$ yocto-layer create simplestlayer
Please enter the layer priority you'd like to use for the layer: [default: 6] Would you like to have an example recipe created? (y/n) [default: n] Would you like to have an example bbappend file created? (y/n) [default: n]

Can these options be specified on the cli? It would be nice for documentation to not have to list all the questions to describe how to accomplish a specific task such as this. e.g.

Quoted 6 lines

[trz@empanada build]$ yocto-layer create simplestlayer -p 6 --no-recipe --no-bbappend

Or possibly having defaults to those questions accepted by default unless [-i|--interactive] is specified?

Well, you can do it all from the command-line if you use the -i command (where -i doesn't mean interactive, just the opposite in fact) with a JSON file:

[trz@empanada build]$ yocto-layer create jtest -i yocto-layer-input.json

With the contents of yocto-layer-input.json being values for the properties you get from 'yocto-layer list properties':

{"layer_priority":"6","create_example_recipe":"n","create_example_bbappend":"n","example_recipe_name":"example","example_bbappend_name":"example","example_bbappend_version":"0.1"}

Obviously this isn't designed for humans to use directly - the purpose is to allow other tools to use the Yocto BSP tools but avoid having to display the default text-based interface. ADT uses this for instance to create an Eclipse UI for yocto-bsp.

I could add specific command-line options for each of those properties, or a subset if that makes sense, but the templating engine and the resulting tools were meant to be 'user-friendly' and 'menu-driven' for complete novices who don't necessarily want to read documentation.

I'm thinking that most users probably won't use these tools very often, so providing a complete command-line equivalent encompassing all the options would be more trouble than it's worth. It might make sense though to do it for the case of the 'simplest layer' which would mean just adding a 'priority' option in addition to the layer name already specified on the command line.

Quoted 2 lines

empanada :-) Mmmmmm

Yeah, that's what happens when you install a new system just before dinner. ;-)

Quoted 15 lines
Quoted 5 lines

New layer created in meta-simplestlayer.

Don't forget to add it to your BBLAYERS (for details see meta-simplestlayer\README).

Quoted 8 lines

[trz@empanada build]$ find .
.
./meta-simplestlayer
./meta-simplestlayer/conf
./meta-simplestlayer/conf/layer.conf
./meta-simplestlayer/README
./meta-simplestlayer/COPYING.MIT

Quoted 3 lines

It might make sense to create a recipes/ directory as well, just to support convention.

Not sure what you mean - if you say 'y' to either the recipe or the bbappend, it will create a recipes-example/ dir to contain them. Do you mean something else?

Quoted 49 lines
Quoted 12 lines

In the second case, we tell the tool that we do want an example .bb and and an example .bbappend. We're queried for the recipe name that we want our recipe to have, and for the .bbappend, the name of the base recipe and its version. Below you can see the files it generates - please look at the files themselves to see the contents. For the recipe example, it generates a recipe based on the example in the Yocto manual, and my own helloworld.c code (untested so far which is also why this is an RFC). For the .bbappend example, it just creates an empty .patch file with some instructions on what to do to modify the parent recipe with a patch:

Quoted 7 lines

[trz@empanada build]$ yocto-layer create mylayer
Please enter the layer priority you'd like to use for the layer: [default: 6]
Would you like to have an example recipe created? (y/n) [default: n] y
Please enter the name you'd like to use for your example recipe: [default: example] flork
Would you like to have an example bbappend file created? (y/n) [default: n] y
Please enter the name you'd like to use for your bbappend file: [default: example] chork
Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1] 0.22.3

Wow, that's quite a bit more than I was asking for... I can imagine that some folks my find that useful.

Quoted 24 lines

New layer created in meta-mylayer.

Don't forget to add it to your BBLAYERS (for details see meta-mylayer\README).

[trz@empanada build]$ find .
.
./meta-mylayer
./meta-mylayer/recipes-example
./meta-mylayer/recipes-example/example ./meta-mylayer/recipes-example/example/flork-0.1 ./meta-mylayer/recipes-example/example/flork-0.1/helloworld.c ./meta-mylayer/recipes-example/example/flork-0.1/example.patch ./meta-mylayer/recipes-example/example/flork_0.1.bb ./meta-mylayer/conf
./meta-mylayer/conf/layer.conf
./meta-mylayer/recipes-example-bbappend ./meta-mylayer/recipes-example-bbappend/example-bbappend ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork-0.22.3 ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork-0.22.3/example.patch ./meta-mylayer/recipes-example-bbappend/example-bbappend/chork_0.22.3.bbappend ./meta-mylayer/README
./meta-mylayer/COPYING.MIT

Quoted 7 lines
Quoted 2 lines

Please try it and look at the generated code - any comments or suggestions are welcome.

In concept, looks pretty good to me, and a natural refactoring of yocto-bsp. I'll review the patches independently.

Thanks for reviewing them!

Tom

Quoted 50 lines

Thanks,

Darren

Quoted 44 lines

Thanks,

Tom

The following changes since commit da598d4f0fcf6faa62055084a51d70d735399d33:

eglibc: fix checksums of fetched patches (2012-12-13 18:02:21 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/yocto-layer-rfc
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/yocto-layer-rfc

Tom Zanussi (5):
scripts/lib/bsp/engine.py: add yocto_layer_create()
yocto-layer: new script
yocto-layer: add help/usage
yocto-layer: add 'layer' template data scripts/lib/bsp/engine.py: refactor bsp-creation code

 scripts/lib/bsp/engine.py                          |  86 +++++++-
 scripts/lib/bsp/help.py                            | 228 +++++++++++++++++++++
 .../bsp/substrate/target/arch/layer/COPYING.MIT    |  17 ++
 scripts/lib/bsp/substrate/target/arch/layer/README |  64 ++++++
 .../substrate/target/arch/layer/conf/layer.conf    |  10 +
 .../target/arch/layer/layer-questions.noinstall    |  14 ++
 .../example.patch"                                 |  12 ++
 ..._name}}_{{=example_bbappend_version}}.bbappend" |   8 +
 .../{{=example_recipe_name}}-0.1/example.patch"    |  12 ++
 .../{{=example_recipe_name}}-0.1/helloworld.c"     |   6 +
 .../example/{{=example_recipe_name}}_0.1.bb"       |  23 +++
 scripts/yocto-layer                                | 142 +++++++++++++
 12 files changed, 612 insertions(+), 10 deletions(-)
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/README
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
 create mode 100644 scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}-{{=example_bbappend_version}}/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"
 create mode 100644 "scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"
 create mode 100755 scripts/yocto-layer
#20 lore raw
Quoted 11 lines · Tom Zanussi
Quoted 3 lines · Darren Hart
Quoted 2 lines · On 12/17/2012 09:51 AM, [email protected] wrote:

From: Tom Zanussi <[email protected]>

I'm thinking that most users probably won't use these tools very often, so providing a complete command-line equivalent encompassing all the options would be more trouble than it's worth. It might make sense though to do it for the case of the 'simplest layer' which would mean just adding a 'priority' option in addition to the layer name already specified on the command line.

Nothing else to add, agreed.

Quoted 7 lines
Quoted 3 lines

It might make sense to create a recipes/ directory as well, just to support convention.

Not sure what you mean - if you say 'y' to either the recipe or the bbappend, it will create a recipes-example/ dir to contain them. Do you mean something else?

Missed that, problem solved.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel