forked from intel/webapps-annex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
463 lines (389 loc) · 13.1 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-tizen');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-release');
grunt.loadTasks('tools/grunt-tasks');
grunt.initConfig({
packageInfo: grunt.file.readJSON('package.json'),
chromeInfo: grunt.file.readJSON('platforms/chrome-crx/manifest.json'),
crosswalk: {
arm: {
//"outDir": process.env.HOME+'/z/webapps/webapps-annex/build',
"outDir": 'build',
verbose: false,
version: '<%= packageInfo.version %>',
// display name for the app on the device;
// the sanitisedName used to construct the Locations object later
// is derived from this
name: '<%= packageInfo.name %>',
// package for the app's generated Java files; this works best if
// you have at least one period character between two character
// strings, and no digits
pkg: 'org.org01.webapps.<%= packageInfo.name.toLowerCase() %>',
icon: 'icon_128.png',
fullscreen: true,
remoteDebugging: true,
// path to the directory containing your HTML5 app;
// note that this must use the correct path separators for your
// platform: Windows uses '\\' while Linux uses '/'
appRoot: 'build/xpk',
// relative path from appRoot of the entry HTML file for your app
appLocalPath: 'index.html',
// embed crosswalk itself into the package
//embedded: true,
// path to the root of your Android SDK installation;
// on Windows, use the path to the sdk directory inside
// the installation, e.g. 'c:\\android-sdk\\sdk'
// default: automatically obtain from the 'android' command's path
//androidSDKDir: '/opt/android-sdk-linux/',
// path to the xwalk_app_template directory; you can either
// download and unpack this manually, or use the xwalk_android_dl
// script to do so (part of this project; see the README for details);
// note that path separators specific to your platform must be used
// eg: export XWALK_APP_TEMPLATE=$HOME/Downloads/crosswalk-3.32.53.4-x86
//xwalkAndroidDir: project/specific/folder
// architecture of embedded crosswalk
// default: it is obtained from the contents of
// xwalkAndroidDir/native_libs/ if there is only one arch in there,
// else it should be specified as either 'x86' or 'arm'
arch: 'arm',
// default: automatically obtains latest from androidSDKDir/build-tools
//androidAPIVersion: "18.0.1"
},
x86: {
//"outDir": process.env.HOME+'/z/webapps/webapps-annex/build',
"outDir": 'build',
verbose: false,
version: '<%= packageInfo.version %>',
// display name for the app on the device;
// the sanitisedName used to construct the Locations object later
// is derived from this
name: '<%= packageInfo.name %>',
// package for the app's generated Java files; this works best if
// you have at least one period character between two character
// strings, and no digits
pkg: 'org.org01.webapps.<%= packageInfo.name.toLowerCase() %>',
icon: 'icon_128.png',
fullscreen: true,
remoteDebugging: true,
// path to the directory containing your HTML5 app;
// note that this must use the correct path separators for your
// platform: Windows uses '\\' while Linux uses '/'
appRoot: 'build/xpk',
// relative path from appRoot of the entry HTML file for your app
appLocalPath: 'index.html',
// embed crosswalk itself into the package
//embedded: true,
// path to the root of your Android SDK installation;
// on Windows, use the path to the sdk directory inside
// the installation, e.g. 'c:\\android-sdk\\sdk'
// default: automatically obtain from the 'android' command's path
//androidSDKDir: '/opt/android-sdk-linux/',
// path to the xwalk_app_template directory; you can either
// download and unpack this manually, or use the xwalk_android_dl
// script to do so (part of this project; see the README for details);
// note that path separators specific to your platform must be used
// eg: export XWALK_APP_TEMPLATE=$HOME/Downloads/crosswalk-3.32.53.4-x86
//xwalkAndroidDir: project/specific/folder
// architecture of embedded crosswalk
// default: it is obtained from the contents of
// xwalkAndroidDir/native_libs/ if there is only one arch in there,
// else it should be specified as either 'x86' or 'arm'
arch: 'x86',
// default: automatically obtains latest from androidSDKDir/build-tools
//androidAPIVersion: "18.0.1"
}
},
clean: ['build'],
release: {
options: {
npm: false,
npmtag: false,
tagName: 'v<%= version %>'
}
},
tizen_configuration: {
// location on the device to install the tizen-app.sh script to
// (default: '/tmp')
tizenAppScriptDir: '/home/developer/',
// path to the config.xml file for the Tizen wgt file - post templating
// (default: 'config.xml')
configFile: 'build/wgt/config.xml',
// path to the sdb command (default: process.env.SDB or 'sdb')
sdbCmd: 'sdb'
},
// minify JS
uglify: {
dist: {
files: [
{ expand: true, cwd: '.', src: 'app/js/**/*.js', dest: 'build/' }
]
}
},
// minify CSS
cssmin: {
dist: {
files: [
{ expand: true, cwd: '.', src: ['app/css/**/*.css'], dest: 'build/' }
]
}
},
copy: {
common: {
files: [
{ expand: true, cwd: '.', src: ['app/lib/**'], dest: 'build/' },
{ expand: true, cwd: '.', src: ['app/audio/**'], dest: 'build/' },
{ expand: true, cwd: '.', src: ['app/data/**'], dest: 'build/' },
{ expand: true, cwd: '.', src: ['LICENSE'], dest: 'build/app/' },
{ expand: true, cwd: '.', src: ['app/README.txt'], dest: 'build/' },
{ expand: true, cwd: '.', src: ['app/_locales/**'], dest: 'build/' }
]
},
wgt: {
files: [
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/wgt/' },
{ expand: true, cwd: '.', src: ['icon_128.png'], dest: 'build/wgt/' }
]
},
wgt_config: {
files: [
{ expand: true, cwd: 'platforms/tizen-wgt/', src: ['config.xml'], dest: 'build/wgt/' }
],
options:
{
processContent: function(content, srcpath)
{
return grunt.template.process(content);
}
}
},
crx: {
files: [
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/crx/' },
{ expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/crx/' }
]
},
crx_unpacked: {
files: [
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/crx/' },
{ expand: true, cwd: 'app/', src: ['js/**'], dest: 'build/crx/' },
{ expand: true, cwd: 'app/', src: ['css/**'], dest: 'build/crx/' },
{ expand: true, cwd: 'app/', src: ['*.html'], dest: 'build/crx/' },
{ expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/crx/' }
]
},
crx_manifest:
{
files: [
{ expand: true, cwd: 'platforms/chrome-crx/', src: ['manifest.json'], dest: 'build/crx/' }
],
options:
{
processContent: function(content, srcpath)
{
return grunt.template.process(content);
}
}
},
xpk: {
files: [
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/xpk/' },
{ expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/xpk/' }
]
},
xpk_manifest:
{
files: [
{ expand: true, cwd: 'platforms/tizen-xpk/', src: ['manifest.json'], dest: 'build/xpk/' }
],
options:
{
processContent: function(content, srcpath)
{
return grunt.template.process(content);
}
}
},
sdk: {
files: [
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/sdk/' },
{ expand: true, cwd: 'app/', src: ['js/**'], dest: 'build/sdk/' },
{ expand: true, cwd: 'app/', src: ['css/**'], dest: 'build/sdk/' },
{ expand: true, cwd: 'app/', src: ['*.html'], dest: 'build/sdk/' },
{ expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/sdk/' }
]
},
sdk_platform:
{
files: [
{ expand: true, cwd: 'platforms/tizen-sdk/', src: ['.project'], dest: 'build/sdk/' },
{ expand: true, cwd: 'platforms/tizen-wgt/', src: ['config.xml'], dest: 'build/sdk/' }
],
options:
{
processContent: function(content, srcpath)
{
return grunt.template.process(content);
}
}
},
},
htmlmin: {
dist: {
files: [
{ expand: true, cwd: '.', src: ['app/*.html'], dest: 'build/' },
{ expand: true, cwd: '.', src: ['app/html/*.html'], dest: 'build/' }
],
options: {
removeComments: true,
collapseWhitespace: true,
removeCommentsFromCDATA: false,
removeCDATASectionsFromCDATA: false,
removeEmptyAttributes: true,
removeEmptyElements: false
}
}
},
imagemin: {
dist: {
options: {
optimizationLevel: 3,
progressive: true
},
files: [
{ expand: true, cwd: '.', src: ['app/images/**'], dest: 'build/' },
{ expand: true, cwd: '.', src: ['app/css/images/**'], dest: 'build/' }
]
}
},
// make wgt package in build/ directory
package: {
wgt: {
appName: '<%= packageInfo.name %>',
version: '<%= packageInfo.version %>',
files: 'build/wgt/**',
stripPrefix: 'build/wgt/',
outDir: 'build',
suffix: '.wgt',
addGitCommitId: false
},
sdk: {
appName: '<%= packageInfo.name %>',
version: '<%= packageInfo.version %>',
files: 'build/sdk/**',
stripPrefix: 'build/sdk/',
outDir: 'build',
suffix: '.zip'
},
'crx_zip': {
appName: '<%= packageInfo.name %>-crx',
version: '<%= packageInfo.version %>',
files: 'build/crx/**',
stripPrefix: 'build/crx/',
outDir: 'build',
suffix: '.zip'
}
},
simple_server: {
port: 30303,
dir: 'build/app/'
},
tizen: {
push: {
action: 'push',
localFiles: {
pattern: 'build/*.wgt',
filter: 'latest'
},
remoteDir: '/home/developer/'
},
install: {
action: 'install',
remoteFiles: {
pattern: '/home/developer/<%= packageInfo.name %>*.wgt',
filter: 'latest'
}
},
uninstall: {
action: 'uninstall'
},
start: {
action: 'start',
stopOnFailure: true
},
stop: {
action: 'stop',
stopOnFailure: false
},
debug: {
action: 'debug',
browserCmd: 'google-chrome %URL%',
localPort: 9090,
stopOnFailure: true
}
}
});
grunt.registerTask('dist', [
'clean',
'imagemin:dist',
'uglify:dist',
'cssmin:dist',
'htmlmin:dist',
'copy:common'
]);
grunt.registerTask('crx', ['dist', 'copy:crx', 'copy:crx_manifest']);
grunt.registerTask('crx_unpacked', [
'clean',
'imagemin:dist',
'copy:common',
'copy:crx_unpacked',
'copy:crx_manifest',
'package:crx_zip'
]);
grunt.registerTask('wgt', ['dist', 'copy:wgt', 'copy:wgt_config', 'package:wgt']);
grunt.registerTask('xpk', ['dist', 'copy:xpk', 'copy:xpk_manifest']);
grunt.registerTask('sdk', [
'clean',
'imagemin:dist',
'copy:common',
'copy:sdk',
'copy:sdk_platform',
'package:sdk'
]);
grunt.registerTask('perf', [
'dist',
'uglify:perf',
'inline',
'copy:wgt',
'copy:wgt_config',
'package:wgt'
]);
grunt.registerTask('install', [
'tizen:push',
'tizen:stop',
'tizen:uninstall',
'tizen:install',
'tizen:start'
]);
grunt.registerTask('wait', function () {
var done = this.async();
setTimeout(function () {
done();
}, 10000);
});
grunt.registerTask('restart', ['tizen:stop', 'tizen:start']);
grunt.registerTask('server', ['dist', 'simple_server']);
grunt.registerTask('wgt-install', ['wgt', 'install']);
grunt.registerTask('sdk-install', ['sdk', 'install']);
grunt.registerTask('default', 'wgt');
grunt.registerTask('apk', [
'xpk',
'crosswalk:x86',
'crosswalk:arm'
]);
};