@@ -5,7 +5,6 @@ use anyhow::Result;
55use indexmap:: IndexMap ;
66use owo_colors:: OwoColorize ;
77use parsers:: firehose_parser_ack_nak;
8- use serial:: setup_serial_device;
98use std:: cmp:: min;
109use std:: io:: { Read , Write } ;
1110use std:: str:: { self , FromStr } ;
@@ -15,7 +14,6 @@ use types::FirehoseStorageType;
1514use types:: QdlBackend ;
1615use types:: QdlChan ;
1716use types:: QdlReadWrite ;
18- use usb:: setup_usb_device;
1917
2018use anyhow:: bail;
2119use pbr:: { ProgressBar , Units } ;
@@ -31,18 +29,23 @@ pub mod usb;
3129
3230pub fn setup_target_device (
3331 backend : QdlBackend ,
34- serial_no : Option < String > ,
35- port : Option < String > ,
32+ _serial_no : Option < String > ,
33+ _port : Option < String > ,
3634) -> Result < Box < dyn QdlReadWrite > > {
3735 match backend {
38- QdlBackend :: Serial => match setup_serial_device ( port) {
36+ #[ cfg( feature = "serial" ) ]
37+ QdlBackend :: Serial => match serial:: setup_serial_device ( _port) {
3938 Ok ( d) => Ok ( Box :: new ( d) ) ,
4039 Err ( e) => Err ( e) ,
4140 } ,
42- QdlBackend :: Usb => match setup_usb_device ( serial_no) {
41+ #[ cfg( feature = "usb" ) ]
42+ QdlBackend :: Usb => match usb:: setup_usb_device ( _serial_no) {
4343 Ok ( d) => Ok ( Box :: new ( d) ) ,
4444 Err ( e) => Err ( e) ,
4545 } ,
46+ // If all back-ends are compiled in, this throws a warning
47+ #[ allow( unreachable_patterns) ]
48+ _ => bail ! ( "The {:?} backend is not supported in this build" , backend) ,
4649 }
4750}
4851
0 commit comments