Skip to content

Commit

Permalink
Merge 80145ca into 684d54c
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbany committed Oct 19, 2016
2 parents 684d54c + 80145ca commit 216d03a
Show file tree
Hide file tree
Showing 76 changed files with 4,365 additions and 2,882 deletions.
8 changes: 4 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ CommentCoreLibrary在库外提供了很多可扩展的空间,你可以相对

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

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

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

Expand Down
145 changes: 75 additions & 70 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,67 @@ module.exports = (grunt) ->
grunt.file.readJSON('package.json')

# !! Compile configurations
License = '/*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
FilterType = "Simple" # "Comment" || "Simple"
LICENSE = '/*!Copyright(c) CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */'
# !! End of config area

CSS = [
'src/css/base.css',
'src/css/fontalias.css'
]

SRC_CORE_CMP = [
'Comment'
'CommentSpaceAllocator'
]

SRC_CORE = [
'src/Array.js'
'src/core/CommentSpaceAllocator.js'
'src/core/Comment.js'
'src/filter/' + FilterType + 'Filter.js'
'src/CommentCoreLibrary.js'
'src/CommentManager.js'
]

SRC_MODULES =
'filter': ['src/filter/SimpleFilter.js']
'provider': ['src/CommentProvider.js']
'format-bilibili': ['src/parsers/BilibiliFormat.js']
'format-acfun': ['src/parsers/AcfunFormat.js']
'format-common': ['src/parsers/CommonDanmakuFormat.js']

# Typescript targets
SRC_TS_CORE = [
'Comment'
'CommentSpaceAllocator'
]

SRC_SCRIPTING_KAGEROU =
display: 'src/scripting/api/Display/Display.ts'
runtime: 'src/scripting/api/Runtime/Runtime.ts'
player: 'src/scripting/api/Player/Player.ts'
utils: 'src/scripting/api/Utils/Utils.ts'
tween: 'src/scripting/api/Tween/Tween.ts'
SRC_TS_SCRIPTING_KAGEROU =
'display': 'src/scripting/api/Display/Display.ts'
'runtime': 'src/scripting/api/Runtime/Runtime.ts'
'player': 'src/scripting/api/Player/Player.ts'
'utils': 'src/scripting/api/Utils/Utils.ts'
'tween': 'src/scripting/api/Tween/Tween.ts'

SRC_PARSER = [
'src/parsers/AcfunFormat.js'
'src/parsers/BilibiliFormat.js'
]
# ==== Below this point is logic to generate compile configurations ====
# You probably do not need to edit anything below here

# Dynamically generate the target for all
CMP_ALL = []
CMP_ALL = CMP_ALL.concat SRC_CORE
for name, source of SRC_MODULES
CMP_ALL = CMP_ALL.concat source

# !! Below are compile settings
# Dynamically generate the core ts targets
CMP_CORE_TS = { }
CMP_CORE_NAME = [ ]
for target in SRC_CORE_CMP
CMP_CORE_NAME.push ("ts:" + target)
CMP_CORE_TS[target] =
CMP_CORE_TS = {}
CMP_CORE_NAME = []
for target in SRC_TS_CORE
CMP_CORE_NAME.push ("ts:core_" + target)
CMP_CORE_TS["core_" + target] =
src: ["src/core/" + target + ".ts"]
out: "src/core/" + target + ".js"

# Dynamically generate the kagerou ts targets
CMP_KAGEROU_TS = { }
CMP_KAGEROU_NAME = [ ]
for target,src of SRC_SCRIPTING_KAGEROU
CMP_KAGEROU_TS = {}
CMP_KAGEROU_NAME = []
for target,src of SRC_TS_SCRIPTING_KAGEROU
CMP_KAGEROU_NAME.push ('ts:kagerou_engine_' + target)
CMP_KAGEROU_TS['kagerou_engine_' + target] =
src: src
out: 'build/scripting/api/' + src.split('/').pop().split('.')[0] + '.js'
out: 'dist/scripting/api/' + src.split('/').pop().split('.')[0] + '.js'

# Append Typescript Tasks
ts_config =
Expand All @@ -67,32 +76,30 @@ module.exports = (grunt) ->
for key,value of CMP_KAGEROU_TS
ts_config[key] = value

# Core concatenated with libraries
# Actual concat ordering does not/should not matter
SRC_CORELIB = SRC_CORE.concat(SRC_PARSER)
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-jasmine'

grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-jasmine')
grunt.initConfig(
clean:
scripting: ['build/scripting']
build: ['build']
scripting: ['dist/scripting']
dist: ['dist']

# Concat CSS and JS files
# core_only : builds CCL without parsers
# all : builds CCL with everything
# dist_core : builds CCL with just the comment system
# dist_all : builds CCL with everything
# scripting_host : builds just the scripting host
concat:
scripting_host:
dist_core:
files:
'build/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js']
core_only:
'dist/css/style.css': CSS
'dist/CommentCoreLibrary.js': SRC_CORE
dist_all:
files:
'build/style.css': CSS
'build/CommentCore.js': SRC_CORE
all:
'dist/css/style.css': CSS
'dist/CommentCoreLibrary.js': CMP_ALL
scripting_host:
files:
'build/style.css': CSS
'build/CommentCoreLibrary.js': SRC_CORELIB
'dist/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js']

# Compile TypeScript
ts: ts_config
Expand All @@ -101,43 +108,42 @@ module.exports = (grunt) ->
copy:
scripting_sandbox:
files:[
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'build/scripting/api/'},
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'build/scripting/'}
{expand: true, cwd:'src/scripting/api/', src: ['*.js'], dest:'dist/scripting/api/'},
{expand: true, cwd:'src/scripting/', src: ['OOAPI.js','Worker.js'], dest:'dist/scripting/'}
]

# Auto-prefix CSS properties using Can I Use?
autoprefixer:
options:
browsers: ['last 3 versions', 'bb 10', 'android 3']

no_dest:
# File to output
src: 'build/style.css'
src: 'dist/css/style.css'

# Minify CSS
cssmin:
minify:
src: ['build/style.css']
dest: 'build/style.min.css'
src: ['dist/css/style.css']
dest: 'dist/css/style.min.css'

# Minify JS
uglify:
options: banner: License
core_only:
files:
'build/CommentCore.min.js': SRC_CORE
options:
banner: LICENSE
all:
files:
'build/CommentCoreLibrary.min.js': SRC_CORELIB
'dist/CommentCoreLibrary.min.js': ['dist/CommentCoreLibrary.js']

# Watch files for changes
#
watch:
all:
files: ['src/**/*', '!node_modules']

# Run concat, autoprefixer, cssmin and uglify
scripting:
files: ['src/scripting/**/*', '!node_modules']
tasks: ['build-scripting']
core:
files: ['src/**/*', '!node_modules', '!src/scripting/**/*']
tasks: ['build']

# JSHint
jshint:
options:
curly: true,
Expand All @@ -157,7 +163,6 @@ module.exports = (grunt) ->
src: ['src/*.js']

# Jasmine test

jasmine:
coverage:
src: 'src/**/*.js'
Expand All @@ -175,7 +180,7 @@ module.exports = (grunt) ->
report: 'coverage'
coverage: 'coverage/coverage.json'
ci:
src: 'build/CommentCoreLibrary.js'
src: 'dist/CommentCoreLibrary.js'
options:
specs: 'compiled_spec/*spec.js'
helpers: 'spec/*helper.js'
Expand All @@ -202,14 +207,14 @@ module.exports = (grunt) ->
)

# Register special compiles
grunt.registerTask 'compile-ts-kagerou', CMP_KAGEROU_NAME
grunt.registerTask 'compile-ts-core', CMP_CORE_NAME
grunt.registerTask 'compile:ts-core', CMP_CORE_NAME
grunt.registerTask 'compile:ts-kagerou', CMP_KAGEROU_NAME

# Register our tasks
grunt.registerTask 'test', ['coffee', 'jasmine:coverage']
grunt.registerTask 'build-scripting', ['clean:scripting','concat:scripting_host', 'compile-ts-kagerou', 'copy:scripting_sandbox']
grunt.registerTask 'build-core', ['compile-ts-core', 'concat:core_only', 'autoprefixer', 'cssmin', 'uglify:core_only']
grunt.registerTask 'build', ['compile-ts-core', 'concat:all', 'autoprefixer', 'cssmin', 'uglify:all']
grunt.registerTask 'build', ['compile:ts-core', 'concat:dist_all', 'autoprefixer', 'cssmin', 'uglify:all']
grunt.registerTask 'build:core', ['compile:ts-core', 'concat:dist_core', 'autoprefixer', 'cssmin', 'uglify:core']
grunt.registerTask 'build:scripting', ['clean:scripting','concat:scripting_host', 'compile:ts-kagerou', 'copy:scripting_sandbox']
grunt.registerTask 'ci', ['build', 'coffee', 'jasmine:ci']
grunt.registerTask 'default', ['clean', 'build', 'build-scripting', 'watch']

grunt.registerTask 'default', ['clean', 'build', 'build:scripting', 'watch']
12 changes: 8 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "comment-core-library",
"version": "0.9.3",
"main": ["build/CommentCoreLibrary.js","build/style.css"],
"ignore": [
"name": "comment-core-library",
"description": "Javascript library for organizing and displaying danmaku comments",
"license": "MIT",
"authors": [
"Jim Chen <knh.jabbany@gmail.com>"
],
"main": ["dist/CommentCoreLibrary.js","dist/style.css"],
"ignore": [
"test/**/*",
"experimental/**/*",
"demo/**/*"
Expand Down
Loading

0 comments on commit 216d03a

Please sign in to comment.