summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/devtool/__init__.py18
-rw-r--r--scripts/lib/devtool/standard.py30
-rw-r--r--scripts/lib/devtool/upgrade.py20
3 files changed, 36 insertions, 32 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index 3ea38028d4..07a3636e9b 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -152,3 +152,21 @@ def check_workspace_recipe(workspace, pn, checksrc=True):
152 raise DevtoolError("Source tree %s for recipe %s does not exist" % (srctree, pn)) 152 raise DevtoolError("Source tree %s for recipe %s does not exist" % (srctree, pn))
153 if not os.listdir(srctree): 153 if not os.listdir(srctree):
154 raise DevtoolError("Source tree %s for recipe %s is empty" % (srctree, pn)) 154 raise DevtoolError("Source tree %s for recipe %s is empty" % (srctree, pn))
155
156def use_external_build(same_dir, no_same_dir, d):
157 """
158 Determine if we should use B!=S (separate build and source directories) or not
159 """
160 b_is_s = True
161 if no_same_dir:
162 logger.info('Using separate build directory since --no-same-dir specified')
163 b_is_s = False
164 elif same_dir:
165 logger.info('Using source tree as build directory since --same-dir specified')
166 elif bb.data.inherits_class('autotools-brokensep', d):
167 logger.info('Using source tree as build directory since recipe inherits autotools-brokensep')
168 elif d.getVar('B', True) == os.path.abspath(d.getVar('S', True)):
169 logger.info('Using source tree as build directory since that would be the default for this recipe')
170 else:
171 b_is_s = False
172 return b_is_s
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index ec21b3c139..700a56b4ed 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -25,7 +25,7 @@ import logging
25import argparse 25import argparse
26import scriptutils 26import scriptutils
27import errno 27import errno
28from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, DevtoolError 28from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, DevtoolError
29from devtool import parse_recipe 29from devtool import parse_recipe
30 30
31logger = logging.getLogger('devtool') 31logger = logging.getLogger('devtool')
@@ -107,17 +107,26 @@ def add(args, config, basepath, workspace):
107 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree) 107 (stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
108 initial_rev = stdout.rstrip() 108 initial_rev = stdout.rstrip()
109 109
110 tinfoil = setup_tinfoil(config_only=True)
111 rd = oe.recipeutils.parse_recipe(recipefile, None, tinfoil.config_data)
112 if not rd:
113 return 1
114
110 appendfile = os.path.join(appendpath, '%s.bbappend' % bp) 115 appendfile = os.path.join(appendpath, '%s.bbappend' % bp)
111 with open(appendfile, 'w') as f: 116 with open(appendfile, 'w') as f:
112 f.write('inherit externalsrc\n') 117 f.write('inherit externalsrc\n')
113 f.write('EXTERNALSRC = "%s"\n' % srctree) 118 f.write('EXTERNALSRC = "%s"\n' % srctree)
114 if args.same_dir: 119
120 b_is_s = use_external_build(args.same_dir, args.no_same_dir, rd)
121 if b_is_s:
115 f.write('EXTERNALSRC_BUILD = "%s"\n' % srctree) 122 f.write('EXTERNALSRC_BUILD = "%s"\n' % srctree)
116 if initial_rev: 123 if initial_rev:
117 f.write('\n# initial_rev: %s\n' % initial_rev) 124 f.write('\n# initial_rev: %s\n' % initial_rev)
118 125
119 _add_md5(config, args.recipename, appendfile) 126 _add_md5(config, args.recipename, appendfile)
120 127
128 tinfoil.shutdown()
129
121 return 0 130 return 0
122 131
123 132
@@ -483,18 +492,7 @@ def modify(args, config, basepath, workspace):
483 f.write('# NOTE: We use pn- overrides here to avoid affecting multiple variants in the case where the recipe uses BBCLASSEXTEND\n') 492 f.write('# NOTE: We use pn- overrides here to avoid affecting multiple variants in the case where the recipe uses BBCLASSEXTEND\n')
484 f.write('EXTERNALSRC_pn-%s = "%s"\n' % (args.recipename, srctree)) 493 f.write('EXTERNALSRC_pn-%s = "%s"\n' % (args.recipename, srctree))
485 494
486 b_is_s = True 495 b_is_s = use_external_build(args.same_dir, args.no_same_dir, rd)
487 if args.no_same_dir:
488 logger.info('using separate build directory since --no-same-dir specified')
489 b_is_s = False
490 elif args.same_dir:
491 logger.info('using source tree as build directory since --same-dir specified')
492 elif bb.data.inherits_class('autotools-brokensep', rd):
493 logger.info('using source tree as build directory since original recipe inherits autotools-brokensep')
494 elif rd.getVar('B', True) == s:
495 logger.info('using source tree as build directory since that is the default for this recipe')
496 else:
497 b_is_s = False
498 if b_is_s: 496 if b_is_s:
499 f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (args.recipename, srctree)) 497 f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (args.recipename, srctree))
500 498
@@ -876,7 +874,9 @@ def register_commands(subparsers, context):
876 description='Adds a new recipe') 874 description='Adds a new recipe')
877 parser_add.add_argument('recipename', help='Name for new recipe to add') 875 parser_add.add_argument('recipename', help='Name for new recipe to add')
878 parser_add.add_argument('srctree', help='Path to external source tree') 876 parser_add.add_argument('srctree', help='Path to external source tree')
879 parser_add.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") 877 group = parser_add.add_mutually_exclusive_group()
878 group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true")
879 group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true")
880 parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree', metavar='URI') 880 parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree', metavar='URI')
881 parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)') 881 parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
882 parser_add.set_defaults(func=add) 882 parser_add.set_defaults(func=add)
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 86443b0735..6c1dfee3fe 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -29,7 +29,7 @@ import errno
29import bb 29import bb
30import oe.recipeutils 30import oe.recipeutils
31from devtool import standard 31from devtool import standard
32from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe 32from devtool import exec_build_env_command, setup_tinfoil, DevtoolError, parse_recipe, use_external_build
33 33
34logger = logging.getLogger('devtool') 34logger = logging.getLogger('devtool')
35 35
@@ -126,21 +126,6 @@ def _rename_recipe_files(bpn, oldpv, newpv, path):
126 _rename_recipe_dirs(oldpv, newpv, path) 126 _rename_recipe_dirs(oldpv, newpv, path)
127 return _rename_recipe_file(bpn, oldpv, newpv, path) 127 return _rename_recipe_file(bpn, oldpv, newpv, path)
128 128
129def _use_external_build(same_dir, no_same_dir, d):
130 b_is_s = True
131 if no_same_dir:
132 logger.info('using separate build directory since --no-same-dir specified')
133 b_is_s = False
134 elif same_dir:
135 logger.info('using source tree as build directory since --same-dir specified')
136 elif bb.data.inherits_class('autotools-brokensep', d):
137 logger.info('using source tree as build directory since original recipe inherits autotools-brokensep')
138 elif d.getVar('B', True) == os.path.abspath(d.getVar('S', True)):
139 logger.info('using source tree as build directory since that is the default for this recipe')
140 else:
141 b_is_s = False
142 return b_is_s
143
144def _write_append(rc, srctree, same_dir, no_same_dir, rev, workspace, d): 129def _write_append(rc, srctree, same_dir, no_same_dir, rev, workspace, d):
145 """Writes an append file""" 130 """Writes an append file"""
146 if not os.path.exists(rc): 131 if not os.path.exists(rc):
@@ -161,7 +146,8 @@ def _write_append(rc, srctree, same_dir, no_same_dir, rev, workspace, d):
161 f.write(('# NOTE: We use pn- overrides here to avoid affecting' 146 f.write(('# NOTE: We use pn- overrides here to avoid affecting'
162 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n')) 147 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n'))
163 f.write('EXTERNALSRC_pn-%s = "%s"\n' % (pn, srctree)) 148 f.write('EXTERNALSRC_pn-%s = "%s"\n' % (pn, srctree))
164 if _use_external_build(same_dir, no_same_dir, d): 149 b_is_s = use_external_build(same_dir, no_same_dir, d)
150 if b_is_s:
165 f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (pn, srctree)) 151 f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (pn, srctree))
166 if rev: 152 if rev:
167 f.write('\n# initial_rev: %s\n' % rev) 153 f.write('\n# initial_rev: %s\n' % rev)