@@ -22,6 +22,7 @@ use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_r
2222use util:: compile_crate;
2323use workspace:: is_workspace;
2424use workcache_support;
25+ use workcache_support:: crate_tag;
2526use extra:: workcache;
2627
2728// An enumeration of the unpacked source of a package workspace.
@@ -231,7 +232,7 @@ impl PkgSrc {
231232 p. filestem ( ) . map_default ( false , |p| { p == & self . id . short_name . as_slice ( ) } )
232233 }
233234
234- fn push_crate ( cs : & mut ~[ Crate ] , prefix : uint , p : & Path ) {
235+ pub fn push_crate ( cs : & mut ~[ Crate ] , prefix : uint , p : & Path ) {
235236 assert ! ( p. components. len( ) > prefix) ;
236237 let mut sub = Path ( "" ) ;
237238 for c in p. components . slice ( prefix, p. components . len ( ) ) . iter ( ) {
@@ -286,7 +287,6 @@ impl PkgSrc {
286287
287288 fn build_crates ( & self ,
288289 ctx : & BuildContext ,
289- exec : & mut workcache:: Exec ,
290290 destination_dir : & Path ,
291291 crates : & [ Crate ] ,
292292 cfgs : & [ ~str ] ,
@@ -297,25 +297,40 @@ impl PkgSrc {
297297 let path_str = path. to_str ( ) ;
298298 let cfgs = crate . cfgs + cfgs;
299299
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+ } ;
312325 }
313326 }
314327
315328 /// Declare all the crate files in the package source as inputs
329+ /// (to the package)
316330 pub fn declare_inputs ( & self , prep : & mut workcache:: Prep ) {
317331 let to_do = ~[ self . libs . clone ( ) , self . mains . clone ( ) ,
318332 self . tests . clone ( ) , self . benchs . clone ( ) ] ;
333+ debug ! ( "In declare inputs, self = %s" , self . to_str( ) ) ;
319334 for cs in to_do. iter ( ) {
320335 for c in cs. iter ( ) {
321336 let path = self . start_dir . push_rel ( & c. file ) . normalize ( ) ;
@@ -330,7 +345,6 @@ impl PkgSrc {
330345 // It would be better if build returned a Path, but then Path would have to derive
331346 // Encodable.
332347 pub fn build ( & self ,
333- exec : & mut workcache:: Exec ,
334348 build_context : & BuildContext ,
335349 cfgs : ~[ ~str ] ) -> ~str {
336350 use conditions:: not_a_workspace:: cond;
@@ -360,13 +374,23 @@ impl PkgSrc {
360374 let benchs = self . benchs . clone ( ) ;
361375 debug ! ( "Building libs in %s, destination = %s" ,
362376 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 ) ;
364378 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 ) ;
366380 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 ) ;
368382 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 ) ;
370384 destination_workspace. to_str ( )
371385 }
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+ }
372396}
0 commit comments