@@ -5,60 +5,67 @@ module.exports = (grunt) ->
55 grunt .file .readJSON (' package.json' )
66
77 # !! Compile configurations
8- License = ' /*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
9- FilterType = " Simple" # "Comment" || "Simple"
8+ LICENSE = ' /*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
109 # !! End of config area
1110
1211 CSS = [
1312 ' src/css/base.css' ,
1413 ' src/css/fontalias.css'
1514 ]
1615
17- SRC_CORE_CMP = [
18- ' Comment'
19- ' CommentSpaceAllocator'
20- ]
21-
2216 SRC_CORE = [
2317 ' src/Array.js'
2418 ' src/core/CommentSpaceAllocator.js'
2519 ' src/core/Comment.js'
26- ' src/filter/' + FilterType + ' Filter.js'
27- ' src/CommentCoreLibrary.js'
20+ ' src/CommentManager.js'
2821 ]
29-
30- SRC_SCRIPTING_KAGEROU =
31- display : ' src/scripting/api/Display/Display.ts'
32- runtime : ' src/scripting/api/Runtime/Runtime.ts'
33- player : ' src/scripting/api/Player/Player.ts'
34- utils : ' src/scripting/api/Utils/Utils.ts'
35- tween : ' src/scripting/api/Tween/Tween.ts'
36-
37- SRC_PARSER = [
38- ' src/CommentProvider.js'
39- ' src/parsers/AcfunFormat.js'
40- ' src/parsers/BilibiliFormat.js'
41- ' src/parsers/CommonDanmakuFormat.js'
22+
23+ SRC_MODULES =
24+ ' filter' : [' src/filter/SimpleFilter.js' ]
25+ ' provider' : [' src/CommentProvider.js' ]
26+ ' format-bilibili' : [' src/parsers/BilibiliFormat.js' ]
27+ ' format-acfun' : [' src/parsers/AcfunFormat.js' ]
28+ ' format-common' : [' src/parsers/CommonDanmakuFormat.js' ]
29+
30+ # Typescript targets
31+ SRC_TS_CORE = [
32+ ' Comment'
33+ ' CommentSpaceAllocator'
4234 ]
4335
44- # !! Below are compile settings
36+ SRC_TS_SCRIPTING_KAGEROU =
37+ ' display' : ' src/scripting/api/Display/Display.ts'
38+ ' runtime' : ' src/scripting/api/Runtime/Runtime.ts'
39+ ' player' : ' src/scripting/api/Player/Player.ts'
40+ ' utils' : ' src/scripting/api/Utils/Utils.ts'
41+ ' tween' : ' src/scripting/api/Tween/Tween.ts'
42+
43+ # ==== Below this point is logic to generate compile configurations ====
44+ # You probably do not need to edit anything below here
45+
46+ # Dynamically generate the target for all
47+ CMP_ALL = []
48+ CMP_ALL = CMP_ALL .concat SRC_CORE
49+ for name, source of SRC_MODULES
50+ CMP_ALL = CMP_ALL .concat source
51+
4552 # Dynamically generate the core ts targets
46- CMP_CORE_TS = { }
47- CMP_CORE_NAME = [ ]
48- for target in SRC_CORE_CMP
49- CMP_CORE_NAME .push (" ts:" + target)
50- CMP_CORE_TS[target] =
53+ CMP_CORE_TS = {}
54+ CMP_CORE_NAME = []
55+ for target in SRC_TS_CORE
56+ CMP_CORE_NAME .push (" ts:core_ " + target)
57+ CMP_CORE_TS[" core_ " + target] =
5158 src : [" src/core/" + target + " .ts" ]
5259 out : " src/core/" + target + " .js"
5360
5461 # Dynamically generate the kagerou ts targets
55- CMP_KAGEROU_TS = { }
56- CMP_KAGEROU_NAME = [ ]
57- for target,src of SRC_SCRIPTING_KAGEROU
62+ CMP_KAGEROU_TS = {}
63+ CMP_KAGEROU_NAME = []
64+ for target,src of SRC_TS_SCRIPTING_KAGEROU
5865 CMP_KAGEROU_NAME .push (' ts:kagerou_engine_' + target)
5966 CMP_KAGEROU_TS[' kagerou_engine_' + target] =
6067 src : src
61- out : ' build /scripting/api/' + src .split (' /' ).pop ().split (' .' )[0 ] + ' .js'
68+ out : ' dist /scripting/api/' + src .split (' /' ).pop ().split (' .' )[0 ] + ' .js'
6269
6370 # Append Typescript Tasks
6471 ts_config =
@@ -69,32 +76,30 @@ module.exports = (grunt) ->
6976 for key,value of CMP_KAGEROU_TS
7077 ts_config[key] = value
7178
72- # Core concatenated with libraries
73- # Actual concat ordering does not/should not matter
74- SRC_CORELIB = SRC_CORE .concat (SRC_PARSER)
79+ grunt .loadNpmTasks ' grunt-contrib-coffee'
80+ grunt .loadNpmTasks ' grunt-contrib-jasmine'
7581
76- grunt .loadNpmTasks (' grunt-contrib-coffee' )
77- grunt .loadNpmTasks (' grunt-contrib-jasmine' )
7882 grunt .initConfig (
7983 clean :
80- scripting : [' build /scripting' ]
81- build : [' build ' ]
84+ scripting : [' dist /scripting' ]
85+ dist : [' dist ' ]
8286
8387 # Concat CSS and JS files
84- # core_only : builds CCL without parsers
85- # all : builds CCL with everything
88+ # dist_core : builds CCL with just the comment system
89+ # dist_all : builds CCL with everything
90+ # scripting_host : builds just the scripting host
8691 concat :
87- scripting_host :
92+ dist_core :
8893 files :
89- ' build/scripting/Host.js' : [' src/scripting/Host.js' ,' src/scripting/Unpacker.js' ]
90- core_only :
94+ ' dist/css/style.css' : CSS
95+ ' dist/CommentCoreLibrary.js' : SRC_CORE
96+ dist_all :
9197 files :
92- ' build/ style.css' : CSS
93- ' build/CommentCore .js' : SRC_CORE
94- all :
98+ ' dist/css/ style.css' : CSS
99+ ' dist/CommentCoreLibrary .js' : CMP_ALL
100+ scripting_host :
95101 files :
96- ' build/style.css' : CSS
97- ' build/CommentCoreLibrary.js' : SRC_CORELIB
102+ ' dist/scripting/Host.js' : [' src/scripting/Host.js' ,' src/scripting/Unpacker.js' ]
98103
99104 # Compile TypeScript
100105 ts : ts_config
@@ -103,43 +108,42 @@ module.exports = (grunt) ->
103108 copy :
104109 scripting_sandbox :
105110 files : [
106- {expand : true , cwd : ' src/scripting/api/' , src : [' *.js' ], dest : ' build /scripting/api/' },
107- {expand : true , cwd : ' src/scripting/' , src : [' OOAPI.js' ,' Worker.js' ], dest : ' build /scripting/' }
111+ {expand : true , cwd : ' src/scripting/api/' , src : [' *.js' ], dest : ' dist /scripting/api/' },
112+ {expand : true , cwd : ' src/scripting/' , src : [' OOAPI.js' ,' Worker.js' ], dest : ' dist /scripting/' }
108113 ]
109114
110115 # Auto-prefix CSS properties using Can I Use?
111116 autoprefixer :
112117 options :
113118 browsers : [' last 3 versions' , ' bb 10' , ' android 3' ]
114-
115119 no_dest :
116120 # File to output
117- src : ' build /style.css'
121+ src : ' dist/css /style.css'
118122
119123 # Minify CSS
120124 cssmin :
121125 minify :
122- src : [' build /style.css' ]
123- dest : ' build /style.min.css'
126+ src : [' dist/css /style.css' ]
127+ dest : ' dist/css /style.min.css'
124128
129+ # Minify JS
125130 uglify :
126- options : banner : License
127- core_only :
128- files :
129- ' build/CommentCore.min.js' : SRC_CORE
131+ options :
132+ banner : LICENSE
130133 all :
131134 files :
132- ' build /CommentCoreLibrary.min.js' : SRC_CORELIB
135+ ' dist /CommentCoreLibrary.min.js' : [ ' dist/CommentCoreLibrary.js ' ]
133136
134137 # Watch files for changes
135- #
136138 watch :
137- all :
138- files : [' src/**/*' , ' !node_modules' ]
139-
140- # Run concat, autoprefixer, cssmin and uglify
139+ scripting :
140+ files : [' src/scripting/**/*' , ' !node_modules' ]
141+ tasks : [' build-scripting' ]
142+ core :
143+ files : [' src/**/*' , ' !node_modules' , ' !src/scripting/**/*' ]
141144 tasks : [' build' ]
142145
146+ # JSHint
143147 jshint :
144148 options :
145149 curly : true ,
@@ -159,7 +163,6 @@ module.exports = (grunt) ->
159163 src : [' src/*.js' ]
160164
161165 # Jasmine test
162-
163166 jasmine :
164167 coverage :
165168 src : ' src/**/*.js'
@@ -177,7 +180,7 @@ module.exports = (grunt) ->
177180 report : ' coverage'
178181 coverage : ' coverage/coverage.json'
179182 ci :
180- src : ' build /CommentCoreLibrary.js'
183+ src : ' dist /CommentCoreLibrary.js'
181184 options :
182185 specs : ' compiled_spec/*spec.js'
183186 helpers : ' spec/*helper.js'
@@ -204,14 +207,14 @@ module.exports = (grunt) ->
204207 )
205208
206209 # Register special compiles
207- grunt .registerTask ' compile- ts-kagerou ' , CMP_KAGEROU_NAME
208- grunt .registerTask ' compile- ts-core ' , CMP_CORE_NAME
210+ grunt .registerTask ' compile: ts-core ' , CMP_CORE_NAME
211+ grunt .registerTask ' compile: ts-kagerou ' , CMP_KAGEROU_NAME
209212
210213 # Register our tasks
211214 grunt .registerTask ' test' , [' coffee' , ' jasmine:coverage' ]
212- grunt .registerTask ' build-scripting ' , [' clean:scripting ' , ' concat:scripting_host ' , ' compile-ts-kagerou ' , ' copy:scripting_sandbox ' ]
213- grunt .registerTask ' build- core' , [' compile- ts-core' , ' concat:core_only ' , ' autoprefixer' , ' cssmin' , ' uglify:core_only ' ]
214- grunt .registerTask ' build' , [' compile-ts-core ' , ' concat:all ' , ' autoprefixer ' , ' cssmin ' , ' uglify:all ' ]
215+ grunt .registerTask ' build' , [' compile:ts-core ' , ' concat:dist_all ' , ' autoprefixer ' , ' cssmin ' , ' uglify:all ' ]
216+ grunt .registerTask ' build: core' , [' compile: ts-core' , ' concat:dist_core ' , ' autoprefixer' , ' cssmin' , ' uglify:core ' ]
217+ grunt .registerTask ' build:scripting ' , [' clean:scripting ' , ' concat:scripting_host ' , ' compile:ts-kagerou ' , ' copy:scripting_sandbox ' ]
215218 grunt .registerTask ' ci' , [' build' , ' coffee' , ' jasmine:ci' ]
216- grunt .registerTask ' default' , [' clean' , ' build' , ' build-scripting' , ' watch' ]
217219
220+ grunt .registerTask ' default' , [' clean' , ' build' , ' build:scripting' , ' watch' ]
0 commit comments