(tool, directory)
| 1439 | |
| 1440 | # npm install in Emscripten root directory |
| 1441 | def emscripten_npm_install(tool, directory): |
| 1442 | node_tool = find_latest_installed_tool('node') |
| 1443 | if not node_tool: |
| 1444 | npm_fallback = shutil.which('npm') |
| 1445 | if not npm_fallback: |
| 1446 | errlog('Failed to find npm command') |
| 1447 | errlog(f'Running "npm ci" in installed Emscripten root directory {tool.installation_path()} is required') |
| 1448 | errlog('Please install node.js first') |
| 1449 | return False |
| 1450 | node_path = os.path.dirname(npm_fallback) |
| 1451 | else: |
| 1452 | node_path = os.path.join(node_tool.installation_path(), 'bin') |
| 1453 | |
| 1454 | npm = os.path.join(node_path, 'npm' + ('.cmd' if WINDOWS else '')) |
| 1455 | env = os.environ.copy() |
| 1456 | env["PATH"] = node_path + os.pathsep + env["PATH"] |
| 1457 | print('Running post-install step: npm ci ...') |
| 1458 | try: |
| 1459 | subprocess.check_output( |
| 1460 | [npm, 'ci', '--production'], |
| 1461 | cwd=directory, stderr=subprocess.STDOUT, env=env, |
| 1462 | universal_newlines=True) |
| 1463 | except subprocess.CalledProcessError as e: |
| 1464 | errlog('Error running %s:\n%s' % (e.cmd, e.output)) |
| 1465 | return False |
| 1466 | |
| 1467 | print('Done running: npm ci') |
| 1468 | |
| 1469 | if os.path.isfile(os.path.join(directory, 'bootstrap.py')): |
| 1470 | try: |
| 1471 | subprocess.check_output([sys.executable, os.path.join(directory, 'bootstrap.py')], |
| 1472 | cwd=directory, stderr=subprocess.STDOUT, env=env, |
| 1473 | universal_newlines=True) |
| 1474 | except subprocess.CalledProcessError as e: |
| 1475 | errlog('Error running %s:\n%s' % (e.cmd, e.output)) |
| 1476 | return False |
| 1477 | |
| 1478 | print('Done running: Emscripten bootstrap') |
| 1479 | return True |
| 1480 | |
| 1481 | |
| 1482 | # Binaryen build scripts: |
no test coverage detected