Skip to content

Commit

Permalink
Merge build process for normal and bookmarklet build
Browse files Browse the repository at this point in the history
  • Loading branch information
jviereck authored and fjakobs committed May 23, 2011
1 parent bc93a71 commit 2bf1429
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 96 deletions.
4 changes: 2 additions & 2 deletions Makefile
@@ -1,8 +1,8 @@
build:
mkdir -p build/src
mkdir -p build/textarea/src
./Makefile.dryice.js
./Makefile.dryice.textarea.js
./Makefile.dryice.js normal
./Makefile.dryice.js bm

clean:
rm -rf build
Expand Down
275 changes: 181 additions & 94 deletions Makefile.dryice.js
Expand Up @@ -36,22 +36,68 @@
*
* ***** END LICENSE BLOCK ***** */

var args = process.argv;
var target = null;
var targetDir = null;
if (args.length == 3) {
target = args[2];
// Check if 'target' contains some allowed value.
if (target != "normal" && target != "bm") {
target = null;
}
}

if (!target) {
console.log("--- Ace Dryice Build Tool ---");
console.log("");
console.log("Options:");
console.log(" normal Runs embedded build of Ace");
console.log(" bm Runs bookmarklet build of Ace");
process.exit(0);
} else {
if (target == "normal") {
targetDir = "build";
} else {
targetDir = "build/textarea";
function shadow(input) {
if (typeof input !== 'string') {
input = input.toString();
}

return input.replace(/define\(/g, "__ace_shadowed__.define(");
}
}
}

console.log("using targetDir '", targetDir, "'");

var copy = require('dryice').copy;

var aceHome = __dirname;

console.log('# ace ---------');

var project = copy.createCommonJsProject([
var aceProject = [
aceHome + '/support/pilot/lib',
aceHome + '/lib',
aceHome + '/demo'
]);
aceHome + '/lib'
];

if (target == "normal") {
aceProject.push(aceHome + '/demo');

copy({
source: "build_support/editor.html",
dest: targetDir + '/editor.html'
});
} else if(target == "bm") {
copy({
source: "build_support/editor_textarea.html",
dest: targetDir + '/editor.html'
});
}

var project = copy.createCommonJsProject(aceProject);

copy({
source: "build_support/editor.html",
dest: 'build/editor.html'
});

function filterTextPlugin(text) {
return text.replace(/(['"])text\!/g, "$1text/");
Expand All @@ -63,7 +109,9 @@ function filterTextPlugin(text) {
var ace = copy.createDataObject();
copy({
source: [
'build_support/mini_require.js'
target == "normal"
? 'build_support/mini_require.js'
: 'build_support/mini_require_textarea.js'
],
dest: ace
});
Expand Down Expand Up @@ -91,70 +139,57 @@ copy({
});
copy({
source: [
'build_support/boot.js'
target == "normal"
? 'build_support/boot.js'
: 'build_support/boot_textarea.js'
],
dest: ace
});

if (target == "normal") {
// Create the compressed and uncompressed output files
copy({
source: ace,
filter: [copy.filter.uglifyjs, filterTextPlugin],
dest: targetDir + '/src/ace.js'
});
copy({
source: ace,
filter: [filterTextPlugin],
dest: targetDir + '/src/ace-uncompressed.js'
});
} else if (target == "bm") {
copy({
source: ace,
filter: [
shadow,
copy.filter.uglifyjs
],
dest: targetDir + '/src/ace.js'
});
copy({
source: ace,
filter: [
shadow
],
dest: targetDir + '/src/ace-uncompressed.js'
});
}

// Create the compressed and uncompressed output files
copy({
source: ace,
filter: [copy.filter.uglifyjs, filterTextPlugin],
dest: 'build/src/ace.js'
});
copy({
source: ace,
filter: [filterTextPlugin],
dest: 'build/src/ace-uncompressed.js'
});

console.log('# cockpit ---------');

project.assumeAllFilesLoaded();
project.addRoot(aceHome + '/support/cockpit/lib');

var cockpit = copy.createDataObject();
copy({
source: [
copy.source.commonjs({
project: project,
require: [ 'cockpit/index' ]
})
],
filter: [ copy.filter.moduleDefines ],
dest: cockpit
});
copy({
source: {
root: aceHome + '/support/cockpit/lib',
include: /.*\.css$|.*\.html$/,
exclude: /tests?\//
},
filter: [ copy.filter.addDefines ],
dest: cockpit
});
copy({
source: {
root: aceHome + '/support/cockpit/lib',
include: /.*\.png$|.*\.gif$/,
exclude: /tests?\//
},
filter: [ copy.filter.base64 ],
dest: cockpit
});

// Create the compressed and uncompressed output files
copy({
source: cockpit,
filter: copy.filter.uglifyjs,
dest: 'build/src/cockpit.js'
});
copy({
source: cockpit,
dest: 'build/src/cockpit-uncompressed.js'
});

var modeThemeFilters;
if (target == "normal") {
modeThemeFilters = [
copy.filter.moduleDefines,
copy.filter.uglifyjs,
filterTextPlugin
];
} else if (target == "bm") {
modeThemeFilters = [
copy.filter.moduleDefines,
shadow,
copy.filter.uglifyjs
]
}

console.log('# ace modes ---------');

Expand All @@ -171,12 +206,49 @@ project.assumeAllFilesLoaded();
require: [ 'ace/mode/' + mode ]
})
],
filter: [ copy.filter.debug, copy.filter.moduleDefines, copy.filter.uglifyjs, filterTextPlugin ],
dest: "build/src/mode-" + mode + ".js"
filter: modeThemeFilters,
dest: targetDir + "/src/mode-" + mode + ".js"
});
});

console.log('# worker ---------');
console.log('# ace themes ---------');

[
"clouds", "clouds_midnight", "cobalt", "dawn", "idle_fingers", "kr_theme",
"mono_industrial", "monokai", "pastel_on_dark", "twilight", "eclipse",
"merbivore", "merbivore_soft", "vibrant_ink"
].forEach(function(theme) {
copy({
source: [{
root: aceHome + '/lib',
include: "ace/theme/" + theme + ".js"
}],
filter: modeThemeFilters,
dest: targetDir + "/src/theme-" + theme + ".js"
});
});

console.log('# ace License | Readme | Changelog ---------');

copy({
source: aceHome + "/LICENSE",
dest: targetDir + '/LICENSE'
});
copy({
source: aceHome + "/Readme.md",
dest: targetDir + '/Readme.md'
});
copy({
source: aceHome + "/ChangeLog.txt",
dest: targetDir + '/ChangeLog.txt'
});

// For the bookmarklet build, we are done.
if (target == "bm") {
process.exit(0);
}

console.log('# ace worker ---------');

["javascript", "coffee"].forEach(function(mode) {
console.log("worker for " + mode + " mode");
Expand Down Expand Up @@ -210,22 +282,7 @@ console.log('# worker ---------');
});
});

console.log('# ace themes ---------');

[
"clouds", "clouds_midnight", "cobalt", "dawn", "idle_fingers", "kr_theme",
"mono_industrial", "monokai", "pastel_on_dark", "twilight", "eclipse",
"merbivore", "merbivore_soft", "vibrant_ink"
].forEach(function(theme) {
copy({
source: [{
root: aceHome + '/lib',
include: "ace/theme/" + theme + ".js"
}],
filter: [ copy.filter.moduleDefines, copy.filter.uglifyjs, filterTextPlugin ],
dest: "build/src/theme-" + theme + ".js"
});
});
console.log('# ace key bindings ---------');

// copy key bindings
project.assumeAllFilesLoaded();
Expand All @@ -242,20 +299,50 @@ project.assumeAllFilesLoaded();
});
});

console.log('# cockpit ---------');

console.log('# License | Readme | Changelog ---------');
project.assumeAllFilesLoaded();
project.addRoot(aceHome + '/support/cockpit/lib');

var cockpit = copy.createDataObject();
copy({
source: aceHome + "/LICENSE",
dest: 'build/LICENSE'
source: [
copy.source.commonjs({
project: project,
require: [ 'cockpit/index' ]
})
],
filter: [ copy.filter.moduleDefines ],
dest: cockpit
});
copy({
source: aceHome + "/Readme.md",
dest: 'build/Readme.md'
source: {
root: aceHome + '/support/cockpit/lib',
include: /.*\.css$|.*\.html$/,
exclude: /tests?\//
},
filter: [ copy.filter.addDefines ],
dest: cockpit
});
copy({
source: aceHome + "/ChangeLog.txt",
dest: 'build/ChangeLog.txt'
source: {
root: aceHome + '/support/cockpit/lib',
include: /.*\.png$|.*\.gif$/,
exclude: /tests?\//
},
filter: [ copy.filter.base64 ],
dest: cockpit
});

// Create the compressed and uncompressed output files
copy({
source: cockpit,
filter: copy.filter.uglifyjs,
dest: 'build/src/cockpit.js'
});
copy({
source: cockpit,
dest: 'build/src/cockpit-uncompressed.js'
});

// copy complex demo
Expand Down

0 comments on commit 2bf1429

Please sign in to comment.