forked from JeffreyZhao/wind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-prod.js
More file actions
52 lines (40 loc) · 1.46 KB
/
build-prod.js
File metadata and controls
52 lines (40 loc) · 1.46 KB
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
"use strict";
var path = require("path"),
fs = require("fs"),
utils = require("../lib/utils"),
Wind = utils.Wind,
execAsync = Wind.Async.Binding.fromCallback(require('child_process').exec, "_ignored_", "stdout", "stderr"),
_ = Wind._;
Wind.logger.level = Wind.Logging.Level.INFO;
var prodDir = path.join(__dirname, "../bin/prod");
var srcDir = path.join(__dirname, "../src");
var gccPath = path.join(__dirname, "../tools/compiler.jar");
if (fs.existsSync(prodDir)) {
utils.rmdirSync(prodDir);
}
fs.mkdirSync(prodDir);
var buildOne = eval(Wind.compile("async", function (module) {
var fullName = "wind-" + module;
var version = Wind.modules[module].version;
var inputFile = fullName + ".js";
var outputFile = fullName + "-" + version + ".min.js";
var command = _.format(
"java -jar {0} --js {1} --js_output_file {2} --compilation_level SIMPLE_OPTIMIZATIONS",
gccPath,
path.join(srcDir, inputFile),
path.join(prodDir, outputFile));
utils.stdout("Generating {0}...", outputFile);
var r = $await(execAsync(command));
if (r.stderr) {
utils.stdout("failed.\n");
utils.stderr(r.stderr + "\n");
} else {
utils.stdout("done.\n");
}
}));
var buildAll = eval(Wind.compile("async", function (modules) {
for (var i = 0; i < modules.length; i++) {
$await(buildOne(modules[i]));
}
}));
buildAll(["core", "builderbase", "async", "promise"]).start();