@@ -163,7 +163,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
163
163
164
164
let target = opt_str2 ( matches. opt_str ( "target" ) ) ;
165
165
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) ;
167
167
let ( gdb, gdb_version, gdb_native_rust) =
168
168
analyze_gdb ( matches. opt_str ( "gdb" ) , & target, & android_cross_path) ;
169
169
let ( lldb_version, lldb_native_rust) = matches
@@ -216,6 +216,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
216
216
target,
217
217
host : opt_str2 ( matches. opt_str ( "host" ) ) ,
218
218
cdb,
219
+ cdb_version,
219
220
gdb,
220
221
gdb_version,
221
222
gdb_native_rust,
@@ -773,8 +774,30 @@ fn find_cdb(target: &str) -> Option<OsString> {
773
774
}
774
775
775
776
/// 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] )
778
801
}
779
802
780
803
/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
0 commit comments