@@ -22,6 +22,7 @@ use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_r
22
22
use util:: compile_crate;
23
23
use workspace:: is_workspace;
24
24
use workcache_support;
25
+ use workcache_support:: crate_tag;
25
26
use extra:: workcache;
26
27
27
28
// An enumeration of the unpacked source of a package workspace.
@@ -231,7 +232,7 @@ impl PkgSrc {
231
232
p. filestem ( ) . map_default ( false , |p| { p == & self . id . short_name . as_slice ( ) } )
232
233
}
233
234
234
- fn push_crate ( cs : & mut ~[ Crate ] , prefix : uint , p : & Path ) {
235
+ pub fn push_crate ( cs : & mut ~[ Crate ] , prefix : uint , p : & Path ) {
235
236
assert ! ( p. components. len( ) > prefix) ;
236
237
let mut sub = Path ( "" ) ;
237
238
for c in p. components . slice ( prefix, p. components . len ( ) ) . iter ( ) {
@@ -286,7 +287,6 @@ impl PkgSrc {
286
287
287
288
fn build_crates ( & self ,
288
289
ctx : & BuildContext ,
289
- exec : & mut workcache:: Exec ,
290
290
destination_dir : & Path ,
291
291
crates : & [ Crate ] ,
292
292
cfgs : & [ ~str ] ,
@@ -297,25 +297,40 @@ impl PkgSrc {
297
297
let path_str = path. to_str ( ) ;
298
298
let cfgs = crate . cfgs + cfgs;
299
299
300
- let result =
301
- // compile_crate should return the path of the output artifact
302
- compile_crate ( ctx,
303
- exec,
304
- & self . id ,
305
- & path,
306
- destination_dir,
307
- crate . flags,
308
- cfgs,
309
- false ,
310
- what) . to_str ( ) ;
311
- debug ! ( "Result of compiling %s was %s" , path_str, result) ;
300
+ do ctx. workcache_context . with_prep ( crate_tag ( & path) ) |prep| {
301
+ debug ! ( "Building crate %s, declaring it as an input" , path. to_str( ) ) ;
302
+ prep. declare_input ( "file" , path. to_str ( ) ,
303
+ workcache_support:: digest_file_with_date ( & path) ) ;
304
+ let subpath = path. clone ( ) ;
305
+ let subcfgs = cfgs. clone ( ) ;
306
+ let subpath_str = path_str. clone ( ) ;
307
+ let subcx = ctx. clone ( ) ;
308
+ let id = self . id . clone ( ) ;
309
+ let sub_dir = destination_dir. clone ( ) ;
310
+ let sub_flags = crate . flags. clone ( ) ;
311
+ do prep. exec |exec| {
312
+ let result = compile_crate ( & subcx,
313
+ exec,
314
+ & id,
315
+ & subpath,
316
+ & sub_dir,
317
+ sub_flags,
318
+ subcfgs,
319
+ false ,
320
+ what) . to_str ( ) ;
321
+ debug ! ( "Result of compiling %s was %s" , subpath_str, result) ;
322
+ result
323
+ }
324
+ } ;
312
325
}
313
326
}
314
327
315
328
/// Declare all the crate files in the package source as inputs
329
+ /// (to the package)
316
330
pub fn declare_inputs ( & self , prep : & mut workcache:: Prep ) {
317
331
let to_do = ~[ self . libs . clone ( ) , self . mains . clone ( ) ,
318
332
self . tests . clone ( ) , self . benchs . clone ( ) ] ;
333
+ debug ! ( "In declare inputs, self = %s" , self . to_str( ) ) ;
319
334
for cs in to_do. iter ( ) {
320
335
for c in cs. iter ( ) {
321
336
let path = self . start_dir . push_rel ( & c. file ) . normalize ( ) ;
@@ -330,7 +345,6 @@ impl PkgSrc {
330
345
// It would be better if build returned a Path, but then Path would have to derive
331
346
// Encodable.
332
347
pub fn build ( & self ,
333
- exec : & mut workcache:: Exec ,
334
348
build_context : & BuildContext ,
335
349
cfgs : ~[ ~str ] ) -> ~str {
336
350
use conditions:: not_a_workspace:: cond;
@@ -360,13 +374,23 @@ impl PkgSrc {
360
374
let benchs = self . benchs . clone ( ) ;
361
375
debug ! ( "Building libs in %s, destination = %s" ,
362
376
destination_workspace. to_str( ) , destination_workspace. to_str( ) ) ;
363
- self . build_crates ( build_context, exec , & destination_workspace, libs, cfgs, Lib ) ;
377
+ self . build_crates ( build_context, & destination_workspace, libs, cfgs, Lib ) ;
364
378
debug ! ( "Building mains" ) ;
365
- self . build_crates ( build_context, exec , & destination_workspace, mains, cfgs, Main ) ;
379
+ self . build_crates ( build_context, & destination_workspace, mains, cfgs, Main ) ;
366
380
debug ! ( "Building tests" ) ;
367
- self . build_crates ( build_context, exec , & destination_workspace, tests, cfgs, Test ) ;
381
+ self . build_crates ( build_context, & destination_workspace, tests, cfgs, Test ) ;
368
382
debug ! ( "Building benches" ) ;
369
- self . build_crates ( build_context, exec , & destination_workspace, benchs, cfgs, Bench ) ;
383
+ self . build_crates ( build_context, & destination_workspace, benchs, cfgs, Bench ) ;
370
384
destination_workspace. to_str ( )
371
385
}
386
+
387
+ /// Debugging
388
+ pub fn dump_crates ( & self ) {
389
+ let crate_sets = [ & self . libs , & self . mains , & self . tests , & self . benchs ] ;
390
+ for crate_set in crate_sets. iter ( ) {
391
+ for c in crate_set. iter ( ) {
392
+ debug ! ( "Built crate: %s" , c. file. to_str( ) )
393
+ }
394
+ }
395
+ }
372
396
}
0 commit comments