@@ -11,7 +11,7 @@ var zlib = require("zlib");
1111var tar = require ( "tar" ) ;
1212var request = require ( "request" ) ;
1313
14- function downloadTo ( url , result ) {
14+ function downloadTo ( url , result ) {
1515 return new Bluebird ( function ( resolve , reject ) {
1616 request
1717 . get ( url )
@@ -22,7 +22,7 @@ function downloadTo (url, result) {
2222 } ) ;
2323}
2424
25- function BoostDownloader ( options ) {
25+ function BoostDownloader ( options ) {
2626 this . options = options ;
2727 this . dir = path . join ( environment . home , ".cmake-js" , "boost" ) ;
2828 this . version = options . version ;
@@ -36,7 +36,7 @@ BoostDownloader.prototype.ensureDownloaded = function () {
3636 var self = this ;
3737 self . log . info ( "BOOST" , "Searching for Boost " + self . version + " in '" + self . dir + "'." ) ;
3838 return fs . mkdirpAsync ( self . dir )
39- . then ( function ( ) {
39+ . then ( function ( ) {
4040 return fs . readdirAsync ( self . dir )
4141 } )
4242 . then ( function ( files ) {
@@ -81,7 +81,7 @@ BoostDownloader.prototype.ensureDownloaded = function () {
8181 if ( stat . isFile ( ) ) {
8282 self . log . verbose ( "BOOST" , "Deployment already downloaded. Checking submodules." ) ;
8383 return self . _downloadSubmodules ( semver . valid ( path . basename ( foundDir ) ) , foundDir )
84- . then ( function ( ) {
84+ . then ( function ( ) {
8585 return foundDir ;
8686 } ) ;
8787 }
@@ -119,10 +119,10 @@ BoostDownloader.prototype._download = function () {
119119 }
120120 if ( downloadVersion ) {
121121 self . _downloadVersion ( downloadVersion )
122- . then ( function ( result ) {
122+ . then ( function ( result ) {
123123 resolve ( result ) ;
124124 } )
125- . catch ( function ( e ) {
125+ . catch ( function ( e ) {
126126 reject ( e ) ;
127127 } ) ;
128128 }
@@ -157,7 +157,7 @@ BoostDownloader.prototype._downloadVersion = function (version) {
157157 } ) ;
158158
159159 return fs . mkdirpAsync ( internalPath )
160- . then ( function ( ) {
160+ . then ( function ( ) {
161161 return new Bluebird ( function ( resolve , reject ) {
162162 extracter . once ( "end" , function ( ) {
163163 self . log . verbose ( "BOOST" , "Downloaded: " + internalPath ) ;
@@ -174,7 +174,7 @@ BoostDownloader.prototype._downloadVersion = function (version) {
174174 . then ( function ( ) {
175175 return self . _downloadSubmodules ( version , internalPath ) ;
176176 } )
177- . then ( function ( ) {
177+ . then ( function ( ) {
178178 return internalPath ;
179179 } ) ;
180180} ;
@@ -185,46 +185,56 @@ BoostDownloader.prototype._downloadSubmodules = function (version, internalPath)
185185 self . log . verbose ( "BOOST" , "Checking tools." ) ;
186186 task . push ( self . _downloadSubmo ( version , path . join ( internalPath , "tools" ) , "build" ) ) ;
187187 task . push ( self . _downloadSubmo ( version , path . join ( internalPath , "tools" ) , "inspect" ) ) ;
188- var libsPath = path . join ( internalPath , "libs" ) ;
189- var done = 0 ;
190- task . push (
191- fs . readdirAsync ( libsPath )
192- . then ( function ( libs ) {
193- self . log . verbose ( "BOOST" , "Checking " + libs . length + " libs." ) ;
194- var libTasks = [ ] ;
195- libs . forEach ( function ( lib ) {
196- var fullLibPath = path . join ( libsPath , lib ) ;
197- var stat = fs . lstatSync ( fullLibPath ) ;
198- if ( stat . isDirectory ( ) ) {
199- libTasks . push (
200- self . _downloadSubmo ( version , libsPath , lib )
201- . then ( function ( internalPath ) {
202- ++ done ;
203- if ( internalPath ) {
204- self . log . info ( "BOOST" , ( ( done / libTasks . length ) * 100 ) . toFixed ( 1 ) + "% - Downloaded: " + internalPath ) ;
205- }
206- else {
207- self . log . verbose ( "BOOST" , ( ( done / libTasks . length ) * 100 ) . toFixed ( 1 ) + "% - submodule " + lib + " exists." ) ;
208- }
209- } ) ) ;
210- }
211- } ) ;
212- return Bluebird . all ( libTasks ) ;
213- } ) ) ;
214- return Bluebird . all ( task ) ;
188+ function downloadAt ( libsPath , prefix ) {
189+ var dirName = path . basename ( libsPath ) ;
190+ prefix = prefix || "" ;
191+ self . log . info ( "BOOST" , "Downloading submodules of director '" + dirName + "'." ) ;
192+ var done = 0 ;
193+ task . push (
194+ fs . readdirAsync ( libsPath )
195+ . then ( function ( libs ) {
196+ self . log . verbose ( "BOOST" , "Checking " + libs . length + " libs." ) ;
197+ var libTasks = [ ] ;
198+ libs . forEach ( function ( lib ) {
199+ var fullLibPath = path . join ( libsPath , lib ) ;
200+ var stat = fs . lstatSync ( fullLibPath ) ;
201+ if ( stat . isDirectory ( ) ) {
202+ libTasks . push (
203+ self . _downloadSubmo ( version , libsPath , lib , prefix )
204+ . then ( function ( internalPath ) {
205+ ++ done ;
206+ if ( internalPath ) {
207+ self . log . info ( "BOOST" , ( ( done / libTasks . length ) * 100 ) . toFixed ( 1 ) + "% - submodule " + dirName + "/" + lib + " downloaded." ) ;
208+ }
209+ else {
210+ self . log . verbose ( "BOOST" , ( ( done / libTasks . length ) * 100 ) . toFixed ( 1 ) + "% - submodule " + dirName + "/" + lib + " exists." ) ;
211+ }
212+ } ) ) ;
213+ }
214+ } ) ;
215+ return Bluebird . all ( libTasks ) ;
216+ } ) ) ;
217+ return Bluebird . all ( task ) ;
218+ }
219+
220+ return downloadAt ( path . join ( internalPath , "libs" ) )
221+ . then ( function ( ) {
222+ return downloadAt ( path . join ( internalPath , "libs" , "numeric" ) , "numeric_" ) ;
223+ } ) ;
215224} ;
216225
217- BoostDownloader . prototype . _downloadSubmo = function ( version , internalPath , name ) {
226+ BoostDownloader . prototype . _downloadSubmo = function ( version , internalPath , name , prefix ) {
218227 var self = this ;
228+ prefix = prefix || "" ;
219229 internalPath = path . join ( internalPath , name ) ;
220230
221231 return fs . readdirAsync ( internalPath )
222- . then ( function ( entries ) {
232+ . then ( function ( entries ) {
223233 if ( entries && entries . length ) {
224234 return ;
225235 }
226236
227- var downloadUrl = "https://github.com/boostorg/" + name + "/archive/boost-" + version + ".tar.gz" ;
237+ var downloadUrl = "https://github.com/boostorg/" + prefix + name + "/archive/boost-" + version + ".tar.gz" ;
228238 self . log . http ( "BOOST" , "Downloading: " + downloadUrl ) ;
229239
230240 var gunzip = zlib . createGunzip ( ) ;
0 commit comments