[gnome-continuous-yocto/gnomeostree-3.28-rocko: 5194/8267] devtool/recipetill: npm install of devDependencies
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 5194/8267] devtool/recipetill: npm install of devDependencies
- Date: Sun, 17 Dec 2017 03:05:51 +0000 (UTC)
commit 6fa0fda1165f05adc9d971a8c873dbbd4ba18d6a
Author: Anders Darander <anders chargestorm se>
Date: Mon Mar 13 11:01:52 2017 +0100
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>
scripts/lib/devtool/standard.py | 3 +++
scripts/lib/recipetool/create.py | 6 ++++++
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 5bd498c..07c1400 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -150,6 +150,8 @@ def add(args, config, basepath, workspace):
extracmdopts += ' --src-subdir "%s"' % args.src_subdir
if args.autorev:
extracmdopts += ' -a'
+ if args.fetch_dev:
+ extracmdopts += ' --fetch-dev'
tempdir = tempfile.mkdtemp(prefix='devtool')
try:
@@ -1823,6 +1825,7 @@ def register_commands(subparsers, context):
group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true")
group.add_argument('--no-same-dir', help='Force build in a separate build directory',
action="store_true")
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')
+ parser_add.add_argument('--fetch-dev', help='For npm, also fetch devDependencies', action="store_true")
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('--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 1be3f14..648f2d6 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -599,6 +599,11 @@ def create_recipe(args):
lines_after.append('INSANE_SKIP_${PN} += "already-stripped"')
lines_after.append('')
+ if args.fetch_dev:
+ extravalues['fetchdev'] = True
+ else:
+ extravalues['fetchdev'] = None
+
# Find all plugins that want to register handlers
logger.debug('Loading recipe handlers')
raw_handlers = []
@@ -1134,6 +1139,7 @@ def register_commands(subparsers):
parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use',
metavar='SUBDIR')
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")
parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for
debugging)')
+ parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch
devDependencies')
parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)
parser_create.set_defaults(func=create_recipe)
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index 158029f..a215026 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -101,7 +101,7 @@ class NpmRecipeHandler(RecipeHandler):
extravalues['extrafiles']['lockdown.json'] = tmpfile
lines_before.append('NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json"')
- def _handle_dependencies(self, d, deps, optdeps, lines_before, srctree):
+ def _handle_dependencies(self, d, deps, optdeps, devdeps, lines_before, srctree):
import scriptutils
# If this isn't a single module we need to get the dependencies
# and add them to SRC_URI
@@ -115,6 +115,10 @@ class NpmRecipeHandler(RecipeHandler):
depdata = self.get_npm_data(dep, depver, d)
if self.check_npm_optional_dependency(depdata):
deplist[dep] = depdata
+ for dep, depver in devdeps.items():
+ depdata = self.get_npm_data(dep, depver, d)
+ if self.check_npm_optional_dependency(depdata):
+ deplist[dep] = depdata
for dep, depver in deps.items():
depdata = self.get_npm_data(dep, depver, d)
deplist[dep] = depdata
@@ -197,8 +201,9 @@ class NpmRecipeHandler(RecipeHandler):
if 'homepage' in data:
extravalues['HOMEPAGE'] = data['homepage']
- deps, optdeps = self.get_npm_package_dependencies(data)
- updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, lines_before,
srctree)
+ fetchdev = extravalues['fetchdev'] or None
+ deps, optdeps, devdeps = self.get_npm_package_dependencies(data, fetchdev)
+ updated = self._handle_dependencies(tinfoil.config_data, deps, optdeps, devdeps,
lines_before, srctree)
if updated:
# We need to redo the license stuff
self._replace_license_vars(srctree, lines_before, handled, extravalues,
tinfoil.config_data)
@@ -293,18 +298,26 @@ class NpmRecipeHandler(RecipeHandler):
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
# (split out from _getdependencies())
- def get_npm_package_dependencies(self, pdata):
+ def get_npm_package_dependencies(self, pdata, fetchdev):
dependencies = pdata.get('dependencies', {})
optionalDependencies = pdata.get('optionalDependencies', {})
dependencies.update(optionalDependencies)
+ if fetchdev:
+ devDependencies = pdata.get('devDependencies', {})
+ dependencies.update(devDependencies)
+ else:
+ devDependencies = {}
depsfound = {}
optdepsfound = {}
+ devdepsfound = {}
for dep in dependencies:
if dep in optionalDependencies:
optdepsfound[dep] = dependencies[dep]
+ elif dep in devDependencies:
+ devdepsfound[dep] = dependencies[dep]
else:
depsfound[dep] = dependencies[dep]
- return depsfound, optdepsfound
+ return depsfound, optdepsfound, devdepsfound
# FIXME this is effectively duplicated from lib/bb/fetch2/npm.py
# (split out from _getdependencies())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]