summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/devtool/__init__.py')
-rw-r--r--scripts/lib/devtool/__init__.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index b432e3d44e..e675133f63 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -259,3 +259,32 @@ def get_bbclassextend_targets(recipefile, pn):
259 elif variant in ['native', 'cross', 'crosssdk']: 259 elif variant in ['native', 'cross', 'crosssdk']:
260 targets.append('%s-%s' % (pn, variant)) 260 targets.append('%s-%s' % (pn, variant))
261 return targets 261 return targets
262
263def ensure_npm(config, basepath, fixed_setup=False):
264 """
265 Ensure that npm is available and either build it or show a
266 reasonable error message
267 """
268 tinfoil = setup_tinfoil(config_only=True, basepath=basepath)
269 try:
270 nativepath = tinfoil.config_data.getVar('STAGING_BINDIR_NATIVE', True)
271 finally:
272 tinfoil.shutdown()
273
274 npmpath = os.path.join(nativepath, 'npm')
275 if not os.path.exists(npmpath):
276 logger.info('Building nodejs-native')
277 try:
278 exec_build_env_command(config.init_path, basepath,
279 'bitbake -q nodejs-native', watch=True)
280 except bb.process.ExecutionError as e:
281 if "Nothing PROVIDES 'nodejs-native'" in e.stdout:
282 if fixed_setup:
283 msg = 'nodejs-native is required for npm but is not available within this SDK'
284 else:
285 msg = 'nodejs-native is required for npm but is not available - you will likely need to add a layer that provides nodejs'
286 raise DevtoolError(msg)
287 else:
288 raise
289 if not os.path.exists(npmpath):
290 raise DevtoolError('Built nodejs-native but npm binary still could not be found at %s' % npmpath)