@@ -178,6 +178,61 @@ module.exports = function (grunt) {
178
178
grunt . task . run ( "curl-dir:" + grunt . config ( "icuConfig" ) ) ;
179
179
} ) ;
180
180
181
+ // task: vs-crt
182
+ grunt . registerTask ( "vs-crt" , "Download and setup VS CRT dlls" , function ( ) {
183
+ if ( platform === "win" ) {
184
+ var config = "vs-crt-" + platform + common . arch ( ) ,
185
+ zipSrc = grunt . config ( "curl-dir." + config + ".src" ) ,
186
+ zipName = path . basename ( zipSrc ) ,
187
+ zipDest = path . resolve ( process . cwd ( ) , path . join ( grunt . config ( "curl-dir." + config + ".dest" ) , zipName ) ) ,
188
+ txtName ;
189
+
190
+ // extract zip file name and set config property
191
+ grunt . config ( "vsCRTZipDest" , zipDest ) ;
192
+ grunt . config ( "vsCRTZipSrc" , zipSrc ) ;
193
+ grunt . config ( "vsCRTZipName" , zipName ) ;
194
+ grunt . config ( "vsCRTConfig" , config ) ;
195
+
196
+ // remove .zip extension
197
+ txtName = zipName . substr ( 0 , zipName . lastIndexOf ( "." ) ) + ".txt" ;
198
+
199
+ // optionally download if vs-crt is not found
200
+ if ( ! grunt . file . exists ( "deps/vs-crt/" + txtName ) ) {
201
+ var vsCRTTasks = [ "vs-crt-clean" , "vs-crt-extract" ] ;
202
+
203
+ if ( grunt . file . exists ( zipDest ) ) {
204
+ grunt . verbose . writeln ( "Found VS CRT download " + zipDest ) ;
205
+ } else {
206
+ vsCRTTasks . unshift ( "vs-crt-download" ) ;
207
+ }
208
+
209
+ grunt . task . run ( vsCRTTasks ) ;
210
+ } else {
211
+ grunt . verbose . writeln ( "Skipping vs-crt download. Found deps/vs-crt/" + txtName ) ;
212
+ }
213
+ }
214
+ } ) ;
215
+
216
+ // task: vs-crt-clean
217
+ grunt . registerTask ( "vs-crt-clean" , "Removes CEF binaries and linked folders" , function ( ) {
218
+ // delete dev symlinks from "setup_for_hacking"
219
+ common . deleteFile ( "Release/dev" , { force : true } ) ;
220
+ common . deleteFile ( "Debug/dev" , { force : true } ) ;
221
+
222
+ // finally delete vs-crt binary\
223
+ common . deleteFile ( "deps/vs-crt" , { force : true } ) ;
224
+ } ) ;
225
+
226
+ // task: vs-crt-download
227
+ grunt . registerTask ( "vs-crt-download" , "Download vs crt, see curl-dir config in Gruntfile.js" , function ( ) {
228
+ // requires download-vs-crt to set "vsCRTZipName" in config
229
+ grunt . task . requires ( [ "vs-crt" ] ) ;
230
+
231
+ // run curl
232
+ grunt . log . writeln ( "Downloading " + grunt . config ( "vsCRTZipSrc" ) + ". This may take a while..." ) ;
233
+ grunt . task . run ( "curl-dir:" + grunt . config ( "vsCRTConfig" ) ) ;
234
+ } ) ;
235
+
181
236
function cefFileLocation ( ) {
182
237
return path . resolve ( process . cwd ( ) , "deps/cef" ) ;
183
238
}
@@ -390,6 +445,45 @@ module.exports = function (grunt) {
390
445
} ) ;
391
446
} ) ;
392
447
448
+ // task: vs-crt-extract
449
+ grunt . registerTask ( "vs-crt-extract" , "Extract vs-crt zip" , function ( ) {
450
+ // requires vs-crt to set "vsCRTZipName" in config
451
+ grunt . task . requires ( [ "vs-crt" ] ) ;
452
+
453
+ var done = this . async ( ) ,
454
+ zipDest = grunt . config ( "vsCRTZipDest" ) ,
455
+ zipName = grunt . config ( "vsCRTZipName" ) ,
456
+ unzipPromise ;
457
+
458
+ // unzip to deps/
459
+ unzipPromise = unzip ( zipDest , "deps" ) ;
460
+
461
+ // remove .zip ext
462
+ zipName = path . basename ( zipName , ".zip" ) ;
463
+
464
+ unzipPromise . then ( function ( ) {
465
+ // rename version stamped name to cef
466
+ return rename ( "deps/" + zipName , "deps/vs-crt" ) ;
467
+ } ) . then ( function ( ) {
468
+ var memo = path . resolve ( process . cwd ( ) , "deps/vs-crt/" + zipName + ".txt" ) ,
469
+ permissionsPromise ;
470
+
471
+ permissionsPromise = q . resolve ( ) ;
472
+
473
+ return permissionsPromise . then ( function ( ) {
474
+ // write empty file with zip file
475
+ grunt . file . write ( memo , "" ) ;
476
+
477
+ return q . resolve ( ) ;
478
+ } ) ;
479
+ } ) . then ( function ( ) {
480
+ done ( ) ;
481
+ } , function ( err ) {
482
+ grunt . log . writeln ( err ) ;
483
+ done ( false ) ;
484
+ } ) ;
485
+ } ) ;
486
+
393
487
// task: cef-symlinks
394
488
grunt . registerTask ( "cef-symlinks" , "Create symlinks for CEF" , function ( ) {
395
489
var done = this . async ( ) ,
@@ -589,5 +683,9 @@ module.exports = function (grunt) {
589
683
} ) ;
590
684
591
685
// task: setup
592
- grunt . registerTask ( "setup" , [ "cef" , "node" , "node-check" , "icu" , "create-project" ] ) ;
593
- } ;
686
+ if ( platform === "win" ) {
687
+ grunt . registerTask ( "setup" , [ "cef" , "node" , "node-check" , "icu" , "vs-crt" , "create-project" ] ) ;
688
+ } else {
689
+ grunt . registerTask ( "setup" , [ "cef" , "node" , "node-check" , "icu" , "create-project" ] ) ;
690
+ }
691
+ } ;
0 commit comments