|
9 | 9 |
|
10 | 10 | require("dotenv").config({path: "./.perspectiverc"}); |
11 | 11 |
|
12 | | -const {execute, execute_throw} = require("./script_utils.js"); |
| 12 | +const {execute_throw} = require("./script_utils.js"); |
13 | 13 | const {emscripten} = require("../package.json"); |
| 14 | +const path = require("path"); |
| 15 | +const os = require("os"); |
| 16 | +const fs = require("fs"); |
| 17 | + |
| 18 | +function base() { |
| 19 | + return path.join(__dirname, "..", ".emsdk"); |
| 20 | +} |
| 21 | + |
| 22 | +function emsdk_checkout() { |
| 23 | + function git(args) { |
| 24 | + execute_throw`git ${args.join(" ")}`; |
| 25 | + } |
| 26 | + |
| 27 | + git(["clone", "https://github.com/emscripten-core/emsdk.git", base()]); |
| 28 | +} |
| 29 | + |
| 30 | +function emsdk(...args) { |
| 31 | + const basedir = base(); |
| 32 | + const suffix = os.type() == "Windows_NT" ? ".bat" : ""; |
| 33 | + const emsdk = path.join(basedir, "emsdk" + suffix); |
| 34 | + execute_throw`${emsdk} ${args.join(" ")}`; |
| 35 | +} |
14 | 36 |
|
15 | 37 | function upgrade() { |
16 | 38 | console.log(`-- Emscripten not found, installing ${emscripten}`); |
17 | | - execute`yarn emsdk-checkout`; |
18 | | - execute`yarn emsdk install ${emscripten}`; |
19 | | - execute`yarn emsdk activate ${emscripten}`; |
| 39 | + emsdk_checkout(); |
| 40 | + emsdk("install", emscripten); |
| 41 | + emsdk("activate", emscripten); |
20 | 42 | console.log(`-- Emscripten ${emscripten} installed`); |
21 | 43 | } |
22 | 44 |
|
23 | 45 | function check() { |
24 | 46 | try { |
25 | | - execute_throw`yarn emsdk-run command -v emcc`; |
| 47 | + execute_throw`emcc --version`; |
26 | 48 | return true; |
27 | 49 | } catch (e) { |
28 | | - return false; |
| 50 | + return fs.existsSync(path.join(__dirname, "..", ".emsdk")); |
29 | 51 | } |
30 | 52 | } |
31 | 53 |
|
|
0 commit comments