2015-02-04 04:27:00 +03:00
|
|
|
/**
|
|
|
|
* Instructions for updating this file.
|
|
|
|
* - this file must be updated everytime a new cross-folder dependency is added
|
|
|
|
* into any of the [refs.ts] file. For instance, if suddenly you add a
|
2015-02-25 02:52:27 +03:00
|
|
|
* reference to [../storage/whatever.ts] in [build/libwab.ts], then you must
|
|
|
|
* update the dependencies of the [build/libwab.d.ts] task.
|
2015-02-04 04:27:00 +03:00
|
|
|
**/
|
2015-02-05 03:47:33 +03:00
|
|
|
var assert = require('assert');
|
2015-02-04 04:27:00 +03:00
|
|
|
var child_process = require("child_process");
|
|
|
|
var fs = require("fs");
|
2015-02-10 04:30:29 +03:00
|
|
|
var path = require("path");
|
|
|
|
var source_map = require("source-map");
|
2015-02-14 04:19:23 +03:00
|
|
|
var events = require("events");
|
|
|
|
|
|
|
|
events.EventEmitter.defaultMaxListeners = 32;
|
2015-02-04 04:27:00 +03:00
|
|
|
|
2015-02-12 22:59:02 +03:00
|
|
|
var head;
|
|
|
|
function getGitHead() {
|
|
|
|
if (!head)
|
|
|
|
head = child_process.execSync("git rev-parse HEAD");
|
|
|
|
return head;
|
2015-02-10 05:07:09 +03:00
|
|
|
}
|
|
|
|
|
2015-02-05 04:38:49 +03:00
|
|
|
jake.addListener("start", function () {
|
|
|
|
if (!fs.existsSync("build"))
|
|
|
|
fs.mkdirSync("build");
|
|
|
|
});
|
2015-02-04 04:27:00 +03:00
|
|
|
|
2015-02-06 05:03:16 +03:00
|
|
|
var branchingFactor = 32;
|
|
|
|
|
2015-02-04 04:27:00 +03:00
|
|
|
// The list of files generated by the build.
|
2015-02-05 02:13:44 +03:00
|
|
|
var generated = [
|
|
|
|
'shell/npm/package.json',
|
2015-02-05 21:15:29 +03:00
|
|
|
'shell/npm/bin/touchdevelop.js',
|
2015-02-05 02:13:44 +03:00
|
|
|
'results.html',
|
|
|
|
'results.json',
|
|
|
|
];
|
2015-02-04 04:27:00 +03:00
|
|
|
|
2015-02-11 01:00:22 +03:00
|
|
|
// A list of targets we compile with the --noImplicitAny flag.
|
|
|
|
var noImplicitAny = {
|
|
|
|
"build/browser.d.ts": null,
|
2015-04-24 14:17:45 +03:00
|
|
|
"build/blockly-main.js": null
|
2015-02-11 01:00:22 +03:00
|
|
|
};
|
|
|
|
|
2015-02-11 04:04:26 +03:00
|
|
|
// On Windows, merely changing a file in the directory does *not* change that
|
|
|
|
// directory's mtime, meaning that we can't depend on a directory, but rather
|
|
|
|
// need to depend on all the files in a directory. [expand] takes a list of
|
|
|
|
// dependencies, and for filenames that seem to be directories, performs a
|
|
|
|
// manual expansion.
|
|
|
|
function expand(dependencies) {
|
|
|
|
var isFolder = function (f) {
|
|
|
|
return f.indexOf(".") < 0 && f.indexOf("/") < 0;
|
|
|
|
};
|
|
|
|
var acc = [];
|
|
|
|
dependencies.forEach(function (f) {
|
|
|
|
if (isFolder(f)) {
|
|
|
|
var l = new jake.FileList();
|
|
|
|
l.include(f+"/*");
|
|
|
|
acc = acc.concat(l.toArray());
|
|
|
|
} else {
|
|
|
|
acc.push(f);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
2015-03-24 00:41:48 +03:00
|
|
|
// for use with child_process.exec/execFile
|
|
|
|
function execCallback(task) {
|
|
|
|
return function (error, stdout, stderr) {
|
|
|
|
if (stdout) console.log(stdout.toString());
|
|
|
|
if (stderr) console.error(stderr.toString());
|
|
|
|
if (error) task.fail(error);
|
|
|
|
else task.complete();
|
|
|
|
}
|
|
|
|
}
|
2015-02-11 04:04:26 +03:00
|
|
|
|
2015-02-05 04:38:49 +03:00
|
|
|
// This function tries to be "smart" about the target.
|
2015-02-11 02:53:48 +03:00
|
|
|
// - if the target is of the form "foobar/refs.ts", the output is bundled with
|
2015-02-05 04:38:49 +03:00
|
|
|
// [--out] into "build/foobar.js", and "build/foobar.d.ts" is also generated;
|
|
|
|
// - otherwise, the file is just compiled as a single file into the "build/"
|
|
|
|
// directory
|
|
|
|
function mkSimpleTask(production, dependencies, target) {
|
2015-02-10 05:07:09 +03:00
|
|
|
var sourceRoot = (process.env.TRAVIS
|
2015-02-12 22:59:02 +03:00
|
|
|
? "https://github.com/Microsoft/TouchDevelop/raw/"+getGitHead()+"/"
|
2015-02-10 05:07:09 +03:00
|
|
|
: "/editor/local/");
|
2015-02-05 04:38:49 +03:00
|
|
|
var tscCall = [
|
|
|
|
"node node_modules/typescript/bin/tsc",
|
|
|
|
"--noEmitOnError",
|
2015-02-06 02:06:40 +03:00
|
|
|
"--removeComments",
|
2015-02-05 04:38:49 +03:00
|
|
|
"--target ES5",
|
|
|
|
"--module commonjs",
|
|
|
|
"--declaration", // not always strictly needed, but better be safe than sorry
|
|
|
|
];
|
2015-02-11 02:16:00 +03:00
|
|
|
if (process.env.TD_SOURCE_MAPS) {
|
|
|
|
tscCall.push("--sourceMap");
|
|
|
|
tscCall.push("--sourceRoot "+sourceRoot);
|
|
|
|
}
|
2015-02-11 01:00:22 +03:00
|
|
|
if (production in noImplicitAny)
|
|
|
|
tscCall.push("--noImplicitAny");
|
2015-02-05 04:38:49 +03:00
|
|
|
var match = target.match(/(\w+)\/refs.ts/);
|
|
|
|
if (match) {
|
2015-04-24 14:17:45 +03:00
|
|
|
tscCall.push("--out "+production);
|
2015-02-05 04:38:49 +03:00
|
|
|
} else {
|
|
|
|
tscCall.push("--outDir build/");
|
|
|
|
}
|
|
|
|
tscCall.push(target);
|
2015-04-24 14:17:45 +03:00
|
|
|
// We always generate definition files
|
|
|
|
file(production.replace(".js", ".d.ts"), [ production ]);
|
2015-02-11 04:04:26 +03:00
|
|
|
return file(production, expand(dependencies), { async: true, parallelLimit: branchingFactor }, function () {
|
2015-02-06 05:03:16 +03:00
|
|
|
var task = this;
|
|
|
|
console.log("[B] "+production);
|
|
|
|
jake.exec(tscCall.join(" "), { printStdout: true }, function () {
|
|
|
|
task.complete();
|
|
|
|
});
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// A series of compile-and-run rules that generate various files for the build
|
2015-02-06 05:03:16 +03:00
|
|
|
// system.
|
|
|
|
function runAndComplete(cmds, task) {
|
2015-02-04 04:27:00 +03:00
|
|
|
jake.exec(cmds, {}, function() {
|
2015-02-06 05:03:16 +03:00
|
|
|
task.complete();
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-03-12 03:03:30 +03:00
|
|
|
mkSimpleTask('build/genmeta.js', [ 'tools', 'generated/help.cache' ], "tools/genmeta.ts");
|
2015-02-12 03:15:34 +03:00
|
|
|
file('build/api.js', expand([ "build/genmeta.js", "lib" ]), { async: true }, function () {
|
2015-02-04 04:27:00 +03:00
|
|
|
console.log("[P] generating build/api.js, localization.json and topiclist.json");
|
2015-02-06 05:03:16 +03:00
|
|
|
runAndComplete([
|
|
|
|
"node build/genmeta.js",
|
|
|
|
], this);
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
|
2015-02-05 04:38:49 +03:00
|
|
|
mkSimpleTask('build/addCssPrefixes.js', [ 'tools' ], "tools/addCssPrefixes.ts");
|
|
|
|
task('css-prefixes', [ "build/addCssPrefixes.js" ], { async: true }, function () {
|
2015-02-04 04:27:00 +03:00
|
|
|
console.log("[P] modifying in-place all css files");
|
2015-02-06 05:03:16 +03:00
|
|
|
runAndComplete([
|
|
|
|
"node build/addCssPrefixes.js"
|
|
|
|
], this);
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
|
2015-02-05 04:38:49 +03:00
|
|
|
mkSimpleTask('build/shell.js', [ 'shell/shell.ts' ], "shell/shell.ts");
|
|
|
|
mkSimpleTask('build/package.js', [ 'shell/package.ts', 'build/shell.js' ], "shell/package.ts");
|
|
|
|
file('build/pkgshell.js', [ 'build/package.js' ], { async: true }, function () {
|
2015-02-04 04:27:00 +03:00
|
|
|
console.log("[P] generating build/pkgshell.js and packaging");
|
2015-02-06 05:03:16 +03:00
|
|
|
runAndComplete([
|
|
|
|
"node build/package.js"
|
|
|
|
], this);
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// These dependencies have been hand-crafted by reading the various [refs.ts]
|
|
|
|
// files. The dependencies inside the same folder are coarse-grained: for
|
2015-02-05 04:38:49 +03:00
|
|
|
// instance, anytime something changes in [editor/], [build/editor.d.ts] gets
|
2015-02-11 02:53:48 +03:00
|
|
|
// rebuilt. This amounts to assuming that for all [foo/bar.ts], [bar.ts] is a
|
|
|
|
// dependency of [build/foo.js].
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/browser.js', [
|
2015-02-04 04:27:00 +03:00
|
|
|
'browser/browser.ts'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "browser/browser.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/rt.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt',
|
|
|
|
'lib'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "rt/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/storage.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'storage'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "storage/refs.ts");
|
2015-04-26 18:10:04 +03:00
|
|
|
mkSimpleTask('build/embedded.js', [
|
|
|
|
'build/ast.d.ts',
|
|
|
|
'embedded'
|
|
|
|
], "embedded/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/ast.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'ast'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "ast/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/libwab.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'libwab'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "libwab/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/libnode.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
|
|
|
'libnode'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "libnode/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/libcordova.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'libcordova'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "libcordova/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/editor.js', [
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
|
|
|
'build/rt.d.ts',
|
|
|
|
'build/ast.d.ts',
|
|
|
|
'build/storage.d.ts',
|
|
|
|
'build/libwab.d.ts',
|
|
|
|
'build/libcordova.d.ts',
|
2015-04-26 18:10:04 +03:00
|
|
|
'build/embedded.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'intellitrain',
|
|
|
|
'editor'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "editor/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/officemix.js', [
|
2015-02-12 20:09:48 +03:00
|
|
|
'officemix'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "officemix/officemix.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/jsonapi.js', [], "noderunner/jsonapi.ts");
|
2015-02-05 04:38:49 +03:00
|
|
|
mkSimpleTask('build/client.js', [
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 21:34:03 +03:00
|
|
|
'build/jsonapi.d.ts',
|
2015-02-06 01:29:38 +03:00
|
|
|
'tools/client.ts'
|
|
|
|
], "tools/client.ts");
|
2015-02-04 04:27:00 +03:00
|
|
|
// XXX coarse-grained dependencies here over the whole 'noderunner' directory
|
2015-02-06 03:53:32 +03:00
|
|
|
mkSimpleTask('build/nrunner.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
|
|
|
'build/ast.d.ts',
|
|
|
|
'build/libnode.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'noderunner'
|
2015-02-06 03:53:32 +03:00
|
|
|
], "noderunner/nrunner.ts");
|
2015-02-04 04:27:00 +03:00
|
|
|
// XXX same here
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/runner.js', [
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/browser.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'rt/typings.d.ts',
|
2015-02-05 04:38:49 +03:00
|
|
|
'build/rt.d.ts',
|
|
|
|
'build/storage.d.ts',
|
|
|
|
'build/libwab.d.ts',
|
|
|
|
'build/libnode.d.ts',
|
|
|
|
'build/libcordova.d.ts',
|
2015-02-04 04:27:00 +03:00
|
|
|
'runner'
|
2015-02-05 04:38:49 +03:00
|
|
|
], "runner/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/ace-main.js', [
|
2015-04-02 01:32:15 +03:00
|
|
|
"www/ace/ace-main.ts",
|
|
|
|
"editor/messages.ts"
|
|
|
|
], "www/ace/refs.ts");
|
2015-04-24 14:17:45 +03:00
|
|
|
mkSimpleTask('build/blockly-main.js', [
|
2015-04-02 01:32:15 +03:00
|
|
|
"www/blockly/blockly-main.ts",
|
2015-04-04 03:45:46 +03:00
|
|
|
"www/blockly/compiler.ts",
|
2015-04-02 01:32:15 +03:00
|
|
|
"editor/messages.ts"
|
|
|
|
], "www/blockly/refs.ts");
|
2015-02-04 04:27:00 +03:00
|
|
|
|
|
|
|
// Now come the rules for files that are obtained by concatenating multiple
|
2015-02-04 20:27:14 +03:00
|
|
|
// _js_ files into another one. The sequence exactly reproduces what happened
|
|
|
|
// previously, as there are ordering issues with initialization of global variables
|
|
|
|
// (unsurprisingly). Here's the semantics of these entries:
|
|
|
|
// - files ending with ".js" end up as dependencies (either as rule names, or as
|
|
|
|
// statically-checked-in files in the repo, such as [langs.js]), and are
|
|
|
|
// concatenated in the final file
|
|
|
|
// - files without an extension generate a dependency on the ".d.ts" rule and
|
|
|
|
// the ".js" compiled file ends up in the concatenation
|
2015-02-04 04:27:00 +03:00
|
|
|
var concatMap = {
|
2015-02-05 21:15:29 +03:00
|
|
|
"build/noderunner.js": [
|
2015-02-24 06:01:54 +03:00
|
|
|
"tools/node_prelude.js",
|
2015-02-05 04:38:49 +03:00
|
|
|
"build/browser",
|
|
|
|
"build/rt",
|
|
|
|
"build/ast",
|
2015-02-04 20:27:14 +03:00
|
|
|
"build/api.js",
|
2015-02-05 04:38:49 +03:00
|
|
|
"generated/langs.js",
|
|
|
|
"build/libnode",
|
2015-02-04 20:27:14 +03:00
|
|
|
"build/pkgshell.js",
|
2015-02-06 03:53:32 +03:00
|
|
|
"build/nrunner.js",
|
2015-02-04 20:27:14 +03:00
|
|
|
],
|
2015-02-24 06:01:54 +03:00
|
|
|
"build/noderuntime.js": [
|
|
|
|
"tools/node_prelude.js",
|
|
|
|
"build/browser",
|
|
|
|
"build/rt",
|
|
|
|
"build/storage",
|
|
|
|
"build/libnode",
|
|
|
|
"build/runner",
|
|
|
|
],
|
2015-02-05 21:15:29 +03:00
|
|
|
"build/runtime.js": [
|
2015-02-05 04:38:49 +03:00
|
|
|
"build/rt",
|
|
|
|
"build/storage",
|
|
|
|
"build/libwab",
|
|
|
|
"build/libnode",
|
|
|
|
"build/libcordova",
|
|
|
|
"build/runner",
|
2015-02-04 20:27:14 +03:00
|
|
|
],
|
2015-02-05 21:15:29 +03:00
|
|
|
"build/main.js": [
|
2015-02-05 04:38:49 +03:00
|
|
|
"build/rt",
|
|
|
|
"build/ast",
|
2015-02-04 20:27:14 +03:00
|
|
|
"build/api.js",
|
2015-02-05 04:38:49 +03:00
|
|
|
"generated/langs.js",
|
|
|
|
"build/storage",
|
|
|
|
"build/libwab",
|
|
|
|
"build/libcordova",
|
2015-02-04 20:27:14 +03:00
|
|
|
"build/pkgshell.js",
|
2015-02-05 04:38:49 +03:00
|
|
|
"build/editor" ,
|
2015-02-04 20:27:14 +03:00
|
|
|
],
|
2015-02-04 04:27:00 +03:00
|
|
|
};
|
|
|
|
|
2015-02-10 04:30:29 +03:00
|
|
|
// Just a dumb concatenation
|
|
|
|
function justCat(files, dest) {
|
|
|
|
console.log("[C]", dest);
|
|
|
|
var bufs = [];
|
|
|
|
|
|
|
|
files.forEach(function (f) {
|
|
|
|
bufs.push(fs.readFileSync(f));
|
|
|
|
});
|
|
|
|
|
|
|
|
fs.writeFileSync(dest, Buffer.concat(bufs));
|
|
|
|
}
|
|
|
|
|
|
|
|
// A concatenation that recomputes proper maps. Generates the source map in the
|
|
|
|
// same directory as the original map, and expects it to remain that way.
|
|
|
|
function mapCat(files, dest) {
|
|
|
|
console.log("[C]", dest, "with maps");
|
|
|
|
|
|
|
|
// An array of buffers for all the files we want to concatenate.
|
|
|
|
var bufs = [];
|
|
|
|
// Current line offest.
|
|
|
|
var lineOffset = 0;
|
|
|
|
// The source map we're generating.
|
|
|
|
var map = new source_map.SourceMapGenerator({ file: dest + ".map" });
|
|
|
|
|
|
|
|
files.forEach(function (f) {
|
|
|
|
var buf = fs.readFileSync(f);
|
|
|
|
bufs.push(buf);
|
|
|
|
if (fs.existsSync(f + ".map")) {
|
|
|
|
var originalMap = new source_map.SourceMapConsumer(fs.readFileSync(f + ".map", { encoding: "utf-8" }));
|
|
|
|
originalMap.eachMapping(function (m) {
|
|
|
|
map.addMapping({
|
|
|
|
generated: {
|
|
|
|
line: m.generatedLine + lineOffset,
|
|
|
|
column: m.generatedColumn,
|
|
|
|
},
|
|
|
|
original: {
|
|
|
|
line: m.originalLine,
|
|
|
|
column: m.originalColumn,
|
|
|
|
},
|
|
|
|
source: m.source,
|
|
|
|
name: m.name
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// An extra line was added for the sourcemap comment already.
|
|
|
|
lineOffset--;
|
|
|
|
}
|
|
|
|
lineOffset += buf.toString().split("\n").length;
|
|
|
|
if (buf[buf.length - 1] == "\n".charCodeAt(0))
|
|
|
|
lineOffset--;
|
|
|
|
});
|
|
|
|
|
|
|
|
bufs.push(new Buffer("\n//# sourceMappingURL="+path.basename(dest)+".map"));
|
|
|
|
|
|
|
|
fs.writeFileSync(dest, Buffer.concat(bufs));
|
|
|
|
fs.writeFileSync(dest+".map", map.toString());
|
|
|
|
}
|
|
|
|
|
2015-02-04 04:27:00 +03:00
|
|
|
Object.keys(concatMap).forEach(function (f) {
|
2015-02-04 20:27:14 +03:00
|
|
|
var isJs = function (s) { return s.substr(s.length - 3, 3) == ".js"; };
|
2015-04-24 14:17:45 +03:00
|
|
|
var buildDeps = concatMap[f].map(function (x) { if (isJs(x)) return x; else return x + ".js"; });
|
|
|
|
var toConcat = buildDeps;
|
2015-02-06 05:03:16 +03:00
|
|
|
file(f, buildDeps, { parallelLimit: branchingFactor }, function () {
|
2015-02-10 04:30:29 +03:00
|
|
|
if (f == "build/main.js" && process.env.TD_SOURCE_MAPS)
|
|
|
|
mapCat(toConcat, f);
|
|
|
|
else
|
|
|
|
justCat(toConcat, f);
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-02-13 19:40:42 +03:00
|
|
|
task('log', [], { async: false }, function () {
|
2015-03-19 04:52:37 +03:00
|
|
|
if (process.env.TRAVIS_COMMIT) {
|
2015-02-13 19:40:42 +03:00
|
|
|
console.log("[I] dumping commit info to build/buildinfo.json");
|
|
|
|
fs.writeFileSync('build/buildinfo.json', JSON.stringify({
|
|
|
|
commit: process.env.TRAVIS_COMMIT,
|
|
|
|
commitRange: process.env.TRAVIS_COMMIT_RANGE
|
|
|
|
}));
|
2015-02-13 02:23:31 +03:00
|
|
|
}
|
2015-02-12 22:59:02 +03:00
|
|
|
});
|
|
|
|
|
2015-02-04 04:27:00 +03:00
|
|
|
// Our targets are the concatenated files, which are the final result of the
|
|
|
|
// compilation. We also re-run the CSS prefixes thingy everytime.
|
2015-03-24 03:33:37 +03:00
|
|
|
desc('build the whole TouchDevelop project')
|
2015-03-10 02:33:57 +03:00
|
|
|
task('default', [
|
|
|
|
'css-prefixes',
|
|
|
|
'build/client.js',
|
|
|
|
'build/officemix.d.ts',
|
2015-04-24 14:17:45 +03:00
|
|
|
'build/ace-main.js',
|
|
|
|
'build/blockly-main.js',
|
2015-03-10 02:33:57 +03:00
|
|
|
'log'
|
|
|
|
].concat(Object.keys(concatMap)), {
|
2015-02-06 05:03:16 +03:00
|
|
|
parallelLimit: branchingFactor,
|
|
|
|
},function () {
|
2015-02-04 22:38:08 +03:00
|
|
|
console.log("[I] build completed.");
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
|
2015-02-27 00:30:04 +03:00
|
|
|
desc('clean up the build folders and files')
|
2015-02-04 04:27:00 +03:00
|
|
|
task('clean', [], function () {
|
2015-03-31 03:52:29 +03:00
|
|
|
// XXX do this in a single call? check out https://github.com/mde/utilities/blob/master/lib/file.js
|
|
|
|
generated.forEach(function (f) { jake.rmRf(f); });
|
|
|
|
jake.rmRf('build/');
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
|
2015-04-03 06:40:50 +03:00
|
|
|
desc('display info about installed tools')
|
|
|
|
task('info', [], { async: true }, function () {
|
|
|
|
var task = this;
|
2015-04-26 18:10:04 +03:00
|
|
|
|
2015-04-07 03:00:22 +03:00
|
|
|
if (process.env.TRAVIS) {
|
2015-04-26 18:10:04 +03:00
|
|
|
assert(process.env.TD_UPLOAD_KEY, "missing touchdevelop upload key TD_UPLOAD_KEY");
|
2015-04-07 03:00:22 +03:00
|
|
|
}
|
|
|
|
|
2015-04-03 06:40:50 +03:00
|
|
|
jake.exec([ 'tsc --version' ],
|
|
|
|
{ printStdout: true, printStderr: true },
|
|
|
|
function() { task.complete(); });
|
|
|
|
});
|
|
|
|
|
2015-02-27 00:30:04 +03:00
|
|
|
desc('run local test suite')
|
2015-04-03 06:40:50 +03:00
|
|
|
task('test', [ 'info', 'build/client.js', 'default', 'nw-build' ], { async: true }, function () {
|
2015-02-06 05:03:16 +03:00
|
|
|
var task = this;
|
|
|
|
console.log("[I] running tests")
|
|
|
|
jake.exec([ 'node build/client.js buildtest' ],
|
|
|
|
{ printStdout: true, printStderr: true },
|
|
|
|
function() { task.complete(); });
|
2015-02-04 04:27:00 +03:00
|
|
|
});
|
|
|
|
|
2015-02-05 20:31:38 +03:00
|
|
|
// this task runs as a "after_success" step in the travis-ci automation
|
2015-02-27 00:30:04 +03:00
|
|
|
desc('upload current build to the cloud')
|
2015-03-31 03:50:22 +03:00
|
|
|
task('upload', [ "build/client.js" ], { async : true }, function() {
|
2015-02-06 05:03:16 +03:00
|
|
|
var task = this;
|
2015-02-05 20:31:38 +03:00
|
|
|
var upload = function (buildVersion) {
|
2015-02-05 03:31:57 +03:00
|
|
|
console.log("[I] uploading v" + buildVersion)
|
2015-04-26 18:10:04 +03:00
|
|
|
var procs = [];
|
|
|
|
if (process.env.TD_UPLOAD_LITE_KEY) {
|
|
|
|
console.log("[I] uploading to lite")
|
|
|
|
procs.push('node build/client.js tdupload ' + process.env.TD_UPLOAD_LITE_KEY + ' ' + buildVersion + ' latest');
|
|
|
|
}
|
|
|
|
var uploadKey = process.env.TD_UPLOAD_KEY || "direct";
|
|
|
|
procs.push('node build/client.js tdupload ' + uploadKey + ' ' + buildVersion);
|
|
|
|
jake.exec(procs,
|
|
|
|
{ printStdout: true, printStderr: true },
|
|
|
|
function() { task.complete(); });
|
2015-02-05 20:31:38 +03:00
|
|
|
};
|
|
|
|
if (!process.env.TRAVIS) {
|
2015-03-05 18:05:06 +03:00
|
|
|
upload(process.env.TD_UPLOAD_USER || process.env.USERNAME);
|
2015-02-05 20:31:38 +03:00
|
|
|
} else {
|
|
|
|
assert(process.env.TRAVIS_BUILD_NUMBER, "missing travis build number");
|
2015-04-07 02:52:59 +03:00
|
|
|
assert(process.env.TD_UPLOAD_KEY, "missing touchdevelop upload key TD_UPLOAD_KEY");
|
2015-02-11 19:31:25 +03:00
|
|
|
var buildVersion = 80100 + parseInt(process.env.TRAVIS_BUILD_NUMBER || - 80000);
|
2015-03-19 21:40:08 +03:00
|
|
|
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST != "false") {
|
|
|
|
// don't upload
|
|
|
|
} else {
|
|
|
|
if (process.env.TRAVIS_BRANCH != "master")
|
|
|
|
buildVersion = process.env.TRAVIS_BRANCH + buildVersion
|
|
|
|
upload(buildVersion);
|
|
|
|
}
|
2015-02-05 03:31:57 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-02-27 00:30:04 +03:00
|
|
|
desc('build portal html pages')
|
|
|
|
task('portal', ['build/portal/portal.html']);
|
|
|
|
|
|
|
|
desc('build and launch local server')
|
2015-02-05 02:49:22 +03:00
|
|
|
task('local', [ 'default' ], { async: true }, function() {
|
2015-02-06 05:03:16 +03:00
|
|
|
var task = this;
|
2015-02-18 00:48:00 +03:00
|
|
|
jake.mkdirP('build/local/node_modules')
|
2015-02-18 05:06:53 +03:00
|
|
|
jake.cpR('build/shell.js', 'build/local/tdserver.js')
|
2015-02-09 09:41:19 +03:00
|
|
|
process.chdir("build/local")
|
2015-02-18 05:06:53 +03:00
|
|
|
var node = "node"
|
|
|
|
if (process.env.TD_SHELL_DEBUG)
|
|
|
|
node = "node-debug"
|
2015-02-04 22:31:42 +03:00
|
|
|
jake.exec(
|
2015-03-09 20:19:59 +03:00
|
|
|
[ node + ' tdserver.js --cli TD_ALLOW_EDITOR=true TD_LOCAL_EDITOR_PATH=../.. ' + (process.env.TD_SHELL_ARGS || "") ],
|
2015-02-04 22:31:42 +03:00
|
|
|
{ printStdout: true, printStderr: true },
|
2015-02-06 05:03:16 +03:00
|
|
|
function() { task.complete(); }
|
2015-02-06 01:59:36 +03:00
|
|
|
);
|
|
|
|
});
|
2015-02-05 02:49:22 +03:00
|
|
|
|
2015-02-14 08:29:34 +03:00
|
|
|
task('nw', ['default', 'nw-npm'], { async: true }, function() {
|
2015-02-16 21:53:33 +03:00
|
|
|
runAndComplete([ 'node node_modules/nw/bin/nw build/nw' ], this);
|
2015-02-14 08:29:34 +03:00
|
|
|
})
|
|
|
|
|
2015-02-05 20:31:38 +03:00
|
|
|
task('update-docs', [ 'build/client.js', 'default' ], { async: true }, function() {
|
2015-02-06 05:03:16 +03:00
|
|
|
var task = this;
|
2015-02-05 02:49:22 +03:00
|
|
|
jake.exec(
|
2015-02-05 21:15:29 +03:00
|
|
|
[ 'node build/client.js updatehelp',
|
|
|
|
'node build/client.js updatelang' ],
|
2015-02-05 02:49:22 +03:00
|
|
|
{ printStdout: true, printStderr: true },
|
2015-02-06 05:03:16 +03:00
|
|
|
function() { task.complete(); }
|
2015-02-06 01:59:36 +03:00
|
|
|
);
|
|
|
|
});
|
2015-02-05 04:26:19 +03:00
|
|
|
|
2015-03-24 00:41:48 +03:00
|
|
|
|
|
|
|
task('azure', [ 'build/shell.js' ], { async: true }, function() {
|
2015-03-24 03:28:18 +03:00
|
|
|
jake.mkdirP("build/azure")
|
2015-03-24 00:41:48 +03:00
|
|
|
child_process.execFile(
|
|
|
|
"C:/Program Files/Microsoft SDKs/Azure/.NET SDK/v2.5/bin/cspack.exe",
|
|
|
|
[ "tdshell.csdef",
|
2015-03-31 03:52:29 +03:00
|
|
|
"/out:../../build/azure/tdshell.cspkg",
|
2015-03-24 00:41:48 +03:00
|
|
|
"/roleFiles:ShellRole;files.txt" ], { cwd: 'shell/azure' }, execCallback(this))
|
|
|
|
});
|
2015-03-31 03:52:29 +03:00
|
|
|
|
2015-02-06 17:34:33 +03:00
|
|
|
task('nw-npm', {async : true }, function() {
|
|
|
|
var task = this;
|
2015-02-09 10:06:02 +03:00
|
|
|
jake.mkdirP('build/nw');
|
|
|
|
['node-webkit/app.html',
|
|
|
|
'node-webkit/logo.png',
|
|
|
|
'node-webkit/client.ico',
|
|
|
|
'node-webkit/package.json',
|
|
|
|
'build/shell.js'].forEach(function(f) { jake.cpR(f, 'build/nw') })
|
2015-03-24 00:41:48 +03:00
|
|
|
child_process.exec('npm install', { cwd: 'build/nw' }, execCallback(task))
|
2015-02-06 17:34:33 +03:00
|
|
|
})
|
|
|
|
|
2015-02-14 08:29:34 +03:00
|
|
|
task('nw-build', [ 'default', 'nw-npm' ], { async : true }, function() {
|
2015-02-06 05:03:16 +03:00
|
|
|
var task = this;
|
2015-02-06 01:36:38 +03:00
|
|
|
console.log('[I] building nw packages')
|
|
|
|
var nwBuilder = require('node-webkit-builder');
|
|
|
|
var nw = new nwBuilder({
|
2015-03-25 19:04:21 +03:00
|
|
|
version: '0.12.0',
|
2015-02-06 01:36:38 +03:00
|
|
|
files: 'build/nw/**',
|
2015-02-06 09:50:46 +03:00
|
|
|
platforms: ['win32', 'osx32', 'linux32'],
|
2015-02-06 01:36:38 +03:00
|
|
|
buildDir: 'build/nw_build',
|
2015-02-06 19:58:47 +03:00
|
|
|
cacheDir: 'nw_cache'
|
2015-02-06 01:36:38 +03:00
|
|
|
});
|
|
|
|
nw.on('log', console.log);
|
|
|
|
nw.build().then(function () {
|
|
|
|
console.log('[I] nw packaged');
|
2015-02-06 05:03:16 +03:00
|
|
|
task.complete();
|
2015-02-06 19:58:47 +03:00
|
|
|
}).catch(function (error) {
|
|
|
|
console.error(error);
|
|
|
|
task.fail();
|
2015-02-06 01:36:38 +03:00
|
|
|
});
|
2015-02-06 01:59:36 +03:00
|
|
|
});
|
2015-02-06 01:36:38 +03:00
|
|
|
|
2015-02-06 01:59:36 +03:00
|
|
|
task('cordova', [ 'default' ], {}, function () {
|
|
|
|
// FIXME minify
|
|
|
|
jake.mkdirP('build/cordova/');
|
|
|
|
['www/index.html',
|
|
|
|
'build/browser.js',
|
|
|
|
'build/main.js',
|
|
|
|
'www/default.css',
|
|
|
|
'www/editor.css'].forEach(function (f) { jake.cpR(f, 'build/cordova/'); });
|
|
|
|
});
|
2015-02-05 04:26:19 +03:00
|
|
|
|
2015-02-05 04:24:12 +03:00
|
|
|
// vim: ft=javascript
|