All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] scripts/lib/bsp/engine.py: add yocto_layer_create()
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py
index 8985544..d406e79 100644
--- a/scripts/lib/bsp/engine.py
+++ b/scripts/lib/bsp/engine.py
@@ -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
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/7] yocto-layer: new script
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/yocto-layer | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100755 scripts/yocto-layer

diff --git a/scripts/yocto-layer b/scripts/yocto-layer
new file mode 100755
index 0000000..f759275
--- /dev/null
+++ b/scripts/yocto-layer
@@ -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)
+
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/7] yocto-layer: add help/usage
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/help.py | 228 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 228 insertions(+)

diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index 3a1f52c..eac172a 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -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
 ##
 
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 0/7] new 'yocto-layer' tool for creating generic Yocto layers, v1
@ 2013-01-18 18:27 ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

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

v1 changes (the previous version was an RFC):

- if layer_priority is specified on the command line, the user is not
  queried and the layer is generated immediately
- explicitly return 0 in the hello.c example code

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

If you specify a layer_priority directly on the command line,
yocto-layer will not query the user at all but instead will generate
the layer (without example recipes etc) immediately:

 [trz@empanada build]$ yocto-layer create simplestlayer 7

 New layer created in meta-simplestlayer.

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

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

Thanks,

Tom

The following changes since commit 53cc748b93e8af584557d6db5309c3e955182c5c:

  linux-libc-headers: fix headers install in long path name environments (2013-01-10 23:53:51 +0000)

are available in the git repository at:

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

Tom Zanussi (7):
  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
  yocto-layer: add optional layer priority param
  scripts/lib/bsp/engine.py: add handling for JSON strings

 scripts/lib/bsp/engine.py                          | 114 ++++++++--
 scripts/lib/bsp/help.py                            | 238 +++++++++++++++++++++
 .../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"     |   8 +
 .../example/{{=example_recipe_name}}_0.1.bb"       |  23 ++
 scripts/yocto-layer                                | 147 +++++++++++++
 12 files changed, 645 insertions(+), 22 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

-- 
1.7.11.4



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/7] yocto-layer: add 'layer' template data
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 .../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"     |  8 +++
 .../example/{{=example_recipe_name}}_0.1.bb"       | 23 ++++++++
 9 files changed, 168 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"

diff --git a/scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT b/scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
new file mode 100644
index 0000000..89de354
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
@@ -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.
diff --git a/scripts/lib/bsp/substrate/target/arch/layer/README b/scripts/lib/bsp/substrate/target/arch/layer/README
new file mode 100644
index 0000000..943dfc4
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/README
@@ -0,0 +1,64 @@
+This README file contains information on the contents of the
+{{=layer_name}} layer.
+
+Please see the corresponding sections below for details.
+
+
+Dependencies
+============
+
+This layer depends on:
+
+  URI: git://git.openembedded.org/bitbake
+  branch: master
+
+  URI: git://git.openembedded.org/openembedded-core
+  layers: meta
+  branch: master
+
+  URI: git://git.yoctoproject.org/xxxx
+  layers: xxxx
+  branch: master
+
+
+Patches
+=======
+
+Please submit any patches against the {{=layer_name}} layer to the
+xxxx mailing list (xxxx@zzzz.org) and cc: the maintainer:
+
+Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
+
+
+Table of Contents
+=================
+
+  I. Adding the {{=layer_name}} layer to your build
+ II. Misc
+
+
+I. Adding the {{=layer_name}} layer to your build
+=================================================
+
+--- replace with specific instructions for the {{=layer_name}} layer ---
+
+In order to use this layer, you need to make the build system aware of
+it.
+
+Assuming the {{=layer_name}} layer exists at the top-level of your
+yocto build tree, you can add it to the build system by adding the
+location of the {{=layer_name}} layer to bblayers.conf, along with any
+other layers needed. e.g.:
+
+  BBLAYERS ?= " \
+    /path/to/yocto/meta \
+    /path/to/yocto/meta-yocto \
+    /path/to/yocto/meta-yocto-bsp \
+    /path/to/yocto/meta-{{=layer_name}} \
+    "
+
+
+II. Misc
+========
+
+--- replace with specific information about the {{=layer_name}} layer ---
diff --git a/scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf b/scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
new file mode 100644
index 0000000..84a9abb
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
@@ -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}}"
diff --git a/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall b/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
new file mode 100644
index 0000000..e2a89c3
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
@@ -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"}}
diff --git "a/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" "b/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 mode 100644
index 0000000..2000a34
--- /dev/null
+++ "b/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"	
@@ -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.
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend" "b/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 mode 100644
index 0000000..2e50ff6
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend"	
@@ -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).
+#
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch" "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"
new file mode 100644
index 0000000..2000a34
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"	
@@ -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.
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c" "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"
new file mode 100644
index 0000000..71f2e46
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"	
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");
+
+    return 0;
+}
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb" "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"
new file mode 100644
index 0000000..14bf344
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"	
@@ -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}
+}
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/7] scripts/lib/bsp/engine.py: refactor bsp-creation code
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

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.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/engine.py | 141 +++++++++++++++++++++++++---------------------
 1 file changed, 76 insertions(+), 65 deletions(-)

diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py
index d406e79..7431860 100644
--- a/scripts/lib/bsp/engine.py
+++ b/scripts/lib/bsp/engine.py
@@ -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,21 +1358,22 @@ 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, target, scripts_path, layer_output_dir, codedump, properties_file, properties_str="", expand_common=True):
     """
-    Create yocto layer
+    Common layer-creation code
 
-    layer_name - user-defined layer name
+    machine - user-defined machine name (if needed, will generate 'machine' var)
+    target - the 'target' the layer 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
+    layer_output_dir - dirname to create for layer
     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
+    properties_file - use values from this file if nonempty i.e no prompting
+    properties_str - use values from this string if nonempty i.e no prompting
+    expand_common - boolean, use the contents of (for bsp layers) arch/common
     """
-    if os.path.exists(bsp_output_dir):
-        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+    if os.path.exists(layer_output_dir):
+        print "\nlayer output dir already exists, exiting. (%s)" % layer_output_dir
         sys.exit(1)
 
     properties = None
@@ -1380,10 +1387,10 @@ def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, pro
 
         properties = json.load(infile)
 
-    os.mkdir(bsp_output_dir)
+    os.mkdir(layer_output_dir)
 
-    context = create_context(machine, arch, scripts_path)
-    target_files = expand_targets(context, bsp_output_dir)
+    context = create_context(machine, target, scripts_path)
+    target_files = expand_targets(context, layer_output_dir, expand_common)
 
     input_lines = gather_inputlines(target_files)
 
@@ -1405,7 +1412,22 @@ 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
+    layer_output_dir - dirname to create for layer
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from this file if nonempty i.e no prompting
+    properties - use values from this string if nonempty i.e no prompting
+    """
+    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):
@@ -1418,49 +1440,12 @@ def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, prop
     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
+    properties_file - use values from this file if nonempty i.e no prompting
+    properties - use values from this string 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)
+    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file)
 
-    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)
+    print "\nNew %s BSP created in %s" % (arch, bsp_output_dir)
 
 
 def print_dict(items, indent = 0):
@@ -1508,15 +1493,15 @@ def get_properties(input_lines):
     return properties
 
 
-def yocto_bsp_list_properties(arch, scripts_path, properties_file):
+def yocto_layer_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
+    layer.  If properties_file is non-null, write the complete set of
     properties as a nested JSON object corresponding to a possibly
     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 +1590,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_layer_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 +1599,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)
 
@@ -1697,13 +1682,39 @@ def yocto_bsp_list(args, scripts_path, properties_file):
 
     if len(args) == 2:
         if args[1] == "properties":
-            yocto_bsp_list_properties(arch, scripts_path, properties_file)
+            yocto_layer_list_properties(arch, scripts_path, properties_file)
         else:
             return False
 
     if len(args) == 3:
         if args[1] == "property":
-            yocto_bsp_list_property_values(arch, args[2], scripts_path, properties_file)
+            yocto_layer_list_property_values(arch, args[2], scripts_path, properties_file)
+        else:
+            return False
+
+    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_layer_list_properties("layer", scripts_path, properties_file, False)
+        else:
+            return False
+
+    if len(args) == 2:
+        if args[0] == "property":
+            yocto_layer_list_property_values("layer", args[1], scripts_path, properties_file, False)
         else:
             return False
 
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/7] yocto-layer: add optional layer priority param
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

If the user specifies a layer priority following the layer name, layer
creation will proceed without further queries using the specified
layer priority and the remaining values defaulted.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/help.py | 14 ++++++++++++--
 scripts/yocto-layer     |  9 +++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index eac172a..346bf0f 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -622,7 +622,8 @@ yocto_layer_create_usage = """
 
  Create a new generic Yocto layer
 
- usage: yocto-layer create <layer-name> [-o <DIRNAME> | --outdir <DIRNAME>]
+ usage: yocto-layer create <layer-name> [layer_priority]
+            [-o <DIRNAME> | --outdir <DIRNAME>]
             [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
 
  This command creates a generic Yocto layer based on the specified
@@ -631,6 +632,10 @@ yocto_layer_create_usage = """
  'meta-layer-name'.  The -o option can be used to place the layer in a
  directory with a different name and location.
 
+ If layer_priority is specified, a simple layer will be created using
+ the given layer priority, and the user will not be prompted for
+ further input.
+
  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
@@ -646,7 +651,8 @@ NAME
     yocto-layer create - Create a new generic Yocto layer
 
 SYNOPSIS
-    yocto-layer create <layer-name> [-o <DIRNAME> | --outdir <DIRNAME>]
+    yocto-layer create <layer-name> [layer_priority]
+        [-o <DIRNAME> | --outdir <DIRNAME>]
         [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
 
 DESCRIPTION
@@ -656,6 +662,10 @@ DESCRIPTION
     'meta-layer-name'.  The -o option can be used to place the layer
     in a directory with a different name and location.
 
+    If layer_priority is specified, a simple layer will be created
+    using the given layer priority, and the user will not be prompted
+    for further input.
+
     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
diff --git a/scripts/yocto-layer b/scripts/yocto-layer
index f759275..53d2aab 100755
--- a/scripts/yocto-layer
+++ b/scripts/yocto-layer
@@ -60,19 +60,24 @@ def yocto_layer_create_subcommand(args, usage_str):
                       default = False, help = "dump the generated code to layergen.out")
     (options, args) = parser.parse_args(args)
 
-    if len(args) != 1:
+    if len(args) < 1 or len(args) > 2:
         logging.error("Wrong number of arguments, exiting\n")
         parser.print_help()
         sys.exit(1)
 
     layer_name = args[0]
+    properties = ""
+
+    if len(args) == 2:
+        layer_priority = args[1]
+        properties = '{"layer_priority":"' + layer_priority + '"}'
 
     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)
+    yocto_layer_create(layer_name, scripts_path, layer_output_dir, options.codedump, options.properties_file, properties)
 
 
 def yocto_layer_list_subcommand(args, usage_str):
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/7] scripts/lib/bsp/engine.py: add handling for JSON strings
  2013-01-18 18:27 ` tom.zanussi
@ 2013-01-18 18:27   ` tom.zanussi
  -1 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-11 20:43 UTC (permalink / raw)
  To: yocto, dvhart

From: Tom Zanussi <tom.zanussi@intel.com>

Normally pre-canned properties are supplied as JSON from a file, which
the user can specify using e.g. the -i option.

We can reuse that basic functionality for dedicated command-line
parameters by sythesizing a JSON string containing those param values
on the fly and passing that in instead.

This adds the ability for the common creation code to accept JSON
strings as well as JSON files.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/engine.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py
index 7431860..aa26280 100644
--- a/scripts/lib/bsp/engine.py
+++ b/scripts/lib/bsp/engine.py
@@ -1387,6 +1387,9 @@ def yocto_common_create(machine, target, scripts_path, layer_output_dir, codedum
 
         properties = json.load(infile)
 
+    if properties_str and not properties:
+        properties = json.loads(properties_str)
+
     os.mkdir(layer_output_dir)
 
     context = create_context(machine, target, scripts_path)
@@ -1413,7 +1416,7 @@ def yocto_common_create(machine, target, scripts_path, layer_output_dir, codedum
     run_program_lines(program_lines, codedump)
 
 
-def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file, properties=""):
     """
     Create yocto layer
 
@@ -1424,13 +1427,13 @@ def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, pro
     properties_file - use values from this file if nonempty i.e no prompting
     properties - use values from this string if nonempty i.e no prompting
     """
-    yocto_common_create(layer_name, "layer", scripts_path, layer_output_dir, codedump, properties_file, False)
+    yocto_common_create(layer_name, "layer", scripts_path, layer_output_dir, codedump, properties_file, properties, 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):
+def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file, properties=None):
     """
     Create bsp
 
@@ -1443,7 +1446,7 @@ def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, prop
     properties_file - use values from this file if nonempty i.e no prompting
     properties - use values from this string if nonempty i.e no prompting
     """
-    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file)
+    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file, properties)
 
     print "\nNew %s BSP created in %s" % (arch, bsp_output_dir)
 
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 1/7] scripts/lib/bsp/engine.py: add yocto_layer_create()
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/engine.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py
index 8985544..d406e79 100644
--- a/scripts/lib/bsp/engine.py
+++ b/scripts/lib/bsp/engine.py
@@ -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
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/7] yocto-layer: new script
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/yocto-layer | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100755 scripts/yocto-layer

diff --git a/scripts/yocto-layer b/scripts/yocto-layer
new file mode 100755
index 0000000..f759275
--- /dev/null
+++ b/scripts/yocto-layer
@@ -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)
+
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/7] yocto-layer: add help/usage
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/help.py | 228 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 228 insertions(+)

diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index 3a1f52c..eac172a 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -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
 ##
 
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/7] yocto-layer: add 'layer' template data
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

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

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 .../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"     |  8 +++
 .../example/{{=example_recipe_name}}_0.1.bb"       | 23 ++++++++
 9 files changed, 168 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"

diff --git a/scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT b/scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
new file mode 100644
index 0000000..89de354
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/COPYING.MIT
@@ -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.
diff --git a/scripts/lib/bsp/substrate/target/arch/layer/README b/scripts/lib/bsp/substrate/target/arch/layer/README
new file mode 100644
index 0000000..943dfc4
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/README
@@ -0,0 +1,64 @@
+This README file contains information on the contents of the
+{{=layer_name}} layer.
+
+Please see the corresponding sections below for details.
+
+
+Dependencies
+============
+
+This layer depends on:
+
+  URI: git://git.openembedded.org/bitbake
+  branch: master
+
+  URI: git://git.openembedded.org/openembedded-core
+  layers: meta
+  branch: master
+
+  URI: git://git.yoctoproject.org/xxxx
+  layers: xxxx
+  branch: master
+
+
+Patches
+=======
+
+Please submit any patches against the {{=layer_name}} layer to the
+xxxx mailing list (xxxx@zzzz.org) and cc: the maintainer:
+
+Maintainer: XXX YYYYYY <xxx.yyyyyy@zzzzz.com>
+
+
+Table of Contents
+=================
+
+  I. Adding the {{=layer_name}} layer to your build
+ II. Misc
+
+
+I. Adding the {{=layer_name}} layer to your build
+=================================================
+
+--- replace with specific instructions for the {{=layer_name}} layer ---
+
+In order to use this layer, you need to make the build system aware of
+it.
+
+Assuming the {{=layer_name}} layer exists at the top-level of your
+yocto build tree, you can add it to the build system by adding the
+location of the {{=layer_name}} layer to bblayers.conf, along with any
+other layers needed. e.g.:
+
+  BBLAYERS ?= " \
+    /path/to/yocto/meta \
+    /path/to/yocto/meta-yocto \
+    /path/to/yocto/meta-yocto-bsp \
+    /path/to/yocto/meta-{{=layer_name}} \
+    "
+
+
+II. Misc
+========
+
+--- replace with specific information about the {{=layer_name}} layer ---
diff --git a/scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf b/scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
new file mode 100644
index 0000000..84a9abb
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/conf/layer.conf
@@ -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}}"
diff --git a/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall b/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
new file mode 100644
index 0000000..e2a89c3
--- /dev/null
+++ b/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
@@ -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"}}
diff --git "a/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" "b/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 mode 100644
index 0000000..2000a34
--- /dev/null
+++ "b/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"	
@@ -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.
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend" "b/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 mode 100644
index 0000000..2e50ff6
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_bbappend == \"y\": }} recipes-example-bbappend/example-bbappend/{{=example_bbappend_name}}_{{=example_bbappend_version}}.bbappend"	
@@ -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).
+#
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch" "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"
new file mode 100644
index 0000000..2000a34
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/example.patch"	
@@ -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.
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c" "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"
new file mode 100644
index 0000000..71f2e46
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}-0.1/helloworld.c"	
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+    printf("Hello World!\n");
+
+    return 0;
+}
diff --git "a/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb" "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"
new file mode 100644
index 0000000..14bf344
--- /dev/null
+++ "b/scripts/lib/bsp/substrate/target/arch/layer/{{ if create_example_recipe == \"y\": }} recipes-example/example/{{=example_recipe_name}}_0.1.bb"	
@@ -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}
+}
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 0/7] new 'yocto-layer' tool for creating generic Yocto layers, v1
@ 2013-01-18 18:27 ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

NOTE: No changes here from previous posting of this patchset, just
reposting to the right list this time...

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

v1 changes (the previous version was an RFC):

- if layer_priority is specified on the command line, the user is not
  queried and the layer is generated immediately
- explicitly return 0 in the hello.c example code

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

If you specify a layer_priority directly on the command line,
yocto-layer will not query the user at all but instead will generate
the layer (without example recipes etc) immediately:

 [trz@empanada build]$ yocto-layer create simplestlayer 7

 New layer created in meta-simplestlayer.

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

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

Thanks,

Tom

The following changes since commit 53cc748b93e8af584557d6db5309c3e955182c5c:

  linux-libc-headers: fix headers install in long path name environments (2013-01-10 23:53:51 +0000)

are available in the git repository at:

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

Tom Zanussi (7):
  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
  yocto-layer: add optional layer priority param
  scripts/lib/bsp/engine.py: add handling for JSON strings

 scripts/lib/bsp/engine.py                          | 114 ++++++++--
 scripts/lib/bsp/help.py                            | 238 +++++++++++++++++++++
 .../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"     |   8 +
 .../example/{{=example_recipe_name}}_0.1.bb"       |  23 ++
 scripts/yocto-layer                                | 147 +++++++++++++
 12 files changed, 645 insertions(+), 22 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

-- 
1.7.11.4



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/7] scripts/lib/bsp/engine.py: refactor bsp-creation code
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

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.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/engine.py | 141 +++++++++++++++++++++++++---------------------
 1 file changed, 76 insertions(+), 65 deletions(-)

diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py
index d406e79..7431860 100644
--- a/scripts/lib/bsp/engine.py
+++ b/scripts/lib/bsp/engine.py
@@ -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,21 +1358,22 @@ 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, target, scripts_path, layer_output_dir, codedump, properties_file, properties_str="", expand_common=True):
     """
-    Create yocto layer
+    Common layer-creation code
 
-    layer_name - user-defined layer name
+    machine - user-defined machine name (if needed, will generate 'machine' var)
+    target - the 'target' the layer 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
+    layer_output_dir - dirname to create for layer
     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
+    properties_file - use values from this file if nonempty i.e no prompting
+    properties_str - use values from this string if nonempty i.e no prompting
+    expand_common - boolean, use the contents of (for bsp layers) arch/common
     """
-    if os.path.exists(bsp_output_dir):
-        print "\nBSP output dir already exists, exiting. (%s)" % bsp_output_dir
+    if os.path.exists(layer_output_dir):
+        print "\nlayer output dir already exists, exiting. (%s)" % layer_output_dir
         sys.exit(1)
 
     properties = None
@@ -1380,10 +1387,10 @@ def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, pro
 
         properties = json.load(infile)
 
-    os.mkdir(bsp_output_dir)
+    os.mkdir(layer_output_dir)
 
-    context = create_context(machine, arch, scripts_path)
-    target_files = expand_targets(context, bsp_output_dir)
+    context = create_context(machine, target, scripts_path)
+    target_files = expand_targets(context, layer_output_dir, expand_common)
 
     input_lines = gather_inputlines(target_files)
 
@@ -1405,7 +1412,22 @@ 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
+    layer_output_dir - dirname to create for layer
+    codedump - dump generated code to bspgen.out
+    properties_file - use values from this file if nonempty i.e no prompting
+    properties - use values from this string if nonempty i.e no prompting
+    """
+    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):
@@ -1418,49 +1440,12 @@ def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, prop
     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
+    properties_file - use values from this file if nonempty i.e no prompting
+    properties - use values from this string 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)
+    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file)
 
-    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)
+    print "\nNew %s BSP created in %s" % (arch, bsp_output_dir)
 
 
 def print_dict(items, indent = 0):
@@ -1508,15 +1493,15 @@ def get_properties(input_lines):
     return properties
 
 
-def yocto_bsp_list_properties(arch, scripts_path, properties_file):
+def yocto_layer_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
+    layer.  If properties_file is non-null, write the complete set of
     properties as a nested JSON object corresponding to a possibly
     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 +1590,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_layer_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 +1599,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)
 
@@ -1697,13 +1682,39 @@ def yocto_bsp_list(args, scripts_path, properties_file):
 
     if len(args) == 2:
         if args[1] == "properties":
-            yocto_bsp_list_properties(arch, scripts_path, properties_file)
+            yocto_layer_list_properties(arch, scripts_path, properties_file)
         else:
             return False
 
     if len(args) == 3:
         if args[1] == "property":
-            yocto_bsp_list_property_values(arch, args[2], scripts_path, properties_file)
+            yocto_layer_list_property_values(arch, args[2], scripts_path, properties_file)
+        else:
+            return False
+
+    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_layer_list_properties("layer", scripts_path, properties_file, False)
+        else:
+            return False
+
+    if len(args) == 2:
+        if args[0] == "property":
+            yocto_layer_list_property_values("layer", args[1], scripts_path, properties_file, False)
         else:
             return False
 
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/7] yocto-layer: add optional layer priority param
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

If the user specifies a layer priority following the layer name, layer
creation will proceed without further queries using the specified
layer priority and the remaining values defaulted.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/help.py | 14 ++++++++++++--
 scripts/yocto-layer     |  9 +++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index eac172a..346bf0f 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -622,7 +622,8 @@ yocto_layer_create_usage = """
 
  Create a new generic Yocto layer
 
- usage: yocto-layer create <layer-name> [-o <DIRNAME> | --outdir <DIRNAME>]
+ usage: yocto-layer create <layer-name> [layer_priority]
+            [-o <DIRNAME> | --outdir <DIRNAME>]
             [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
 
  This command creates a generic Yocto layer based on the specified
@@ -631,6 +632,10 @@ yocto_layer_create_usage = """
  'meta-layer-name'.  The -o option can be used to place the layer in a
  directory with a different name and location.
 
+ If layer_priority is specified, a simple layer will be created using
+ the given layer priority, and the user will not be prompted for
+ further input.
+
  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
@@ -646,7 +651,8 @@ NAME
     yocto-layer create - Create a new generic Yocto layer
 
 SYNOPSIS
-    yocto-layer create <layer-name> [-o <DIRNAME> | --outdir <DIRNAME>]
+    yocto-layer create <layer-name> [layer_priority]
+        [-o <DIRNAME> | --outdir <DIRNAME>]
         [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
 
 DESCRIPTION
@@ -656,6 +662,10 @@ DESCRIPTION
     'meta-layer-name'.  The -o option can be used to place the layer
     in a directory with a different name and location.
 
+    If layer_priority is specified, a simple layer will be created
+    using the given layer priority, and the user will not be prompted
+    for further input.
+
     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
diff --git a/scripts/yocto-layer b/scripts/yocto-layer
index f759275..53d2aab 100755
--- a/scripts/yocto-layer
+++ b/scripts/yocto-layer
@@ -60,19 +60,24 @@ def yocto_layer_create_subcommand(args, usage_str):
                       default = False, help = "dump the generated code to layergen.out")
     (options, args) = parser.parse_args(args)
 
-    if len(args) != 1:
+    if len(args) < 1 or len(args) > 2:
         logging.error("Wrong number of arguments, exiting\n")
         parser.print_help()
         sys.exit(1)
 
     layer_name = args[0]
+    properties = ""
+
+    if len(args) == 2:
+        layer_priority = args[1]
+        properties = '{"layer_priority":"' + layer_priority + '"}'
 
     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)
+    yocto_layer_create(layer_name, scripts_path, layer_output_dir, options.codedump, options.properties_file, properties)
 
 
 def yocto_layer_list_subcommand(args, usage_str):
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/7] scripts/lib/bsp/engine.py: add handling for JSON strings
@ 2013-01-18 18:27   ` tom.zanussi
  0 siblings, 0 replies; 16+ messages in thread
From: tom.zanussi @ 2013-01-18 18:27 UTC (permalink / raw)
  To: poky

From: Tom Zanussi <tom.zanussi@intel.com>

Normally pre-canned properties are supplied as JSON from a file, which
the user can specify using e.g. the -i option.

We can reuse that basic functionality for dedicated command-line
parameters by sythesizing a JSON string containing those param values
on the fly and passing that in instead.

This adds the ability for the common creation code to accept JSON
strings as well as JSON files.

Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
---
 scripts/lib/bsp/engine.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/bsp/engine.py b/scripts/lib/bsp/engine.py
index 7431860..aa26280 100644
--- a/scripts/lib/bsp/engine.py
+++ b/scripts/lib/bsp/engine.py
@@ -1387,6 +1387,9 @@ def yocto_common_create(machine, target, scripts_path, layer_output_dir, codedum
 
         properties = json.load(infile)
 
+    if properties_str and not properties:
+        properties = json.loads(properties_str)
+
     os.mkdir(layer_output_dir)
 
     context = create_context(machine, target, scripts_path)
@@ -1413,7 +1416,7 @@ def yocto_common_create(machine, target, scripts_path, layer_output_dir, codedum
     run_program_lines(program_lines, codedump)
 
 
-def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file):
+def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, properties_file, properties=""):
     """
     Create yocto layer
 
@@ -1424,13 +1427,13 @@ def yocto_layer_create(layer_name, scripts_path, layer_output_dir, codedump, pro
     properties_file - use values from this file if nonempty i.e no prompting
     properties - use values from this string if nonempty i.e no prompting
     """
-    yocto_common_create(layer_name, "layer", scripts_path, layer_output_dir, codedump, properties_file, False)
+    yocto_common_create(layer_name, "layer", scripts_path, layer_output_dir, codedump, properties_file, properties, 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):
+def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file, properties=None):
     """
     Create bsp
 
@@ -1443,7 +1446,7 @@ def yocto_bsp_create(machine, arch, scripts_path, bsp_output_dir, codedump, prop
     properties_file - use values from this file if nonempty i.e no prompting
     properties - use values from this string if nonempty i.e no prompting
     """
-    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file)
+    yocto_common_create(machine, arch, scripts_path, bsp_output_dir, codedump, properties_file, properties)
 
     print "\nNew %s BSP created in %s" % (arch, bsp_output_dir)
 
-- 
1.7.11.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-01-18 18:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11 20:43 [PATCH 0/7] new 'yocto-layer' tool for creating generic Yocto layers, v1 tom.zanussi
2013-01-18 18:27 ` tom.zanussi
2013-01-11 20:43 ` [PATCH 1/7] scripts/lib/bsp/engine.py: add yocto_layer_create() tom.zanussi
2013-01-18 18:27   ` tom.zanussi
2013-01-11 20:43 ` [PATCH 2/7] yocto-layer: new script tom.zanussi
2013-01-18 18:27   ` tom.zanussi
2013-01-11 20:43 ` [PATCH 3/7] yocto-layer: add help/usage tom.zanussi
2013-01-18 18:27   ` tom.zanussi
2013-01-11 20:43 ` [PATCH 4/7] yocto-layer: add 'layer' template data tom.zanussi
2013-01-18 18:27   ` tom.zanussi
2013-01-11 20:43 ` [PATCH 5/7] scripts/lib/bsp/engine.py: refactor bsp-creation code tom.zanussi
2013-01-18 18:27   ` tom.zanussi
2013-01-11 20:43 ` [PATCH 6/7] yocto-layer: add optional layer priority param tom.zanussi
2013-01-18 18:27   ` tom.zanussi
2013-01-11 20:43 ` [PATCH 7/7] scripts/lib/bsp/engine.py: add handling for JSON strings tom.zanussi
2013-01-18 18:27   ` tom.zanussi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.