2015-01-22 12:37:58 +00:00
|
|
|
/// <binding />
|
2013-10-23 12:15:56 +00:00
|
|
|
module.exports = function (grunt) {
|
2014-04-01 02:02:36 +00:00
|
|
|
|
2014-03-23 04:39:43 +00:00
|
|
|
var loadConfig = require('load-grunt-config');
|
2013-10-23 12:15:56 +00:00
|
|
|
|
2014-03-23 04:39:43 +00:00
|
|
|
loadConfig(grunt, {
|
|
|
|
configPath: __dirname + '/tasks/options',
|
|
|
|
config: {
|
2015-02-19 17:23:35 +00:00
|
|
|
target_dir: 'build',
|
2014-03-23 04:39:43 +00:00
|
|
|
release_dir: 'build',
|
2015-02-19 17:23:35 +00:00
|
|
|
release_custom_dir: 'build/custom',
|
2014-04-01 02:02:36 +00:00
|
|
|
compile_dir: 'dist',
|
2015-02-19 05:01:50 +00:00
|
|
|
modules_dir: 'dist/modules',
|
2014-11-25 00:22:57 +00:00
|
|
|
docs_dir: 'docs',
|
2015-02-19 17:23:35 +00:00
|
|
|
sourcemap: false,
|
|
|
|
filename: 'phaser',
|
2015-02-19 15:27:44 +00:00
|
|
|
filelist: [],
|
2014-04-01 02:02:36 +00:00
|
|
|
banner: require('fs').readFileSync(__dirname + '/tasks/banner.txt', 'utf8')
|
2014-03-23 06:23:45 +00:00
|
|
|
}
|
2014-02-28 09:30:53 +00:00
|
|
|
});
|
|
|
|
|
2014-03-23 04:39:43 +00:00
|
|
|
grunt.loadTasks('tasks');
|
|
|
|
|
2014-03-17 16:10:04 +00:00
|
|
|
grunt.registerTask('default', ['build']);
|
2014-03-23 06:23:45 +00:00
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.registerTask('docs', ['clean:docs', 'pixidoc', 'jsdoc:html', 'replace:docs', 'clean:out']);
|
|
|
|
grunt.registerTask('tsdocs', ['clean:out', 'pixidoc', 'gitclone:plugins', 'jsdoc:json', 'buildtsdoc:pixi', 'buildtsdoc:phaser', 'replace:phasertsdefheader', 'clean:out']);
|
|
|
|
|
2015-02-19 05:01:50 +00:00
|
|
|
grunt.registerTask('custom', 'Build a custom version of Phaser', function(arg) {
|
|
|
|
|
|
|
|
var modules = {
|
|
|
|
|
2015-07-22 11:44:03 +00:00
|
|
|
'pixi': { 'description': 'Pixi.js (custom Phaser build)', 'optional': false, 'stub': false },
|
2015-03-26 02:10:57 +00:00
|
|
|
'intro': { 'description': 'Phaser UMD wrapper', 'optional': true, 'stub': false },
|
2015-02-27 11:57:06 +00:00
|
|
|
'phaser': { 'description': 'Phaser Globals', 'optional': false, 'stub': false },
|
|
|
|
'geom': { 'description': 'Geometry Classes', 'optional': false, 'stub': false },
|
|
|
|
'core': { 'description': 'Phaser Core', 'optional': false, 'stub': false },
|
|
|
|
'input': { 'description': 'Input Manager + Mouse and Touch Support', 'optional': false, 'stub': false },
|
|
|
|
'gamepad': { 'description': 'Gamepad Input', 'optional': true, 'stub': false },
|
|
|
|
'keyboard': { 'description': 'Keyboard Input', 'optional': true, 'stub': false },
|
|
|
|
'components': { 'description': 'Game Object Components', 'optional': false, 'stub': false },
|
|
|
|
'gameobjects': { 'description': 'Core Game Objects', 'optional': false, 'stub': false },
|
|
|
|
'bitmapdata': { 'description': 'BitmapData Game Object', 'optional': true, 'stub': false },
|
|
|
|
'graphics': { 'description': 'Graphics Game Object', 'optional': true, 'stub': false },
|
|
|
|
'rendertexture': { 'description': 'RenderTexture Game Object', 'optional': true, 'stub': false },
|
|
|
|
'text': { 'description': 'Text Game Object (inc. Web Font Support)', 'optional': true, 'stub': false },
|
2015-03-26 02:10:57 +00:00
|
|
|
'bitmaptext': { 'description': 'BitmapText Game Object', 'optional': true, 'stub': false },
|
|
|
|
'retrofont': { 'description': 'Retro Fonts Game Object', 'optional': true, 'stub': false },
|
2015-07-22 11:44:03 +00:00
|
|
|
'rope': { 'description': 'Rope and Strip Game Object', 'optional': true, 'stub': false },
|
|
|
|
'tilesprite': { 'description': 'Tile Sprite Game Object', 'optional': true, 'stub': false },
|
2015-02-27 11:57:06 +00:00
|
|
|
'system': { 'description': 'System Classes', 'optional': false, 'stub': false },
|
|
|
|
'math': { 'description': 'Math, QuadTree and RND', 'optional': false, 'stub': false },
|
2015-04-29 13:07:06 +00:00
|
|
|
'net': { 'description': 'Network Class', 'optional': true, 'stub': true },
|
2015-02-27 11:57:06 +00:00
|
|
|
'tweens': { 'description': 'Tween Manager', 'optional': true, 'stub': true },
|
|
|
|
'time': { 'description': 'Time and Clock Manager', 'optional': false, 'stub': false },
|
|
|
|
'animation': { 'description': 'Animation and Frame Manager', 'optional': false, 'stub': false },
|
|
|
|
'loader': { 'description': 'Loader and Cache', 'optional': false, 'stub': false },
|
|
|
|
'sound': { 'description': 'Sound Support (Web Audio and HTML Audio)', 'optional': true, 'stub': true },
|
2015-04-29 13:07:06 +00:00
|
|
|
'debug': { 'description': 'Debug Class', 'optional': true, 'stub': true },
|
2015-02-27 11:57:06 +00:00
|
|
|
'utils': { 'description': 'Core Utilities', 'optional': false, 'stub': false },
|
|
|
|
'physics': { 'description': 'Physics Manager', 'optional': false, 'stub': false },
|
|
|
|
'arcade': { 'description': 'Arcade Physics', 'optional': true, 'stub': false },
|
|
|
|
'ninja': { 'description': 'Ninja Physics', 'optional': true, 'stub': false },
|
|
|
|
'p2': { 'description': 'P2 Physics', 'optional': true, 'stub': false },
|
|
|
|
'tilemaps': { 'description': 'Tilemap Support', 'optional': true, 'stub': false },
|
|
|
|
'particles': { 'description': 'Arcade Physics Particle System', 'optional': true, 'stub': true },
|
2015-04-13 22:16:29 +00:00
|
|
|
'creature': { 'description': 'Creature Animation Tool Support', 'optional': true, 'stub': false },
|
2015-05-06 06:58:04 +00:00
|
|
|
'video': { 'description': 'Video Game Object', 'optional': true, 'stub': false },
|
2015-03-26 02:10:57 +00:00
|
|
|
'outro': { 'description': 'Phaser UMD closure', 'optional': true, 'stub': false }
|
2015-02-19 15:27:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.log.writeln("---------------------");
|
|
|
|
grunt.log.writeln("Building Phaser " + grunt.config.get('package.version'));
|
|
|
|
grunt.log.writeln("---------------------");
|
2015-02-19 05:01:50 +00:00
|
|
|
|
|
|
|
if (!grunt.option('exclude'))
|
|
|
|
{
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.log.writeln("\nUse --exclude to select which modules to exclude:\n");
|
2015-02-19 05:01:50 +00:00
|
|
|
|
2015-02-22 20:08:44 +00:00
|
|
|
for (var module in modules)
|
2015-02-19 05:01:50 +00:00
|
|
|
{
|
2015-02-22 20:08:44 +00:00
|
|
|
if (modules[module].optional)
|
2015-02-19 15:27:44 +00:00
|
|
|
{
|
2015-02-22 20:08:44 +00:00
|
|
|
grunt.log.writeln(module + ' - ' + modules[module].description);
|
2015-02-19 15:27:44 +00:00
|
|
|
}
|
2015-02-19 05:01:50 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 00:58:59 +00:00
|
|
|
grunt.log.writeln("\nFor example: --exclude p2,tilemap,retrofont");
|
|
|
|
grunt.log.writeln("Optional flags: --filename yourfilename and --sourcemap true");
|
2015-02-19 06:03:42 +00:00
|
|
|
grunt.log.writeln("Note that some modules have dependencies on others.\n");
|
2015-02-19 05:01:50 +00:00
|
|
|
|
2015-02-19 06:03:42 +00:00
|
|
|
grunt.fail.fatal("No build options were specified.");
|
2015-02-19 05:01:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 17:23:35 +00:00
|
|
|
// Defaults
|
|
|
|
grunt.config.set('sourcemap', false);
|
|
|
|
grunt.config.set('filename', 'phaser');
|
|
|
|
grunt.config.set('target_dir', '<%= release_dir %>');
|
|
|
|
|
|
|
|
// Overrides
|
|
|
|
if (grunt.option('filename'))
|
|
|
|
{
|
|
|
|
grunt.config.set('filename', grunt.option('filename'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grunt.option('sourcemap'))
|
|
|
|
{
|
|
|
|
grunt.config.set('sourcemap', grunt.option('sourcemap'));
|
|
|
|
}
|
|
|
|
|
2015-02-19 05:01:50 +00:00
|
|
|
grunt.log.writeln("Excluding modules:\n");
|
|
|
|
|
|
|
|
var excludes = grunt.option('exclude').split(',');
|
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
// Check the given modules are all valid
|
2015-02-19 05:01:50 +00:00
|
|
|
for (var i = 0; i < excludes.length; i++)
|
|
|
|
{
|
2015-02-22 20:08:44 +00:00
|
|
|
var exclude = excludes[i];
|
2015-02-19 15:27:44 +00:00
|
|
|
|
2015-02-22 20:08:44 +00:00
|
|
|
if (modules[exclude])
|
2015-02-19 05:01:50 +00:00
|
|
|
{
|
2015-02-22 20:08:44 +00:00
|
|
|
grunt.log.writeln("* " + exclude + ' - ' + modules[exclude].description);
|
2015-02-19 05:01:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-22 20:08:44 +00:00
|
|
|
grunt.fail.fatal("Unknown module '" + exclude + "'");
|
2015-02-19 06:03:42 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-19 05:01:50 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
// Handle basic dependencies
|
2015-02-19 05:01:50 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
if (excludes['arcade'] && !excludes['particles'])
|
2015-02-19 06:03:42 +00:00
|
|
|
{
|
2015-02-19 15:27:44 +00:00
|
|
|
grunt.log.writeln("Warning: Particles rely on Arcade Physics. Excluding from build.");
|
|
|
|
excludes.push('particles');
|
2015-02-19 06:03:42 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
if (excludes['rendertexture'] && !excludes['retrofont'])
|
2015-02-19 06:03:42 +00:00
|
|
|
{
|
2015-02-19 15:27:44 +00:00
|
|
|
grunt.log.writeln("Warning: RetroFonts rely on RenderTextures. Excluding from build.");
|
|
|
|
excludes.push('retrofont');
|
2015-02-19 06:03:42 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
// Ok we know the excludes array is fine, let's get this show started
|
2015-02-19 06:03:42 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
grunt.log.writeln("\nBuilding ...\n");
|
2015-02-19 06:03:42 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
var filelist = [];
|
2015-02-19 06:03:42 +00:00
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
// Clean the working folder
|
|
|
|
var tasks = [ 'clean:build' ];
|
2015-02-19 06:03:42 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
for (var key in modules)
|
2015-02-19 06:03:42 +00:00
|
|
|
{
|
2015-02-27 11:57:06 +00:00
|
|
|
if (modules[key].stub && excludes.indexOf(key) !== -1)
|
2015-02-19 15:27:44 +00:00
|
|
|
{
|
2015-02-27 11:57:06 +00:00
|
|
|
// If the module IS excluded and has a stub, we need that
|
|
|
|
tasks.push('concat:' + key + 'Stub');
|
|
|
|
|
|
|
|
filelist.push('<%= modules_dir %>/' + key + '.js');
|
|
|
|
}
|
|
|
|
else if (modules[key].optional === false || excludes.indexOf(key) === -1)
|
|
|
|
{
|
|
|
|
// If it's required or NOT excluded, add it to the tasks list
|
2015-02-19 15:27:44 +00:00
|
|
|
tasks.push('concat:' + key);
|
2015-02-19 06:03:42 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
filelist.push('<%= modules_dir %>/' + key + '.js');
|
2015-02-19 06:03:42 +00:00
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
// Special case: If they have Arcade Physics AND Tilemaps we need to include the Tilemap Collision class
|
|
|
|
if (key === 'arcade' && !excludes['tilemaps'])
|
|
|
|
{
|
|
|
|
tasks.push('concat:arcadeTilemaps');
|
|
|
|
filelist.push('<%= modules_dir %>/arcadeTilemaps.js');
|
|
|
|
}
|
|
|
|
}
|
2015-02-19 06:03:42 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 15:27:44 +00:00
|
|
|
grunt.config.set('filelist', filelist);
|
2015-02-19 06:03:42 +00:00
|
|
|
|
|
|
|
tasks.push('concat:custom');
|
2015-02-19 15:27:44 +00:00
|
|
|
|
2015-02-19 06:03:42 +00:00
|
|
|
tasks.push('uglify:custom');
|
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
if (grunt.option('copy'))
|
|
|
|
{
|
|
|
|
tasks.push('copy:custom');
|
|
|
|
}
|
|
|
|
else if (grunt.option('copycustom'))
|
|
|
|
{
|
|
|
|
grunt.config.set('target_dir', '<%= release_custom_dir %>');
|
|
|
|
tasks.push('copy:custom');
|
|
|
|
}
|
2015-02-19 15:27:44 +00:00
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.task.run(tasks);
|
2015-02-19 15:27:44 +00:00
|
|
|
|
2015-02-19 06:03:42 +00:00
|
|
|
}
|
2015-02-19 05:01:50 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-02-25 02:59:00 +00:00
|
|
|
grunt.registerTask('dist', 'Compile all Phaser versions and copy to the build folder', function() {
|
2015-02-19 17:23:35 +00:00
|
|
|
|
|
|
|
grunt.task.run('clean:release');
|
|
|
|
grunt.task.run('full');
|
|
|
|
grunt.task.run('arcadephysics');
|
|
|
|
grunt.task.run('nophysics');
|
|
|
|
grunt.task.run('minimum');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-02-25 02:59:00 +00:00
|
|
|
grunt.registerTask('build', 'Compile all Phaser versions just to the dist folder', function() {
|
|
|
|
|
2015-04-13 22:16:29 +00:00
|
|
|
grunt.option('exclude', 'ninja,creature');
|
2015-02-25 02:59:00 +00:00
|
|
|
grunt.option('filename', 'phaser');
|
|
|
|
grunt.option('sourcemap', true);
|
|
|
|
grunt.option('copy', false);
|
|
|
|
|
|
|
|
grunt.task.run('custom');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.registerTask('full', 'Phaser complete', function() {
|
2015-02-19 05:01:50 +00:00
|
|
|
|
2015-04-13 22:16:29 +00:00
|
|
|
grunt.option('exclude', 'ninja,creature');
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.option('filename', 'phaser');
|
|
|
|
grunt.option('sourcemap', true);
|
|
|
|
grunt.option('copy', true);
|
2014-04-01 02:02:36 +00:00
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.task.run('custom');
|
2013-10-23 12:15:56 +00:00
|
|
|
|
2015-02-19 17:23:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask('arcadephysics', 'Phaser with Arcade Physics, Tilemaps and Particles', function() {
|
|
|
|
|
2015-04-13 22:16:29 +00:00
|
|
|
grunt.option('exclude', 'ninja,p2,creature');
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.option('filename', 'phaser-arcade-physics');
|
|
|
|
grunt.option('sourcemap', true);
|
|
|
|
grunt.option('copy', false);
|
|
|
|
grunt.option('copycustom', true);
|
|
|
|
|
|
|
|
grunt.task.run('custom');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask('nophysics', 'Phaser without physics, tilemaps or particles', function() {
|
|
|
|
|
2015-04-13 22:16:29 +00:00
|
|
|
grunt.option('exclude', 'arcade,ninja,p2,tilemaps,particles,creature');
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.option('filename', 'phaser-no-physics');
|
|
|
|
grunt.option('sourcemap', true);
|
|
|
|
grunt.option('copy', false);
|
|
|
|
grunt.option('copycustom', true);
|
|
|
|
|
|
|
|
grunt.task.run('custom');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask('minimum', 'Phaser without any optional modules except Pixi', function() {
|
|
|
|
|
2015-07-22 11:44:03 +00:00
|
|
|
grunt.option('exclude', 'gamepad,keyboard,bitmapdata,graphics,rendertexture,text,bitmaptext,retrofont,net,tweens,sound,debug,arcade,ninja,p2,tilemaps,particles,creature,video,rope,tilesprite');
|
2015-02-19 17:23:35 +00:00
|
|
|
grunt.option('filename', 'phaser-minimum');
|
|
|
|
grunt.option('sourcemap', true);
|
|
|
|
grunt.option('copy', false);
|
|
|
|
grunt.option('copycustom', true);
|
|
|
|
|
|
|
|
grunt.task.run('custom');
|
|
|
|
|
|
|
|
});
|
2014-11-03 19:30:33 +00:00
|
|
|
|
2013-10-23 12:15:56 +00:00
|
|
|
};
|