forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepl.js
executable file
·133 lines (102 loc) · 4.03 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/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(`<<<<<<`)
}
// process.env.BS_PLAYGROUND = `../../bucklescript-playground`
if (process.env.BS_PLAYGROUND == null) {
console.error('please set env var BS_PLAYGROUND')
process.exit(2)
}
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; }`)
// require('../scripts/release').run()
// try {
// fs.unlinkSync(path.join(__dirname, 'bin', 'js_compiler.ml'))
// } catch (err) {
// console.log(err)
// }
// e(`make -j2 bin/jscmj.exe bin/js_compiler.ml`)
// bin/jsgen.exe
// e(`./bin/jsgen.exe --`)
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`)
// Build JSX v2 PPX with jsoo
// try {
// fs.unlinkSync(path.join(__dirname, 'bin', 'jsoo_reactjs_jsx_ppx_v2.ml'))
// } catch (err) {
// console.log(err)
// }
// e(`make bin/jsoo_reactjs_jsx_ppx_v2.ml`)
// e(`ocamlc.opt -w -30-40 -no-check-prims -o jsoo_reactjs_jsx_ppx_v2.byte -I +compiler-libs ocamlcommon.cma bin/jsoo_reactjs_jsx_ppx_v2.ml`)
// var compilerlib = '../native/lib/ocaml/compiler-libs'
// e(`js_of_ocaml --disable share --toplevel +weak.js +toplevel.js jsoo_reactjs_jsx_ppx_v2.byte -I bin -I ${compilerlib} -o ${playground}/jsoo_reactjs_jsx_ppx_v2.js`)
}
// 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_null`, `js_undefined`,
`js_types`, `js_null_undefined`, `js_dict`, `js_exn`, `js_string`, `js_vector`,
`js_date`,
`js_console`,
`js_global`, `js_math`, `js_obj`, `js_int`,
`js_result`, `js_list`, `js_typed_array`,
`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`)