@@ -24,78 +24,198 @@ module.exports = function (grunt) {
2424
2525 'keyboard' : 'Keyboard Input' ,
2626 'gamepad' : 'Gamepad Input' ,
27+ 'graphics' : 'Graphics Game Object' ,
28+ 'text' : 'Text and BitmapText Game Objects' ,
29+ 'retrofont' : 'RetroFont Game Object' ,
2730 'bitmapdata' : 'BitmapData' ,
28- 'graphics' : 'Graphics' ,
2931 'rendertexture' : 'RenderTextures' ,
30- 'text' : 'Text Game Object' ,
31- 'tweens' : 'Tween Manager' ,
32- 'sound' : 'Sound Manager' ,
32+ 'tweens' : 'Tween System' ,
33+ 'sound' : 'Sound System' ,
3334 'particles' : 'Particle System' ,
3435 'debug' : 'Debug System' ,
35- 'tilemap' : 'Tilemaps ' ,
36+ 'tilemap' : 'Tilemap Support ' ,
3637 'arcade' : 'Arcade Physics' ,
37- 'p2 ' : 'P2 Physics' ,
38- 'nophysics ' : 'Exclude all physics systems, tilemaps and particles '
38+ 'ninja ' : 'Ninja Physics' ,
39+ 'p2 ' : 'P2 Physics '
3940
4041 } ;
4142
42- var autoExclude = {
43-
44- 'retrofont' : 'RetroFont Game Object' ,
45- 'ninja' : 'Ninja Physics'
46-
47- }
48-
4943 grunt . log . writeln ( "----------------------------" ) ;
5044 grunt . log . writeln ( "Building Phaser " + grunt . config . get ( 'package.version' ) + '-custom' ) ;
5145 grunt . log . writeln ( "----------------------------" ) ;
5246
5347 if ( ! grunt . option ( 'exclude' ) )
5448 {
55- grunt . log . errorlns ( "No custom build options were specified." ) ;
56-
5749 grunt . log . writeln ( "\nUse --exclude to select which of the following modules to exclude:\n" ) ;
5850
5951 for ( var key in modules )
6052 {
6153 grunt . log . writeln ( key + ' - ' + modules [ key ] ) ;
6254 }
6355
64- grunt . log . writeln ( "\nThe following are excluded automatically. Use --include to include them: \n" ) ;
56+ grunt . log . writeln ( "\nFor example: --exclude p2,tilemap,retrofont \n" ) ;
6557
66- for ( var key in autoExclude )
67- {
68- grunt . log . writeln ( key + ' - ' + autoExclude [ key ] ) ;
69- }
58+ grunt . log . writeln ( "Note that some modules have dependencies on others.\n" ) ;
7059
71- grunt . log . writeln ( "\nFor example: --exclude p2,tilemap --include retrofont\n" ) ;
72-
73- grunt . log . writeln ( "Note that some modules have dependencies on others." ) ;
60+ grunt . fail . fatal ( "No build options were specified." ) ;
7461 }
7562 else
7663 {
7764 grunt . log . writeln ( "Excluding modules:\n" ) ;
7865
7966 var excludes = grunt . option ( 'exclude' ) . split ( ',' ) ;
8067
68+ for ( var key in modules )
69+ {
70+ grunt . config . set ( [ 'custom' , key ] , true ) ;
71+ }
72+
8173 for ( var i = 0 ; i < excludes . length ; i ++ )
8274 {
8375 if ( modules [ excludes [ i ] ] )
8476 {
77+ // It's a valid module
8578 grunt . log . writeln ( "* " + excludes [ i ] + ' - ' + modules [ excludes [ i ] ] ) ;
79+ grunt . config . set ( [ 'custom' , excludes [ i ] ] , false ) ;
8680 }
8781 else
8882 {
8983 grunt . fail . fatal ( "Unknown module '" + excludes [ i ] + "'" ) ;
9084 }
9185 }
9286
93- grunt . log . writeln ( "Building blah blah :\n" ) ;
87+ grunt . log . writeln ( "\nBuilding ... :\n" ) ;
9488
95- }
89+ // Clean the dist folder
90+ var tasks = [ 'clean:dist' ] ;
91+
92+ // Concat the module files
93+ for ( var key in modules )
94+ {
95+ if ( grunt . config . get ( [ 'custom' , key ] ) )
96+ {
97+ tasks . push ( 'concat:' + key ) ;
98+ }
99+ }
96100
101+ // Concat all the modules together into a single custom build
97102
103+ var filelist = [ ] ;
104+
105+ filelist . push ( '<%= concat.intro.dest %>' ) ;
106+ filelist . push ( '<%= concat.geom.dest %>' ) ;
107+ filelist . push ( '<%= concat.core.dest %>' ) ;
108+ filelist . push ( '<%= concat.input.dest %>' ) ;
109+
110+ if ( grunt . config . get ( 'custom.keyboard' ) )
111+ {
112+ filelist . push ( '<%= concat.keyboard.dest %>' ) ;
113+ }
114+
115+ if ( grunt . config . get ( 'custom.gamepad' ) )
116+ {
117+ filelist . push ( '<%= concat.gamepad.dest %>' ) ;
118+ }
119+
120+ filelist . push ( '<%= concat.components.dest %>' ) ;
121+ filelist . push ( '<%= concat.gameobjects.dest %>' ) ;
122+
123+ if ( grunt . config . get ( 'custom.bitmapdata' ) )
124+ {
125+ filelist . push ( '<%= concat.bitmapdata.dest %>' ) ;
126+ }
127+
128+ if ( grunt . config . get ( 'custom.graphics' ) )
129+ {
130+ filelist . push ( '<%= concat.graphics.dest %>' ) ;
131+ }
132+
133+ if ( grunt . config . get ( 'custom.rendertexture' ) )
134+ {
135+ filelist . push ( '<%= concat.rendertexture.dest %>' ) ;
136+ }
137+
138+ if ( grunt . config . get ( 'custom.text' ) )
139+ {
140+ filelist . push ( '<%= concat.text.dest %>' ) ;
141+ }
98142
143+ if ( grunt . config . get ( 'custom.bitmaptext' ) )
144+ {
145+ filelist . push ( '<%= concat.bitmaptext.dest %>' ) ;
146+ }
147+
148+ if ( grunt . config . get ( 'custom.retrofont' ) )
149+ {
150+ filelist . push ( '<%= concat.retrofont.dest %>' ) ;
151+ }
152+
153+ filelist . push ( '<%= concat.system.dest %>' ) ;
154+ filelist . push ( '<%= concat.math.dest %>' ) ;
155+ filelist . push ( '<%= concat.net.dest %>' ) ;
156+
157+ if ( grunt . config . get ( 'custom.tweens' ) )
158+ {
159+ filelist . push ( '<%= concat.tweens.dest %>' ) ;
160+ }
161+ else
162+ {
163+ // TweenManager stub
164+ }
165+
166+ filelist . push ( '<%= concat.time.dest %>' ) ;
167+ filelist . push ( '<%= concat.animation.dest %>' ) ;
168+ filelist . push ( '<%= concat.loader.dest %>' ) ;
169+
170+ if ( grunt . config . get ( 'custom.sound' ) )
171+ {
172+ filelist . push ( '<%= concat.sound.dest %>' ) ;
173+ }
174+ else
175+ {
176+ // SoundManager stub
177+ }
178+
179+ if ( grunt . config . get ( 'custom.debug' ) )
180+ {
181+ filelist . push ( '<%= concat.debug.dest %>' ) ;
182+ }
183+
184+ filelist . push ( '<%= concat.utils.dest %>' ) ;
185+ filelist . push ( '<%= concat.physics.dest %>' ) ;
186+
187+ if ( grunt . config . get ( 'custom.particles' ) )
188+ {
189+ filelist . push ( '<%= concat.particles.dest %>' ) ;
190+ }
191+
192+ if ( grunt . config . get ( 'custom.tilemap' ) )
193+ {
194+ filelist . push ( '<%= concat.tilemap.dest %>' ) ;
195+ }
196+
197+ if ( grunt . config . get ( 'custom.arcade' ) )
198+ {
199+ filelist . push ( '<%= concat.arcade.dest %>' ) ;
200+ }
201+
202+ // + arcade tmap col
203+
204+ if ( grunt . config . get ( 'custom.p2' ) )
205+ {
206+ filelist . push ( '<%= concat.p2.dest %>' ) ;
207+ }
208+
209+ if ( grunt . config . get ( 'custom.ninja' ) )
210+ {
211+ filelist . push ( '<%= concat.ninja.dest %>' ) ;
212+ }
213+
214+ tasks . push ( 'concat:custom' ) ;
215+ tasks . push ( 'uglify:custom' ) ;
216+
217+ grunt . task . run ( tasks ) ;
218+ }
99219
100220 } ) ;
101221
0 commit comments