diff options
author | Anders Darander <anders@chargestorm.se> | 2017-03-13 11:01:52 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-22 11:35:20 +0000 |
commit | 6fa0fda1165f05adc9d971a8c873dbbd4ba18d6a (patch) | |
tree | 2980ee319648c05dbe042860d007b1da23dbd342 | |
parent | 2b52d7ebc0a1dea68bfad8dcb048778ab00c631d (diff) | |
download | poky-6fa0fda1165f05adc9d971a8c873dbbd4ba18d6a.tar.gz |
devtool/recipetill: npm install of devDependencies
Web applications built using e.g. angular2, usually requires that the
packages in devDependencies are available.
Thus, add an option '--fetch-dev' to both devtool add and recipetool, to
add npm packages in devDependencies to DEPENDS.
(From OE-Core rev: f246f820d53b459596fde6758a09f7a0d7db7c4c)
Signed-off-by: Anders Darander <anders@chargestorm.se>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/devtool/standard.py | 3 | ||||
-rw-r--r-- | scripts/lib/recipetool/create.py | 6 | ||||
-rw-r--r-- | scripts/lib/recipetool/create_npm.py | 23 |
3 files changed, 27 insertions, 5 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 5bd498c933..07c1400388 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -150,6 +150,8 @@ def add(args, config, basepath, workspace): | |||
150 | extracmdopts += ' --src-subdir "%s"' % args.src_subdir | 150 | extracmdopts += ' --src-subdir "%s"' % args.src_subdir |
151 | if args.autorev: | 151 | if args.autorev: |
152 | extracmdopts += ' -a' | 152 | extracmdopts += ' -a' |
153 | if args.fetch_dev: | ||
154 | extracmdopts += ' --fetch-dev' | ||
153 | 155 | ||
154 | tempdir = tempfile.mkdtemp(prefix='devtool') | 156 | tempdir = tempfile.mkdtemp(prefix='devtool') |
155 | try: | 157 | try: |
@@ -1823,6 +1825,7 @@ def register_commands(subparsers, context): | |||
1823 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") | 1825 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") |
1824 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") | 1826 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") |
1825 | parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree (deprecated - pass as positional argument instead)', metavar='URI') | 1827 | parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree (deprecated - pass as positional argument instead)', metavar='URI') |
1828 | parser_add.add_argument('--fetch-dev', help='For npm, also fetch devDependencies', action="store_true") | ||
1826 | parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)') | 1829 | parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)') |
1827 | parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true") | 1830 | parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true") |
1828 | parser_add.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true") | 1831 | parser_add.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true") |
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 1be3f14f86..648f2d66fc 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -599,6 +599,11 @@ def create_recipe(args): | |||
599 | lines_after.append('INSANE_SKIP_${PN} += "already-stripped"') | 599 | lines_after.append('INSANE_SKIP_${PN} += "already-stripped"') |
600 | lines_after.append('') | 600 | lines_after.append('') |
601 | 601 | ||
602 | if args.fetch_dev: | ||
603 | extravalues['fetchdev'] = True | ||
604 | else: | ||
605 | extravalues['fetchdev'] = None | ||
606 | |||
602 | # Find all plugins that want to register handlers | 607 | # Find all plugins that want to register handlers |
603 | logger.debug('Loading recipe handlers') | 608 | logger.debug('Loading recipe handlers') |
604 | raw_handlers = [] | 609 | raw_handlers = [] |
@@ -1134,6 +1139,7 @@ def register_commands(subparsers): | |||
1134 | parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') | 1139 | parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR') |
1135 | parser_create.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true") | 1140 | parser_create.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true") |
1136 | parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') | 1141 | parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') |
1142 | parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies') | ||
1137 | parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS) | 1143 | parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS) |
1138 | parser_create.set_defaults(func=create_recipe) | 1144 | parser_create.set_defaults(func=create_recipe) |
1139 | 1145 | ||
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index 158029fa04..a21502679e 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py | |||
@@ -101,7 +101,7 @@ class NpmRecipeHandler(RecipeHandler): | |||
101 | extravalues['extrafiles']['lockdown.json'] = tmpfile | 101 | extravalues['extrafiles']['lockdown.json'] = tmpfile |
102 | lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"') | 102 | lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"') |
103 | 103 | ||
104 | def _handle_dependencies(self, d, deps, optdeps, lines_before, srctree): | 104 | def _handle_dependencies(self, d, deps, optdeps, devdeps, lines_before, srctree): |
105 | import scriptutils | 105 | import scriptutils |
106 | # If this isn't a single module we need to get the dependencies | 106 | # If this isn't a single module we need to get the dependencies |
107 | # and add them to SRC_URI | 107 | # and add them to SRC_URI |
@@ -115,6 +115,10 @@ class NpmRecipeHandler(RecipeHandler): | |||
115 | depdata = self.get_npm_data(dep, depver, d) | 115 | depdata = self.get_npm_data(dep, depver, d) |
116 | if self.check_npm_optional_dependency(depdata): | 116 | if self.check_npm_optional_dependency(depdata): |
117 | deplist[dep] = depdata | 117 | deplist[dep] = depdata |
118 | for dep, depver in devdeps.items(): | ||
119 | depdata = self.get_npm_data(dep, depver, d) | ||
120 | if self.check_npm_optional_dependency(depdata): | ||
121 | deplist[dep] = depdata | ||
118 | for dep, depver in deps.items(): | 122 | for dep, depver in deps.items(): |
119 | depdata = self.get_npm_data(dep, depver, d) | 123 | depdata = self.get_npm_data(dep, depver, d) |
120 | deplist[dep] = depdata | 124 | deplist[dep] = depdata |
@@ -197,8 +201,9 @@ class NpmRecipeHandler(RecipeHandler): | |||
197 | if 'homepage' in data: | 201 | if 'homepage' in data: |
198 | extravalues['HOMEPAGE'] = data['homepage'] | 202 | extravalues['HOMEPAGE'] = data['homepage'] |
199 | 203 | ||
200 | deps, optdeps = self.get_npm_package_dependencies(data) | 204 | fetchdev = extravalues['fetchdev'] or None |
201 | updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, lines_before, srctree) | 205 | deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev) |
206 | updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, devdeps, lines_before, srctree) | ||
202 | if updated: | 207 | if updated: |
203 | # We need to redo the license stuff | 208 | # We need to redo the license stuff |
204 | self._replace_license_vars(srctree, lines_before, handled, extravalues, tinfoil.config_data) | 209 | self._replace_license_vars(srctree, lines_before, handled, extravalues, tinfoil.config_data) |
@@ -293,18 +298,26 @@ class NpmRecipeHandler(RecipeHandler): | |||
293 | 298 | ||
294 | # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py | 299 | # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py |
295 | # (split out from _getdependencies()) | 300 | # (split out from _getdependencies()) |
296 | def get_npm_package_dependencies(self, pdata): | 301 | def get_npm_package_dependencies(self, pdata, fetchdev): |
297 | dependencies = pdata.get('dependencies', {}) | 302 | dependencies = pdata.get('dependencies', {}) |
298 | optionalDependencies = pdata.get('optionalDependencies', {}) | 303 | optionalDependencies = pdata.get('optionalDependencies', {}) |
299 | dependencies.update(optionalDependencies) | 304 | dependencies.update(optionalDependencies) |
305 | if fetchdev: | ||
306 | devDependencies = pdata.get('devDependencies', {}) | ||
307 | dependencies.update(devDependencies) | ||
308 | else: | ||
309 | devDependencies = {} | ||
300 | depsfound = {} | 310 | depsfound = {} |
301 | optdepsfound = {} | 311 | optdepsfound = {} |
312 | devdepsfound = {} | ||
302 | for dep in dependencies: | 313 | for dep in dependencies: |
303 | if dep in optionalDependencies: | 314 | if dep in optionalDependencies: |
304 | optdepsfound[dep] = dependencies[dep] | 315 | optdepsfound[dep] = dependencies[dep] |
316 | elif dep in devDependencies: | ||
317 | devdepsfound[dep] = dependencies[dep] | ||
305 | else: | 318 | else: |
306 | depsfound[dep] = dependencies[dep] | 319 | depsfound[dep] = dependencies[dep] |
307 | return depsfound, optdepsfound | 320 | return depsfound, optdepsfound, devdepsfound |
308 | 321 | ||
309 | # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py | 322 | # FIXME this is effectively duplicated from lib/bb/fetch2/npm.py |
310 | # (split out from _getdependencies()) | 323 | # (split out from _getdependencies()) |