|
| 1 | +(async () => { |
| 2 | + const spawnSync = require('child_process').spawnSync |
| 3 | + |
| 4 | + function spawnSyncOrThrow() { |
| 5 | + const result = spawnSync(...arguments) |
| 6 | + if (result.error) { |
| 7 | + throw result.error |
| 8 | + } else if (result.status !== 0) { |
| 9 | + const args = Array.from(arguments) |
| 10 | + throw new Error(args[0] + ' ' + args[1].join(' ') + ': exit status=' + result.status) |
| 11 | + } |
| 12 | + return result |
| 13 | + } |
| 14 | + |
| 15 | + if (spawnSync('rustup', ['--version'], { stdio: 'inherit' }).status !== 0) { |
| 16 | + throw new Error('The build process for this framework is intended for a Rust user (via rustup).' + |
| 17 | + 'If you want to install Rust, visit https://www.rust-lang.org/.' + |
| 18 | + 'Otherwise, you can run the benchmark with the provided `.js` and `.wasm` files.' + |
| 19 | + '(Note that other dependencies (require by this framework) will be installed automatically by "npm run build-prod-force")') |
| 20 | + } |
| 21 | + |
| 22 | + spawnSyncOrThrow('rustup', ['toolchain', 'install', 'nightly'], { stdio: 'inherit' }) |
| 23 | + spawnSyncOrThrow('rustup', ['target', 'add', 'wasm32-unknown-unknown', '--toolchain', 'nightly'], { stdio: 'inherit' }) |
| 24 | + |
| 25 | + if (spawnSync('wasm-bindgen', ['--version'], { stdio: 'inherit' }).status !== 0) { |
| 26 | + spawnSyncOrThrow('cargo', ['install', 'wasm-bindgen-cli', '--version', '0.2.29'], { stdio: 'inherit' }) |
| 27 | + } |
| 28 | + |
| 29 | + if (spawnSync('simi', ['--version'], { stdio: 'inherit' }).status !== 0) { |
| 30 | + spawnSyncOrThrow('cargo', ['install', 'simi-cli'], { stdio: 'inherit' }) |
| 31 | + } |
| 32 | + |
| 33 | + const build_mode = process.argv[2] |
| 34 | + spawnSyncOrThrow('simi', ['build', build_mode], { stdio: 'inherit' }) |
| 35 | +})().catch(console.dir) |
0 commit comments