-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmake.js
46 lines (39 loc) · 1.1 KB
/
make.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
var util = require('util');
var fs = require('fs');
var opts = {};
var root;
var args = process.argv.slice(2);
while(args[0].indexOf('.ol') == -1) {
if(args[0] == '_boot') {
opts.boot = true;
}
else if(args[0] == '_with_eval') {
opts.with_eval = true;
}
else if(args[0] == '_no_runtime') {
opts.no_runtime = true;
}
else if(args[0] == '_current_runtime') {
opts.current_runtime = true;
}
args = args.slice(1);
}
if(opts.boot) {
root = './boot/';
}
else {
root = './';
}
var compiler = require(root + 'compiler');
var js_generator = require(root + 'backends/js');
var srcfile = args[0];
var optimizations = 1;
var src = fs.readFileSync(srcfile, 'utf-8');
var js = js_generator(optimizations);
compiler['set-optimizations'] = optimizations;
js['write-runtime'](opts.no_runtime ? 'no-runtime' :
(opts.with_eval ?
'js' :
'js-noeval'),
opts.current_runtime ? __dirname : __dirname + '/boot');
util.puts(compiler['compile-program'](src, js));