update makefile
This commit is contained in:
parent
da94ecdb42
commit
28d4807d09
1 changed files with 143 additions and 129 deletions
|
|
@ -43,56 +43,61 @@ if (!fs.existsSync)
|
||||||
var copy = require('dryice').copy;
|
var copy = require('dryice').copy;
|
||||||
|
|
||||||
var ACE_HOME = __dirname;
|
var ACE_HOME = __dirname;
|
||||||
|
var BUILD_DIR = "build";
|
||||||
|
|
||||||
function main(args) {
|
function main(args) {
|
||||||
var target = "minimal";
|
var type = "minimal";
|
||||||
if (args.length == 3) {
|
args = args.map(function(x) {
|
||||||
target = args[2];
|
if (x[0] == "-" && x[1] != "-")
|
||||||
// Check if 'target' contains some allowed value.
|
return "-" + x;
|
||||||
if (!/^(normal|bm|demo|minimal)$/.test(target))
|
return x;
|
||||||
target = "help";
|
});
|
||||||
}
|
|
||||||
|
if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1))
|
||||||
|
type = args[2];
|
||||||
|
|
||||||
if (target == "help") {
|
var i = args.indexOf("--target");
|
||||||
console.log("--- Ace Dryice Build Tool ---");
|
if (i != -1 && args[i+1])
|
||||||
console.log("");
|
BUILD_DIR = args[i+1];
|
||||||
console.log("Options:");
|
|
||||||
console.log(" minimal Runs minimal build of Ace");
|
|
||||||
console.log(" normal Runs embedded build of Ace");
|
|
||||||
console.log(" demo Runs demo build of Ace");
|
|
||||||
console.log(" bm Runs bookmarklet build of Ace");
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var aceProject = {
|
if (type == "minimal") {
|
||||||
roots: [
|
buildAce({
|
||||||
ACE_HOME + '/lib',
|
compress: args.indexOf("-m") != -1,
|
||||||
ACE_HOME + '/demo'
|
noconflict: args.indexOf("-nc") != -1
|
||||||
],
|
|
||||||
textPluginPattern: /^ace\/requirejs\/text!/
|
|
||||||
};
|
|
||||||
|
|
||||||
if (target == "minimal") {
|
|
||||||
buildAce(aceProject, {
|
|
||||||
compress: false,
|
|
||||||
noconflict: false,
|
|
||||||
suffix: "",
|
|
||||||
name: "ace"
|
|
||||||
});
|
});
|
||||||
|
} else if (type == "normal") {
|
||||||
|
ace();
|
||||||
|
} else if (type == "demo") {
|
||||||
|
demo();
|
||||||
|
} else if (type == "bm") {
|
||||||
|
bookmarklet();
|
||||||
|
} else if (type == "full") {
|
||||||
|
ace();
|
||||||
|
demo();
|
||||||
|
bookmarklet();
|
||||||
}
|
}
|
||||||
if (target == "normal") {
|
|
||||||
ace(aceProject);
|
console.log("--- Ace Dryice Build Tool ---");
|
||||||
}
|
console.log("");
|
||||||
else if (target == "demo") {
|
console.log("Options:");
|
||||||
demo(aceProject);
|
console.log(" normal Runs embedded build of Ace");
|
||||||
}
|
console.log(" demo Runs demo build of Ace");
|
||||||
else if (target == "bm") {
|
console.log(" bm Runs bookmarklet build of Ace");
|
||||||
bookmarklet(aceProject);
|
console.log(" full all of above");
|
||||||
}
|
console.log("flags:");
|
||||||
|
console.log(" -m minify");
|
||||||
|
console.log(" -nc namespace require");
|
||||||
|
console.log(" --target ./path path to build folder");
|
||||||
|
console.log("");
|
||||||
|
if (BUILD_DIR)
|
||||||
|
console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR)
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bookmarklet(aceProject) {
|
function bookmarklet() {
|
||||||
var targetDir = "build/textarea";
|
var targetDir = BUILD_DIR + "/textarea";
|
||||||
copy({
|
copy({
|
||||||
source: "build_support/editor_textarea.html",
|
source: "build_support/editor_textarea.html",
|
||||||
dest: targetDir + '/editor.html'
|
dest: targetDir + '/editor.html'
|
||||||
|
|
@ -102,7 +107,7 @@ function bookmarklet(aceProject) {
|
||||||
dest: targetDir + '/style.css'
|
dest: targetDir + '/style.css'
|
||||||
});
|
});
|
||||||
|
|
||||||
buildAce(aceProject, {
|
buildAce({
|
||||||
targetDir: targetDir + "/src",
|
targetDir: targetDir + "/src",
|
||||||
ns: "__ace_shadowed__",
|
ns: "__ace_shadowed__",
|
||||||
exportModule: "ace/ext/textarea",
|
exportModule: "ace/ext/textarea",
|
||||||
|
|
@ -115,38 +120,27 @@ function bookmarklet(aceProject) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ace(aceProject) {
|
function ace() {
|
||||||
console.log('# ace ---------');
|
console.log('# ace ---------');
|
||||||
|
|
||||||
// uncompressed
|
// uncompressed
|
||||||
buildAce(aceProject, {
|
buildAce({
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: false,
|
noconflict: false
|
||||||
suffix: "",
|
|
||||||
name: "ace"
|
|
||||||
});
|
});
|
||||||
buildAce(aceProject, {
|
buildAce({
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: true,
|
noconflict: true
|
||||||
suffix: "-noconflict",
|
|
||||||
name: "ace",
|
|
||||||
workers: []
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// compressed
|
// compressed
|
||||||
buildAce(aceProject, {
|
buildAce({
|
||||||
compress: true,
|
compress: true,
|
||||||
noconflict: false,
|
noconflict: false
|
||||||
suffix: "-min",
|
|
||||||
name: "ace",
|
|
||||||
workers: []
|
|
||||||
});
|
});
|
||||||
buildAce(aceProject, {
|
buildAce({
|
||||||
compress: true,
|
compress: true,
|
||||||
noconflict: true,
|
noconflict: true
|
||||||
suffix: "-min-noconflict",
|
|
||||||
name: "ace",
|
|
||||||
workers: []
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('# ace License | Readme | Changelog ---------');
|
console.log('# ace License | Readme | Changelog ---------');
|
||||||
|
|
@ -169,7 +163,7 @@ function ace(aceProject) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function demo(aceProject) {
|
function demo() {
|
||||||
console.log('# kitchen sink ---------');
|
console.log('# kitchen sink ---------');
|
||||||
|
|
||||||
var version, ref;
|
var version, ref;
|
||||||
|
|
@ -197,7 +191,7 @@ function demo(aceProject) {
|
||||||
|
|
||||||
copy({
|
copy({
|
||||||
source: "kitchen-sink.html",
|
source: "kitchen-sink.html",
|
||||||
dest: "build/kitchen-sink.html",
|
dest: BUILD_DIR + "/kitchen-sink.html",
|
||||||
filter: [changeComments, function(data) {
|
filter: [changeComments, function(data) {
|
||||||
return data.replace(/"(demo|build)\//g, "\"");
|
return data.replace(/"(demo|build)\//g, "\"");
|
||||||
}]
|
}]
|
||||||
|
|
@ -205,14 +199,14 @@ function demo(aceProject) {
|
||||||
|
|
||||||
copy({
|
copy({
|
||||||
source: "demo/kitchen-sink/styles.css",
|
source: "demo/kitchen-sink/styles.css",
|
||||||
dest: "build/kitchen-sink/styles.css",
|
dest: BUILD_DIR + "/kitchen-sink/styles.css",
|
||||||
filter: [ changeComments ]
|
filter: [ changeComments ]
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.readdirSync("demo/kitchen-sink/docs/").forEach(function(x) {
|
fs.readdirSync("demo/kitchen-sink/docs/").forEach(function(x) {
|
||||||
copy({
|
copy({
|
||||||
source: "demo/kitchen-sink/docs/" + x,
|
source: "demo/kitchen-sink/docs/" + x,
|
||||||
dest: "build/kitchen-sink/docs/" + x
|
dest: BUILD_DIR + "/kitchen-sink/docs/" + x
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -235,22 +229,26 @@ function demo(aceProject) {
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: demo,
|
source: demo,
|
||||||
dest: "build/kitchen-sink/demo.js",
|
dest: BUILD_DIR + "/kitchen-sink/demo.js",
|
||||||
});
|
});
|
||||||
|
|
||||||
copyFileSync("demo/kitchen-sink/logo.png", "build/kitchen-sink/logo.png");
|
copyFileSync("demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildAce(aceProject, options) {
|
function buildAce(options) {
|
||||||
|
var aceProject = {
|
||||||
|
roots: [ACE_HOME + '/lib', ACE_HOME + '/demo'],
|
||||||
|
textPluginPattern: /^ace\/requirejs\/text!/
|
||||||
|
};
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
targetDir: __dirname + "/build/src",
|
targetDir: BUILD_DIR + "/src",
|
||||||
ns: "ace",
|
ns: "ace",
|
||||||
exportModule: "ace/ace",
|
exportModule: "ace/ace",
|
||||||
requires: null,
|
requires: null,
|
||||||
compress: false,
|
compress: false,
|
||||||
noconflict: false,
|
noconflict: false,
|
||||||
suffix: "",
|
suffix: null,
|
||||||
name: "ace",
|
name: "ace",
|
||||||
modes: fs.readdirSync("lib/ace/mode").map(function(x) {
|
modes: fs.readdirSync("lib/ace/mode").map(function(x) {
|
||||||
if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
|
if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
|
||||||
|
|
@ -262,15 +260,29 @@ function buildAce(aceProject, options) {
|
||||||
workers: ["javascript", "coffee", "css", "json", "xquery"],
|
workers: ["javascript", "coffee", "css", "json", "xquery"],
|
||||||
keybindings: ["vim", "emacs"]
|
keybindings: ["vim", "emacs"]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
for(var key in defaults)
|
for(var key in defaults)
|
||||||
if (!options.hasOwnProperty(key))
|
if (!options.hasOwnProperty(key))
|
||||||
options[key] = defaults[key];
|
options[key] = defaults[key];
|
||||||
|
|
||||||
|
if (options.suffix == null) {
|
||||||
|
options.suffix = "";
|
||||||
|
if (options.compress)
|
||||||
|
options.suffix += "-min";
|
||||||
|
if (options.noconflict)
|
||||||
|
options.suffix += "-noconflict";
|
||||||
|
}
|
||||||
|
|
||||||
if (!options.requires)
|
if (!options.requires)
|
||||||
options.requires = [options.exportModule];
|
options.requires = [options.exportModule];
|
||||||
|
|
||||||
var filters = [copy.filter.moduleDefines, filterTextPlugin];
|
var filters = [
|
||||||
|
copy.filter.moduleDefines,
|
||||||
|
filterTextPlugin,
|
||||||
|
removeUseStrict,
|
||||||
|
removeLicenceCmments
|
||||||
|
];
|
||||||
|
|
||||||
if (options.noconflict) {
|
if (options.noconflict) {
|
||||||
filters.push(namespace(options.ns));
|
filters.push(namespace(options.ns));
|
||||||
|
|
@ -280,20 +292,10 @@ function buildAce(aceProject, options) {
|
||||||
var exportFilter = exportAce(options.ns, options.exportModule);
|
var exportFilter = exportAce(options.ns, options.exportModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove use strict
|
|
||||||
filters.push(function(text) {
|
|
||||||
return text.replace(/['"]use strict['"];/g, "");
|
|
||||||
})
|
|
||||||
// remove redundant comments
|
|
||||||
filters.push(function(text) {
|
|
||||||
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1");
|
|
||||||
})
|
|
||||||
|
|
||||||
if (options.compress)
|
if (options.compress)
|
||||||
filters.push(copy.filter.uglifyjs);
|
filters.push(copy.filter.uglifyjs);
|
||||||
|
|
||||||
var suffix = options.suffix;
|
var targetDir = options.targetDir + options.suffix;
|
||||||
var targetDir = options.targetDir;
|
|
||||||
var name = options.name;
|
var name = options.name;
|
||||||
|
|
||||||
var project = copy.createCommonJsProject(aceProject);
|
var project = copy.createCommonJsProject(aceProject);
|
||||||
|
|
@ -304,8 +306,8 @@ function buildAce(aceProject, options) {
|
||||||
});
|
});
|
||||||
copy({
|
copy({
|
||||||
source: [{
|
source: [{
|
||||||
project: project,
|
project: project,
|
||||||
require: options.requires
|
require: options.requires
|
||||||
}],
|
}],
|
||||||
filter: [ copy.filter.moduleDefines ],
|
filter: [ copy.filter.moduleDefines ],
|
||||||
dest: ace
|
dest: ace
|
||||||
|
|
@ -314,7 +316,7 @@ function buildAce(aceProject, options) {
|
||||||
copy({
|
copy({
|
||||||
source: ace,
|
source: ace,
|
||||||
filter: exportFilter ? filters.concat(exportFilter) : filters,
|
filter: exportFilter ? filters.concat(exportFilter) : filters,
|
||||||
dest: targetDir + suffix + '/' + name + ".js"
|
dest: targetDir + '/' + name + ".js"
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('# ace modes ---------');
|
console.log('# ace modes ---------');
|
||||||
|
|
@ -324,11 +326,11 @@ function buildAce(aceProject, options) {
|
||||||
console.log("mode " + mode);
|
console.log("mode " + mode);
|
||||||
copy({
|
copy({
|
||||||
source: [{
|
source: [{
|
||||||
project: cloneProject(project),
|
project: cloneProject(project),
|
||||||
require: [ 'ace/mode/' + mode ]
|
require: [ 'ace/mode/' + mode ]
|
||||||
}],
|
}],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: targetDir + suffix + "/mode-" + mode + ".js"
|
dest: targetDir + "/mode-" + mode + ".js"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -343,7 +345,7 @@ function buildAce(aceProject, options) {
|
||||||
require: ["ace/theme/" + theme]
|
require: ["ace/theme/" + theme]
|
||||||
}],
|
}],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: targetDir + suffix + "/theme-" + theme + ".js"
|
dest: targetDir + "/theme-" + theme + ".js"
|
||||||
});*/
|
});*/
|
||||||
// use this instead, to not create separate modules for js and css
|
// use this instead, to not create separate modules for js and css
|
||||||
var themePath = "lib/ace/theme/" + theme
|
var themePath = "lib/ace/theme/" + theme
|
||||||
|
|
@ -356,43 +358,7 @@ function buildAce(aceProject, options) {
|
||||||
}
|
}
|
||||||
filters.forEach(function(f) {js = f(js); });
|
filters.forEach(function(f) {js = f(js); });
|
||||||
|
|
||||||
fs.writeFileSync(targetDir + suffix + "/theme-" + theme + ".js", js);
|
fs.writeFileSync(targetDir + "/theme-" + theme + ".js", js);
|
||||||
});
|
|
||||||
|
|
||||||
console.log('# ace worker ---------');
|
|
||||||
|
|
||||||
options.workers.forEach(function(mode) {
|
|
||||||
console.log("worker for " + mode + " mode");
|
|
||||||
var worker = copy.createDataObject();
|
|
||||||
var workerProject = copy.createCommonJsProject({
|
|
||||||
roots: [
|
|
||||||
ACE_HOME + '/lib'
|
|
||||||
],
|
|
||||||
textPluginPattern: /^ace\/requirejs\/text!/
|
|
||||||
});
|
|
||||||
copy({
|
|
||||||
source: [
|
|
||||||
{
|
|
||||||
project: workerProject,
|
|
||||||
require: [
|
|
||||||
'ace/lib/fixoldbrowsers',
|
|
||||||
'ace/lib/event_emitter',
|
|
||||||
'ace/lib/oop',
|
|
||||||
'ace/mode/' + mode + '_worker'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
filter: [ copy.filter.moduleDefines, filterTextPlugin ],
|
|
||||||
dest: worker
|
|
||||||
});
|
|
||||||
copy({
|
|
||||||
source: [
|
|
||||||
ACE_HOME + "/lib/ace/worker/worker.js",
|
|
||||||
worker
|
|
||||||
],
|
|
||||||
filter: [ /* copy.filter.uglifyjs */],
|
|
||||||
dest: targetDir + "/worker-" + mode + ".js"
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('# ace key bindings ---------');
|
console.log('# ace key bindings ---------');
|
||||||
|
|
@ -406,9 +372,49 @@ function buildAce(aceProject, options) {
|
||||||
require: [ 'ace/keyboard/' + keybinding ]
|
require: [ 'ace/keyboard/' + keybinding ]
|
||||||
}],
|
}],
|
||||||
filter: filters,
|
filter: filters,
|
||||||
dest: targetDir + suffix + "/keybinding-" + keybinding + ".js"
|
dest: targetDir + "/keybinding-" + keybinding + ".js"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('# ace worker ---------');
|
||||||
|
|
||||||
|
filters = [
|
||||||
|
copy.filter.moduleDefines,
|
||||||
|
filterTextPlugin,
|
||||||
|
removeUseStrict,
|
||||||
|
removeLicenceCmments
|
||||||
|
];
|
||||||
|
|
||||||
|
options.workers.forEach(function(mode) {
|
||||||
|
console.log("worker for " + mode + " mode");
|
||||||
|
var worker = copy.createDataObject();
|
||||||
|
var workerProject = copy.createCommonJsProject({
|
||||||
|
roots: [ ACE_HOME + '/lib' ],
|
||||||
|
textPluginPattern: /^ace\/requirejs\/text!/
|
||||||
|
});
|
||||||
|
copy({
|
||||||
|
source: [{
|
||||||
|
project: workerProject,
|
||||||
|
require: [
|
||||||
|
'ace/lib/fixoldbrowsers',
|
||||||
|
'ace/lib/event_emitter',
|
||||||
|
'ace/lib/oop',
|
||||||
|
'ace/mode/' + mode + '_worker'
|
||||||
|
]
|
||||||
|
}],
|
||||||
|
filter: filters,
|
||||||
|
dest: worker
|
||||||
|
});
|
||||||
|
copy({
|
||||||
|
source: [
|
||||||
|
ACE_HOME + "/lib/ace/worker/worker.js",
|
||||||
|
worker
|
||||||
|
],
|
||||||
|
filter: options.compress ? [copy.filter.uglifyjs] : [],
|
||||||
|
dest: targetDir + "/worker-" + mode + ".js"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: replace with project.clone once it is fixed in dryice
|
// TODO: replace with project.clone once it is fixed in dryice
|
||||||
|
|
@ -459,6 +465,14 @@ function filterTextPlugin(text) {
|
||||||
return text.replace(/(['"])ace\/requirejs\/text\!/g, "$1text!");
|
return text.replace(/(['"])ace\/requirejs\/text\!/g, "$1text!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeUseStrict(text) {
|
||||||
|
return text.replace(/['"]use strict['"];/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeLicenceCmments(text) {
|
||||||
|
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1");
|
||||||
|
}
|
||||||
|
|
||||||
function namespace(ns) {
|
function namespace(ns) {
|
||||||
return function(text) {
|
return function(text) {
|
||||||
text = text
|
text = text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue