forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepl.js
executable file
·107 lines (83 loc) · 3.24 KB
/
repl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env node
var p = require('child_process')
var fs = require('fs')
var path = require('path')
process.env.BS_RELEASE_BUILD = 1
var jscompDir = path.join(__dirname,'..','jscomp')
var config =
{
cwd: jscompDir,
encoding: 'utf8',
stdio: [0, 1, 2],
shell: true
}
function e(cmd) {
console.log(`>>>>>> running command: ${cmd}`)
p.execSync(cmd, config)
console.log(`<<<<<<`)
}
if (process.env.BS_PLAYGROUND == null) {
var defaultPlayground = `../../bucklescript-playground`
console.warn(`BS_PLAYGROUND env var unset, defaulting to ${defaultPlayground}`)
process.env.BS_PLAYGROUND = defaultPlayground
}
var playground = process.env.BS_PLAYGROUND
function prepare() {
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; }
`)
e(`hash ocp-ocamlres 2>/dev/null || { echo >&2 "ocp-ocamlres not installed. Please install: opam install ocp-ocamlres"; exit 1; }`)
e(`hash camlp4 2>/dev/null || { echo >&2 "camlp4 not installed. Please install: opam install camlp4"; exit 1; }`)
e(`./bin/cmjbrowser.exe`)
var js_compiler_path = `../lib/4.02.3/unstable`
e(`ocamlc.opt -w -30-40 -no-check-prims -I ${js_compiler_path} ${js_compiler_path}/js_compiler.mli ${js_compiler_path}/js_compiler.ml -o jsc.byte`)
e(`cp ../lib/js/*.js ${playground}/stdlib`)
}
// needs js_cmj_datasets, preload.js and amdjs to be update
prepare()
console.log(`playground : ${playground}`)
var includes = [`stdlib-402`, `runtime`, `others`].map(x => path.join(jscompDir, x)).map(x => `-I ${x}`).join(` `)
var cmi_files =
[
// `lazy`,
`js`, `js_re`, `js_array`, `js_array2`, `js_null`, `js_undefined`,
`js_types`, `js_null_undefined`, `js_dict`, `js_exn`, `js_string`, `js_string2`, `js_vector`,
`js_date`,
`js_console`,
`js_global`, `js_math`, `js_obj`, `js_int`,
`js_result`, `js_list`, `js_typed_array`, `js_typed_array2`,
`js_promise`, `js_option`, `js_float`, `js_json`,
`arrayLabels`, `bytesLabels`, `complex`, `gc`, `genlex`, `listLabels`,
`moreLabels`, `queue`, `scanf`, `sort`,`stack`, `stdLabels`, `stream`,
`stringLabels`,
`dom`,
`belt`,
`belt_Id`,
`belt_Array`,
`belt_SortArray`,
`belt_SortArrayInt`,
`belt_SortArrayString`,
`belt_MutableQueue`,
`belt_MutableStack`,
`belt_List`,
`belt_Range`,
`belt_Set`,
`belt_SetInt`,
`belt_SetString`,
`belt_Map`,
`belt_MapInt`,
`belt_Option`,
`belt_MapString`,
`belt_MutableSet`,
`belt_MutableSetInt`,
`belt_MutableSetString`,
`belt_MutableMap`,
`belt_MutableMapInt`,
`belt_MutableMapString`,
`belt_HashSet`,
`belt_HashSetInt`,
`belt_HashSetString`,
`belt_HashMap`,
`belt_HashMapInt`,
`belt_HashMapString`,
].map(x => `${x}.cmi:/static/cmis/${x}.cmi`).map(x => `--file ${x}`).join(` `)
e(`js_of_ocaml --disable share --toplevel +weak.js ./polyfill.js jsc.byte ${includes} ${cmi_files} -o ${playground}/exports.js`)