diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-12-22 17:03:09 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-28 09:25:13 +0000 |
commit | ee0d5a1080d3699638304afd66caabb199b3aa84 (patch) | |
tree | aaaa0845ea306ae89045a51f882d655d6a9fd1f3 /scripts | |
parent | 0d8751fbab820c4f157da941b03d29f17dd62b11 (diff) | |
download | poky-ee0d5a1080d3699638304afd66caabb199b3aa84.tar.gz |
devtool: add: allow source tree to be omitted
Assuming we're fetching source remotely (from a URI) we can default the
source tree that will be extracted from it to a "sources" directory
under the workspace in order to save the user specifying it if they
don't have a preferred location.
(From OE-Core rev: ffdad964c7271972e4b067e4898bf7c338c25b68)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/devtool/standard.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 195da1a68c..b129db3e74 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -49,7 +49,12 @@ def add(args, config, basepath, workspace): | |||
49 | if '/' in args.recipename: | 49 | if '/' in args.recipename: |
50 | raise DevtoolError('"/" is not a valid character in recipe names') | 50 | raise DevtoolError('"/" is not a valid character in recipe names') |
51 | 51 | ||
52 | srctree = os.path.abspath(args.srctree) | 52 | if args.srctree: |
53 | srctree = os.path.abspath(args.srctree) | ||
54 | else: | ||
55 | srctree = get_default_srctree(config, args.recipename) | ||
56 | logger.info('Using default source tree path %s' % srctree) | ||
57 | |||
53 | if os.path.exists(srctree): | 58 | if os.path.exists(srctree): |
54 | if args.fetch: | 59 | if args.fetch: |
55 | if not os.path.isdir(srctree): | 60 | if not os.path.isdir(srctree): |
@@ -61,8 +66,16 @@ def add(args, config, basepath, workspace): | |||
61 | "it already exists and is non-empty" % | 66 | "it already exists and is non-empty" % |
62 | srctree) | 67 | srctree) |
63 | elif not args.fetch: | 68 | elif not args.fetch: |
64 | raise DevtoolError("Specified source tree %s could not be found" % | 69 | if args.srctree: |
65 | srctree) | 70 | raise DevtoolError("Specified source tree %s could not be found" % |
71 | args.srctree) | ||
72 | else: | ||
73 | raise DevtoolError("No source tree exists at default path %s - " | ||
74 | "either create and populate this directory, " | ||
75 | "or specify a path to a source tree, or use " | ||
76 | "the -f/--fetch option to fetch source code " | ||
77 | "and extract it to the source directory" % | ||
78 | srctree) | ||
66 | 79 | ||
67 | recipedir = os.path.join(config.workspace_path, 'recipes', args.recipename) | 80 | recipedir = os.path.join(config.workspace_path, 'recipes', args.recipename) |
68 | bb.utils.mkdirhier(recipedir) | 81 | bb.utils.mkdirhier(recipedir) |
@@ -1168,13 +1181,22 @@ def edit_recipe(args, config, basepath, workspace): | |||
1168 | 1181 | ||
1169 | return 0 | 1182 | return 0 |
1170 | 1183 | ||
1184 | def get_default_srctree(config, recipename=''): | ||
1185 | """Get the default srctree path""" | ||
1186 | srctreeparent = config.get('General', 'default_source_parent_dir', config.workspace_path) | ||
1187 | if recipename: | ||
1188 | return os.path.join(srctreeparent, 'sources', recipename) | ||
1189 | else: | ||
1190 | return os.path.join(srctreeparent, 'sources') | ||
1171 | 1191 | ||
1172 | def register_commands(subparsers, context): | 1192 | def register_commands(subparsers, context): |
1173 | """Register devtool subcommands from this plugin""" | 1193 | """Register devtool subcommands from this plugin""" |
1194 | |||
1195 | defsrctree = get_default_srctree(context.config) | ||
1174 | parser_add = subparsers.add_parser('add', help='Add a new recipe', | 1196 | parser_add = subparsers.add_parser('add', help='Add a new recipe', |
1175 | description='Adds a new recipe to the workspace to build a specified source tree. Can optionally fetch a remote URI and unpack it to create the source tree.') | 1197 | description='Adds a new recipe to the workspace to build a specified source tree. Can optionally fetch a remote URI and unpack it to create the source tree.') |
1176 | parser_add.add_argument('recipename', help='Name for new recipe to add (just name - no version, path or extension)') | 1198 | parser_add.add_argument('recipename', help='Name for new recipe to add (just name - no version, path or extension)') |
1177 | parser_add.add_argument('srctree', help='Path to external source tree') | 1199 | parser_add.add_argument('srctree', nargs='?', help='Path to external source tree. If not specified, a subdirectory of %s will be used.' % defsrctree) |
1178 | group = parser_add.add_mutually_exclusive_group() | 1200 | group = parser_add.add_mutually_exclusive_group() |
1179 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") | 1201 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") |
1180 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") | 1202 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") |