@@ -163,7 +163,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
163163
164164 let target = opt_str2 ( matches. opt_str ( "target" ) ) ;
165165 let android_cross_path = opt_path ( matches, "android-cross-path" ) ;
166- let cdb = analyze_cdb ( matches. opt_str ( "cdb" ) , & target) ;
166+ let ( cdb, cdb_version ) = analyze_cdb ( matches. opt_str ( "cdb" ) , & target) ;
167167 let ( gdb, gdb_version, gdb_native_rust) =
168168 analyze_gdb ( matches. opt_str ( "gdb" ) , & target, & android_cross_path) ;
169169 let ( lldb_version, lldb_native_rust) = matches
@@ -216,6 +216,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
216216 target,
217217 host : opt_str2 ( matches. opt_str ( "host" ) ) ,
218218 cdb,
219+ cdb_version,
219220 gdb,
220221 gdb_version,
221222 gdb_native_rust,
@@ -773,8 +774,30 @@ fn find_cdb(target: &str) -> Option<OsString> {
773774}
774775
775776/// Returns Path to CDB
776- fn analyze_cdb ( cdb : Option < String > , target : & str ) -> Option < OsString > {
777- cdb. map ( OsString :: from) . or_else ( || find_cdb ( target) )
777+ fn analyze_cdb ( cdb : Option < String > , target : & str ) -> ( Option < OsString > , Option < [ u16 ; 4 ] > ) {
778+ let cdb = cdb. map ( OsString :: from) . or_else ( || find_cdb ( target) ) ;
779+
780+ let mut version = None ;
781+ if let Some ( cdb) = cdb. as_ref ( ) {
782+ if let Ok ( output) = Command :: new ( cdb) . arg ( "/version" ) . output ( ) {
783+ if let Some ( first_line) = String :: from_utf8_lossy ( & output. stdout ) . lines ( ) . next ( ) {
784+ version = extract_cdb_version ( & first_line) ;
785+ }
786+ }
787+ }
788+
789+ ( cdb, version)
790+ }
791+
792+ fn extract_cdb_version ( full_version_line : & str ) -> Option < [ u16 ; 4 ] > {
793+ // Example full_version_line: "cdb version 10.0.18362.1"
794+ let version = full_version_line. rsplit ( ' ' ) . next ( ) ?;
795+ let mut components = version. split ( '.' ) ;
796+ let major: u16 = components. next ( ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
797+ let minor: u16 = components. next ( ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
798+ let patch: u16 = components. next ( ) . unwrap_or ( "0" ) . parse ( ) . unwrap ( ) ;
799+ let build: u16 = components. next ( ) . unwrap_or ( "0" ) . parse ( ) . unwrap ( ) ;
800+ Some ( [ major, minor, patch, build] )
778801}
779802
780803/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
0 commit comments