diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-01-23 00:59:58 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-24 09:40:33 +0000 |
commit | 50e40fc91f74cce464dc5c7556550cfe91b95c7c (patch) | |
tree | 755bb0f3063b20d3590c66c84e0c2fc3a2e7eaa1 | |
parent | 7e1691de0aa6aae6f86143b581700dd77c72afca (diff) | |
download | poky-50e40fc91f74cce464dc5c7556550cfe91b95c7c.tar.gz |
devtool / recipetool: support specifying a subdirectory within the fetched source
Sometimes you don't want to build an entire project, just a subdirectory
of it; add a --src-subdir option to make that easier. (We still look for
a single subdirectory in what gets unpacked, e.g. what you might find
within a tarball, so whatever you specify with this option is added onto
the end of that.)
(From OE-Core rev: 59682d78f95732e014f78f13e0a05f843860d9bb)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/devtool/standard.py | 6 | ||||
-rw-r--r-- | scripts/lib/recipetool/create.py | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 5390f51095..f19de27a86 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -141,6 +141,8 @@ def add(args, config, basepath, workspace): | |||
141 | extracmdopts += ' -b' | 141 | extracmdopts += ' -b' |
142 | if args.also_native: | 142 | if args.also_native: |
143 | extracmdopts += ' --also-native' | 143 | extracmdopts += ' --also-native' |
144 | if args.src_subdir: | ||
145 | extracmdopts += ' --src-subdir "%s"' % args.src_subdir | ||
144 | 146 | ||
145 | tempdir = tempfile.mkdtemp(prefix='devtool') | 147 | tempdir = tempfile.mkdtemp(prefix='devtool') |
146 | try: | 148 | try: |
@@ -208,6 +210,9 @@ def add(args, config, basepath, workspace): | |||
208 | if not rd: | 210 | if not rd: |
209 | return 1 | 211 | return 1 |
210 | 212 | ||
213 | if args.src_subdir: | ||
214 | srctree = os.path.join(srctree, args.src_subdir) | ||
215 | |||
211 | bb.utils.mkdirhier(os.path.dirname(appendfile)) | 216 | bb.utils.mkdirhier(os.path.dirname(appendfile)) |
212 | with open(appendfile, 'w') as f: | 217 | with open(appendfile, 'w') as f: |
213 | f.write('inherit externalsrc\n') | 218 | f.write('inherit externalsrc\n') |
@@ -1308,6 +1313,7 @@ def register_commands(subparsers, context): | |||
1308 | parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true") | 1313 | parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true") |
1309 | 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') | 1314 | 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') |
1310 | 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') | 1315 | 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') |
1316 | parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') | ||
1311 | parser_add.set_defaults(func=add) | 1317 | parser_add.set_defaults(func=add) |
1312 | 1318 | ||
1313 | parser_modify = subparsers.add_parser('modify', help='Modify the source for an existing recipe', | 1319 | 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 43861ee96b..9c3a63d155 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -324,6 +324,12 @@ def create_recipe(args): | |||
324 | srcuri = '' | 324 | srcuri = '' |
325 | srctree = args.source | 325 | srctree = args.source |
326 | 326 | ||
327 | if args.src_subdir: | ||
328 | srcsubdir = os.path.join(srcsubdir, args.src_subdir) | ||
329 | srctree_use = os.path.join(srctree, args.src_subdir) | ||
330 | else: | ||
331 | srctree_use = srctree | ||
332 | |||
327 | if args.outfile and os.path.isdir(args.outfile): | 333 | if args.outfile and os.path.isdir(args.outfile): |
328 | outfile = None | 334 | outfile = None |
329 | outdir = args.outfile | 335 | outdir = args.outfile |
@@ -343,7 +349,7 @@ def create_recipe(args): | |||
343 | lines_before.append('# (Feel free to remove these comments when editing.)') | 349 | lines_before.append('# (Feel free to remove these comments when editing.)') |
344 | lines_before.append('#') | 350 | lines_before.append('#') |
345 | 351 | ||
346 | licvalues = guess_license(srctree) | 352 | licvalues = guess_license(srctree_use) |
347 | lic_files_chksum = [] | 353 | lic_files_chksum = [] |
348 | if licvalues: | 354 | if licvalues: |
349 | licenses = [] | 355 | licenses = [] |
@@ -472,7 +478,7 @@ def create_recipe(args): | |||
472 | 478 | ||
473 | extravalues = {} | 479 | extravalues = {} |
474 | for handler in handlers: | 480 | for handler in handlers: |
475 | handler.process(srctree, classes, lines_before, lines_after, handled, extravalues) | 481 | handler.process(srctree_use, classes, lines_before, lines_after, handled, extravalues) |
476 | 482 | ||
477 | if not realpv: | 483 | if not realpv: |
478 | realpv = extravalues.get('PV', None) | 484 | realpv = extravalues.get('PV', None) |
@@ -759,5 +765,6 @@ def register_commands(subparsers): | |||
759 | parser_create.add_argument('-V', '--version', help='Version to use within recipe (PV)') | 765 | parser_create.add_argument('-V', '--version', help='Version to use within recipe (PV)') |
760 | 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') | 766 | 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') |
761 | 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') | 767 | 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') |
768 | parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') | ||
762 | parser_create.set_defaults(func=create_recipe) | 769 | parser_create.set_defaults(func=create_recipe) |
763 | 770 | ||