Skip to content

Commit d1b3191

Browse files
committed
qdl: Allow non-fully-[feature]d builds
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
1 parent 223093f commit d1b3191

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

qdl/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use anyhow::Result;
55
use indexmap::IndexMap;
66
use owo_colors::OwoColorize;
77
use parsers::firehose_parser_ack_nak;
8-
use serial::setup_serial_device;
98
use std::cmp::min;
109
use std::io::{Read, Write};
1110
use std::str::{self, FromStr};
@@ -15,7 +14,6 @@ use types::FirehoseStorageType;
1514
use types::QdlBackend;
1615
use types::QdlChan;
1716
use types::QdlReadWrite;
18-
use usb::setup_usb_device;
1917

2018
use anyhow::bail;
2119
use pbr::{ProgressBar, Units};
@@ -31,18 +29,23 @@ pub mod usb;
3129

3230
pub 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

Comments
 (0)