public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 11/14] devtool: add: support adding a native variant
Date: Thu,  7 Jan 2016 00:15:52 +1300	[thread overview]
Message-ID: <de798a8006fabb828f0f0fb47758c8f0d721bd99.1452078721.git.paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <cover.1452078721.git.paul.eggleton@linux.intel.com>
In-Reply-To: <cover.1452078721.git.paul.eggleton@linux.intel.com>

Sometimes you need to build a variant of a recipe for the build
host as well as for the target (i.e. BBCLASSEXTEND = "native"); add a
 --also-native command line option to "recipetool create" that enables
this and plumb it through from an identical option for "devtool add".

(We could conceivably do the same for nativesdk, but I felt it might be
confusing within the context of the extensible SDK, where nativesdk
isn't really relevant to the user.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 scripts/lib/devtool/standard.py  |  3 +++
 scripts/lib/recipetool/create.py | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 741f0ea..7ef0ab8 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -139,6 +139,8 @@ def add(args, config, basepath, workspace):
         extracmdopts += ' -V %s' % args.version
     if args.binary:
         extracmdopts += ' -b'
+    if args.also_native:
+        extracmdopts += ' --also-native'
 
     tempdir = tempfile.mkdtemp(prefix='devtool')
     try:
@@ -1307,6 +1309,7 @@ def register_commands(subparsers, context):
     parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
     parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true")
     parser_add.add_argument('--binary', '-b', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure). Useful with binary packages e.g. RPMs.', action='store_true')
+    parser_add.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
     parser_add.set_defaults(func=add)
 
     parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe',
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 775be42..4f95d7e 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -252,8 +252,14 @@ def create_recipe(args):
     if args.name:
         pn = args.name
         if args.name.endswith('-native'):
+            if args.also_native:
+                logger.error('--also-native cannot be specified for a recipe named *-native (*-native denotes a recipe that is already only for native) - either remove the -native suffix from the name or drop --also-native')
+                sys.exit(1)
             classes.append('native')
         elif args.name.startswith('nativesdk-'):
+            if args.also_native:
+                logger.error('--also-native cannot be specified for a recipe named nativesdk-* (nativesdk-* denotes a recipe that is already only for nativesdk)')
+                sys.exit(1)
             classes.append('nativesdk')
 
     if pv and pv not in 'git svn hg'.split():
@@ -393,6 +399,22 @@ def create_recipe(args):
                 line = re.sub('"[^+]*\+', '"%s+' % realpv, line)
         lines_before.append(line)
 
+    if args.also_native:
+        lines = lines_after
+        lines_after = []
+        bbclassextend = None
+        for line in lines:
+            if line.startswith('BBCLASSEXTEND ='):
+                splitval = line.split('"')
+                if len(splitval) > 1:
+                    bbclassextend = splitval[1].split()
+                    if not 'native' in bbclassextend:
+                        bbclassextend.insert(0, 'native')
+                line = 'BBCLASSEXTEND = "%s"' % ' '.join(bbclassextend)
+            lines_after.append(line)
+        if not bbclassextend:
+            lines_after.append('BBCLASSEXTEND = "native"')
+
     outlines = []
     outlines.extend(lines_before)
     if classes:
@@ -591,5 +613,6 @@ def register_commands(subparsers):
     parser_create.add_argument('-N', '--name', help='Name to use within recipe (PN)')
     parser_create.add_argument('-V', '--version', help='Version to use within recipe (PV)')
     parser_create.add_argument('-b', '--binary', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure)', action='store_true')
+    parser_create.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
     parser_create.set_defaults(func=create_recipe)
 
-- 
2.5.0



  parent reply	other threads:[~2016-01-06 11:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 11:15 [PATCH 00/14] Extensible SDK / devtool / recipetool improvements Paul Eggleton
2016-01-06 11:15 ` [PATCH 01/14] scripts/oe-publish-sdk: add missing call to git update-server-info Paul Eggleton
2016-01-06 11:15 ` [PATCH 02/14] classes/populate_sdk_ext: fix cascading from preparation failure Paul Eggleton
2016-01-06 11:15 ` [PATCH 03/14] classes/populate_sdk_ext: disable signature warnings Paul Eggleton
2016-01-06 11:15 ` [PATCH 04/14] devtool: sdk-update: fix not using updateserver config file option Paul Eggleton
2016-01-06 11:15 ` [PATCH 05/14] devtool: sdk-update: fix metadata update step Paul Eggleton
2016-01-06 11:15 ` [PATCH 06/14] devtool: sdk-update: fix error checking Paul Eggleton
2016-01-06 11:15 ` [PATCH 07/14] devtool: sdk-update: add option to skip preparation step Paul Eggleton
2016-01-06 11:15 ` [PATCH 08/14] recipetool: create: lower case name when determining from filename Paul Eggleton
2016-01-06 11:15 ` [PATCH 09/14] recipetool: create: support creating standalone native/nativesdk recipes Paul Eggleton
2016-01-06 11:15 ` [PATCH 10/14] devtool: reset: do clean for multiple recipes at once with -a Paul Eggleton
2016-01-06 11:15 ` Paul Eggleton [this message]
2016-01-06 11:15 ` [PATCH 12/14] devtool: refactor code for getting local recipe file Paul Eggleton
2016-01-06 11:15 ` [PATCH 13/14] devtool: reset: support recipes with BBCLASSEXTEND Paul Eggleton
2016-01-06 11:15 ` [PATCH 14/14] devtool: build: support using BBCLASSEXTENDed names Paul Eggleton

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=de798a8006fabb828f0f0fb47758c8f0d721bd99.1452078721.git.paul.eggleton@linux.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

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

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