|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +var p = require('child_process') |
| 4 | +var fs = require('fs') |
| 5 | +var path = require('path') |
| 6 | + |
| 7 | +var config = |
| 8 | + { |
| 9 | + cwd: __dirname, |
| 10 | + encoding: 'utf8', |
| 11 | + stdio: [0, 1, 2], |
| 12 | + shell: true |
| 13 | + } |
| 14 | +function e(cmd) { |
| 15 | + console.log(`>>>>>> running command: ${cmd}`) |
| 16 | + p.execSync(cmd, config) |
| 17 | + console.log(`<<<<<<`) |
| 18 | +} |
| 19 | + |
| 20 | +if (process.env.BS_PLAYGROUND == null) { |
| 21 | + console.error('please set env var BS_PLAYGROUND') |
| 22 | + process.exit(2) |
| 23 | +} |
| 24 | + |
| 25 | +var playground = process.env.BS_PLAYGROUND |
| 26 | + |
| 27 | +function prepare() { |
| 28 | + e(`hash hash js_of_ocaml 2>/dev/null || { echo >&2 "js_of_ocaml not found on path. Please install version 2.8.4 (although not with the buckelscript switch) and put it on your path."; exit 1; } |
| 29 | +`) |
| 30 | + |
| 31 | + e(`hash ocp-ocamlres 2>/dev/null || { echo >&2 "ocp-ocamlres not installed. Please install: opam install ocp-ocamlres"; exit 1; }`) |
| 32 | + |
| 33 | + e(`hash camlp4 2>/dev/null || { echo >&2 "camlp4 not installed. Please install: opam install camlp4"; exit 1; }`) |
| 34 | + |
| 35 | + e(`./release.sh`) |
| 36 | + |
| 37 | + fs.unlinkSync(path.join(__dirname, 'bin', 'js_compiler.ml')) |
| 38 | + |
| 39 | + |
| 40 | + e(`make -j2 bin/jscmj.exe bin/jsgen.exe bin/js_compiler.ml`) |
| 41 | + e(`./bin/jsgen.exe --`) |
| 42 | + e(`./bin/jscmj.exe`) |
| 43 | + |
| 44 | + e(`ocamlc.opt -w -30-40 -no-check-prims -I bin bin/config_whole_compiler.mli bin/config_whole_compiler.ml bin/js_compiler.mli bin/js_compiler.ml -o jsc.byte`) |
| 45 | + |
| 46 | + e(`rm -rf ${playground}/pre_load.js`) |
| 47 | + e(`cp ./pre_load.js ${playground}`) |
| 48 | + e(`cp ../lib/amdjs/*.js ${playground}/stdlib`) |
| 49 | + |
| 50 | +} |
| 51 | + |
| 52 | +// needs js_cmj_datasets, preload.js and amdjs to be update |
| 53 | +prepare() |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +console.log(`playground : ${playground}`) |
| 60 | + |
| 61 | +var includes = [`stdlib`, `runtime`, `others`].map(x => path.join(__dirname, x)).map(x => `-I ${x}`).join(` `) |
| 62 | + |
| 63 | +var cmi_files = |
| 64 | + [ |
| 65 | + `lazy`, |
| 66 | + `js`, `js_unsafe`, `js_re`, `js_array`, `js_null`, `js_undefined`, `js_internal`, |
| 67 | + `js_types`, `js_null_undefined`, `js_dict`, `js_string`, `js_vector`, |
| 68 | + `js_promise`, `js_option`, `js_float`, `js_json` |
| 69 | + ].map(x => `${x}.cmi:/cmis/${x}.cmi`).map(x => `--file ${x}`).join(` `) |
| 70 | +e(`js_of_ocaml --toplevel +weak.js ./polyfill.js jsc.byte ${includes} ${cmi_files} -o ${playground}/exports.js`) |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +// note it is preferred to run ./release.sh && ./js.sh otherwise amdjs is not really latest |
| 76 | + |
| 77 | + |
0 commit comments