forked from Manbearpixel/videojs-vpaid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·215 lines (197 loc) · 7.07 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
dev: {
port: 8888,
base: '.'
}
},
mxmlc: {
options: {
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_16.html
metadata: {
// `-title "Adobe Flex Application"`
title: 'VideoJS VPAID SWF',
// `-description "http://www.adobe.com/flex"`
description: 'http://www.videojs.com',
// `-publisher "The Publisher"`
publisher: 'Brightcove, Inc. | VPAID Mod',
// `-creator "The Author"`
creator: 'Brightcove, Inc. | VPAID Mod',
// `-language=EN`
// `-language+=klingon`
language: 'EN',
// `-localized-title "The Color" en-us -localized-title "The Colour" en-ca`
localizedTitle: null,
// `-localized-description "Standardized Color" en-us -localized-description "Standardised Colour" en-ca`
localizedDescription: null,
// `-contributor "Contributor #1" -contributor "Contributor #2"`
contributor: null,
// `-date "Mar 10, 2013"`
date: null
},
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_18.html
application: {
// `-default-size 240 240`
layoutSize: {
width: 640,
height: 360
},
// `-default-frame-rate=24`
frameRate: 30,
// `-default-background-color=0x869CA7`
backgroundColor: 0x000000,
// `-default-script-limits 1000 60`
scriptLimits: {
maxRecursionDepth: 1000,
maxExecutionTime: 60
}
},
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_19.html
// `-library-path+=libraryPath1 -library-path+=libraryPath2`
libraries: ['libs/*.*'],
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_17.html
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_20.html
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html
compiler: {
// `-accessible=false`
'accessible': false,
// `-actionscript-file-encoding=UTF-8`
'actionscriptFileEncoding': null,
// `-allow-source-path-overlap=false`
'allowSourcePathOverlap': false,
// `-as3=true`
'as3': true,
// `-benchmark=true`
'benchmark': true,
// `-context-root context-path`
'contextRoot': null,
// `-debug=false`
'debug': false,
// `-defaults-css-files filePath1 ...`
'defaultsCssFiles': [],
// `-defaults-css-url http://example.com/main.css`
'defaultsCssUrl': null,
// `-define=CONFIG::debugging,true -define=CONFIG::release,false`
// `-define+=CONFIG::bool2,false -define+=CONFIG::and1,"CONFIG::bool2 && false"
// `-define+=NAMES::Company,"'Adobe Systems'"`
'defines': {},
// `-es=true -as3=false`
'es': false,
// `-externs className1 ...`
'externs': [],
// `-external-library-path+=pathElement`
'externalLibraries': [],
'fonts': {
// `-fonts.advanced-anti-aliasing=false`
advancedAntiAliasing: false,
// `-fonts.languages.language-range "Alpha and Plus" "U+0041-U+007F,U+002B"`
// USAGE:
// ```
// languages: [{
// lang: 'Alpha and Plus',
// range: ['U+0041-U+007F', 'U+002B']
// }]
// ```
languages: [],
// `-fonts.local-fonts-snapsnot filePath`
localFontsSnapshot: null,
// `-fonts.managers flash.fonts.JREFontManager flash.fonts.BatikFontManager flash.fonts.AFEFontManager`
// NOTE: FontManager preference is in REVERSE order (prefers LAST array item).
// For more info, see http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_06.html
managers: []
},
// `-incremental=false`
'incremental': false
}
},
vpaid_swf: {
files: {
'dist/videojs-vpaid.swf': ['src/VideoJS.as']
// 'sandbox/exampleadvpaid2.swf': ['sandbox/exampleAd/ExampleVPAID.as']
}
}
},
bumpup: {
options: {
updateProps: {
pkg: 'package.json'
}
},
file: 'package.json'
},
tagrelease: {
file: 'package.json',
commit: true,
message: 'Release %version%',
prefix: 'v'
}
});
grunt.loadNpmTasks('grunt-connect');
grunt.loadNpmTasks('grunt-bumpup');
grunt.loadNpmTasks('grunt-tagrelease');
grunt.loadNpmTasks('grunt-npm');
grunt.loadNpmTasks('chg');
grunt.registerTask('dist', ['mxmlc']);
grunt.registerTask('default', ['dist']);
grunt.registerMultiTask('mxmlc', 'Compiling SWF', function () {
// Merge task-specific and/or target-specific options with these defaults.
var childProcess = require('child_process');
var flexSdk = require('flex-sdk');
var async = require('async');
var pkg = grunt.file.readJSON('package.json');
var
options = this.options,
done = this.async(),
maxConcurrency = 1,
q,
workerFn;
workerFn = function(f, callback) {
// Concat specified files.
var srcList = f.src.filter(function(filepath) {
// Warn on and remove invalid source files (if nonull was set).
if (!grunt.file.exists(filepath)) {
grunt.log.error('Source file "' + filepath + '" not found.');
return false;
}
else {
return true;
}
});
var cmdLineOpts = [];
if (f.dest) {
cmdLineOpts.push('-output');
cmdLineOpts.push(f.dest);
}
cmdLineOpts.push('-define=CONFIG::version, "' + pkg.version + '"');
cmdLineOpts.push('--');
cmdLineOpts.push.apply(cmdLineOpts, srcList);
grunt.verbose.writeln('package version: ' + pkg.version);
grunt.verbose.writeln('mxmlc path: ' + flexSdk.bin.mxmlc);
grunt.verbose.writeln('options: ' + JSON.stringify(cmdLineOpts));
// Compile!
childProcess.execFile(flexSdk.bin.mxmlc, cmdLineOpts, function(err, stdout, stderr) {
if (!err) {
grunt.log.writeln('File "' + f.dest + '" created.');
}
else {
grunt.log.error(err.toString());
grunt.verbose.writeln('stdout: ' + stdout);
grunt.verbose.writeln('stderr: ' + stderr);
if (options.force === true) {
grunt.log.warn('Should have failed but will continue because this task had the `force` option set to `true`.');
}
else {
grunt.fail.warn('FAILED');
}
}
callback(err);
});
};
q = async.queue(workerFn, maxConcurrency);
q.drain = done;
q.push(this.files);
});
};