@@ -907,47 +907,59 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> [attribute] {
907
907
908
908
fn encode_crate_deps( ebml_w: ebml:: writer, cstore: cstore:: cstore) {
909
909
910
- fn get_ordered_names ( cstore: cstore:: cstore) -> [ str ] {
910
+ fn get_ordered_deps ( cstore: cstore:: cstore) -> [ decoder :: crate_dep ] {
911
911
type hashkv = @{ key: crate_num, val: cstore:: crate_metadata} ;
912
- type numname = { crate : crate_num , ident : str } ;
912
+ type numdep = decoder :: crate_dep ;
913
913
914
- // Pull the cnums and names out of cstore
915
- let mut pairs : [ mut numname ] = [ mut ] ;
914
+ // Pull the cnums and name,vers,hash out of cstore
915
+ let mut deps : [ mut numdep ] = [ mut ] ;
916
916
cstore:: iter_crate_data( cstore) { |key, val|
917
- pairs += [ mut { crate : key, ident: val. name} ] ;
917
+ let dep = { cnum : key, name : val. name,
918
+ vers : decoder:: get_crate_vers( val. data) ,
919
+ hash : decoder:: get_crate_hash( val. data) } ;
920
+ deps += [ mut dep] ;
918
921
} ;
919
922
920
923
// Sort by cnum
921
- fn lteq( kv1: numname , kv2: numname ) -> bool { kv1. crate <= kv2. crate }
922
- std:: sort:: quick_sort( lteq, pairs ) ;
924
+ fn lteq( kv1: numdep , kv2: numdep ) -> bool { kv1. cnum <= kv2. cnum }
925
+ std:: sort:: quick_sort( lteq, deps ) ;
923
926
924
927
// Sanity-check the crate numbers
925
928
let mut expected_cnum = 1 ;
926
- for pairs . each { |n|
927
- assert ( n. crate == expected_cnum) ;
929
+ for deps . each { |n|
930
+ assert ( n. cnum == expected_cnum) ;
928
931
expected_cnum += 1 ;
929
932
}
930
933
931
- // Return just the names
932
- fn name( kv: numname) -> str { kv. ident }
933
934
// mut -> immutable hack for vec::map
934
- let immpairs = vec:: slice( pairs, 0 u, vec:: len( pairs) ) ;
935
- ret vec:: map( immpairs, name) ;
935
+ ret vec:: slice( deps, 0 u, vec:: len( deps) ) ;
936
936
}
937
937
938
- // We're just going to write a list of crate names , with the assumption
939
- // that they are numbered 1 to n.
938
+ // We're just going to write a list of crate 'name-hash-version's , with
939
+ // the assumption that they are numbered 1 to n.
940
940
// FIXME: This is not nearly enough to support correct versioning
941
941
// but is enough to get transitive crate dependencies working.
942
942
ebml_w. start_tag( tag_crate_deps) ;
943
- for get_ordered_names( cstore) . each { |cname|
944
- ebml_w. start_tag( tag_crate_dep) ;
945
- ebml_w. writer. write( str :: bytes( cname) ) ;
946
- ebml_w. end_tag( ) ;
943
+ for get_ordered_deps( cstore) . each { |dep|
944
+ encode_crate_dep( ebml_w, dep) ;
947
945
}
948
946
ebml_w. end_tag( ) ;
949
947
}
950
948
949
+ fn encode_crate_dep( ebml_w: ebml:: writer, dep: decoder:: crate_dep) {
950
+ ebml_w. start_tag( tag_crate_dep) ;
951
+ ebml_w. start_tag( tag_crate_dep_name) ;
952
+ ebml_w. writer. write( str :: bytes( dep. name) ) ;
953
+ ebml_w. end_tag( ) ;
954
+ ebml_w. start_tag( tag_crate_dep_vers) ;
955
+ ebml_w. writer. write( str :: bytes( dep. vers) ) ;
956
+ ebml_w. end_tag( ) ;
957
+ ebml_w. start_tag( tag_crate_dep_hash) ;
958
+ ebml_w. writer. write( str :: bytes( dep. hash) ) ;
959
+ ebml_w. end_tag( ) ;
960
+ ebml_w. end_tag( ) ;
961
+ }
962
+
951
963
fn encode_hash( ebml_w: ebml:: writer, hash: str ) {
952
964
ebml_w. start_tag( tag_crate_hash) ;
953
965
ebml_w. writer. write( str :: bytes( hash) ) ;
0 commit comments