Skip to content

Commit 41841b3

Browse files
committed
Moved to grunt compile
1 parent 406a3e1 commit 41841b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+79
-527
lines changed

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# See http://help.github.com/ignore-files/ for more about ignoring files.
2-
#
3-
# If you find yourself ignoring temporary files generated by your text editor
4-
# or operating system, you probably want to add a global ignore instead:
5-
# git config --global core.excludesfile ~/.gitignore_global
6-
#
1+
# IDEA
2+
/.idea
73
*.iml
4+
5+
# Ignore Node Modules
86
/node_modules/*

BUILDING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ CommentCoreLibrary在库外提供了很多可扩展的空间,你可以相对
3131

3232
即可按照默认模板编译。除此之外,你还可以改变编译目标:
3333

34-
- build : 只编译项目,不会clean掉 build文件夹下的产物
34+
- build : 只编译项目,不会clean掉build文件夹下的产物
3535
- build-core : 只编译弹幕核心,不包括Acfun和Bilibili的解析器。这个更加适用各种二次开发不需要
3636
已有的弹幕格式的
37+
- build-scripting : 只编译代码弹幕支持
3738

3839
默认模式会自动看管 `src` 源码文件夹,并且在产生变化的时候自动生成新版。
3940

@@ -43,8 +44,9 @@ CommentCoreLibrary在库外提供了很多可扩展的空间,你可以相对
4344

4445
### 代码弹幕(Scripting Engine)
4546
默认的代码弹幕支持需要使用 TypeScript 编译。这需要你安装 TypeScript 支持,通过
46-
`npm install -g typescript` 即可安装。代码弹幕部分临时还在使用旧的 `make` 系统,未来也会
47-
逐渐过渡到使用 Grunt。目前编译项目不会引入代码弹幕支持(考虑到架设难度的增高和潜在受众面相对于
48-
弹幕支持要少一些),相关库需要手动引入。
47+
`npm install -g typescript` 即可安装。目前编译项目不会引入代码弹幕支持(考虑到架设难度的增高
48+
,编译速度降低和潜在受众面相对于弹幕支持要少一些),相关库需要手动引入。
49+
50+
如果希望直接 Grunt 编译现在也已经支持。
4951

5052
参考 `docs/scripting` 了解代码弹幕系统和它的编译方法。

Gruntfile.coffee

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,44 @@ module.exports = (grunt) ->
1515
'src/CommentCoreLibrary.js'
1616
]
1717

18-
SRC_TRANSITION = [
19-
'src/CCLComment.js'
20-
'src/CommentFilter.js'
21-
'src/CommentTransitionSpaceAllocator.js'
22-
'src/CommentTransitionLibrary.js'
23-
]
18+
SRC_SCRIPTING_KAGEROU =
19+
display: 'src/scripting/api/Display/Display.ts'
20+
runtime: 'src/scripting/api/Runtime/Runtime.ts'
21+
player: 'src/scripting/api/Player/Player.ts'
22+
utils: 'src/scripting/api/Utils/Utils.ts'
23+
tween: 'src/scripting/api/Tween/Tween.ts'
2424

2525
SRC_PARSER = [
2626
'src/parsers/AcfunFormat.js'
2727
'src/parsers/BilibiliFormat.js'
2828
]
2929

30+
# Dynamically generate the ts targets
31+
kagerou_config = { }
32+
for target,src of SRC_SCRIPTING_KAGEROU
33+
kagerou_config['kagerou_engine_' + target] =
34+
options:
35+
target: 'es5'
36+
basePath: src.split('/')[0..-1].join('/')
37+
src: src
38+
dest: 'build/scripting/api/' + src.split('/').pop().split('.')[0] + '.js'
39+
3040
# Core concatenated with libraries
3141
# Actual concat ordering does not/should not matter
3242
SRC_CORELIB = SRC_CORE.concat(SRC_PARSER)
3343

3444
grunt.initConfig(
3545
clean:
46+
scripting: ['build/scripting']
3647
build: ['build']
3748

3849
# Concat CSS and JS files
3950
# core_only : builds CCL without parsers
4051
# all : builds CCL with everything
4152
concat:
53+
scripting:
54+
files:
55+
'build/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js']
4256
core_only:
4357
files:
4458
'build/style.css': CSS
@@ -47,7 +61,18 @@ module.exports = (grunt) ->
4761
files:
4862
'build/style.css': CSS
4963
'build/CommentCoreLibrary.js': SRC_CORELIB
50-
64+
65+
# Compile TypeScript
66+
typescript: kagerou_config
67+
68+
# Copy
69+
copy:
70+
scripting:
71+
files:[
72+
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'build/scripting/api/'},
73+
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'build/scripting/'}
74+
]
75+
5176
# Auto-prefix CSS properties using Can I Use?
5277
autoprefixer:
5378
options:
@@ -82,6 +107,7 @@ module.exports = (grunt) ->
82107
)
83108

84109
# Register our tasks
110+
grunt.registerTask 'build-scripting', ['clean:scripting','concat:scripting', 'copy:scripting', 'typescript']
85111
grunt.registerTask 'build-core', ['concat:core_only', 'autoprefixer', 'cssmin', 'uglify:core_only']
86112
grunt.registerTask 'build', ['concat:all', 'autoprefixer', 'cssmin', 'uglify:all']
87113
grunt.registerTask 'default', ['clean', 'build', 'watch']
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ var CCLScripting = function(workerUrl){
298298
self.getContext().registerObject("__root", {"class":"SpriteRoot"});
299299
};
300300
})();
301+
301302
/** Define some Unpackers **/
302303
(function(){
303304
/** This is the DOM Manipulation Library **/

0 commit comments

Comments
 (0)