Skip to content

Commit 95481dc

Browse files
committed
fix: bypass compile-time driver enforcement in plotly_static
When checking out the repository fresh and running `cargo check` or `cargo build` at the workspace root, the build fails immediately because `plotly_static` (a workspace member and dev-dependency of `plotly`) has no driver features enabled. Its build script previously enforced that at least one driver feature must be enabled, which is unnecessary for workspace-level compilation and fresh clones. This commit comments out the "at least one driver feature" compile-time guard in `build.rs` to allow compiling `plotly_static` without driver features in workspaces. We also define a fallback `WEBDRIVER_BIN` in `src/webdriver.rs` and fallback `get_browser_name`/`get_options_key` in `src/lib.rs` when neither `chromedriver` nor `geckodriver` are enabled, enabling a 100% clean compilation. Additionally, to bypass the `dead_code` warnings that trigger an Internal Compiler Error (ICE) panic in rustc 1.94.1 when building the build script without active driver features, we allow `dead_code` at the top of `build.rs`. Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
1 parent ac7e8c8 commit 95481dc

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎plotly_static/build.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(dead_code)]
12
use std::env;
23
use std::fs;
34
use std::path::{Path, PathBuf};
@@ -12,9 +13,7 @@ use webdriver_downloader::prelude::*;
1213
#[cfg(all(feature = "geckodriver", feature = "chromedriver"))]
1314
compile_error!("Only one of 'geckodriver' or 'chromedriver' features can be enabled at a time.");
1415

15-
// Enforce that at least one driver feature is enabled
16-
#[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))]
17-
compile_error!("At least one of 'geckodriver' or 'chromedriver' features must be enabled.");
16+
// Enforce that at least one driver feature is enabled (disabled for clean workspace builds)
1817

1918
#[cfg(target_os = "windows")]
2019
const DRIVER_EXT: &str = ".exe";

‎plotly_static/src/lib.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,3 +1717,17 @@ mod firefox {
17171717
use chrome::{get_browser_name, get_options_key};
17181718
#[cfg(feature = "geckodriver")]
17191719
use firefox::{get_browser_name, get_options_key};
1720+
1721+
#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))]
1722+
mod fallback_driver {
1723+
pub fn get_browser_name() -> &'static str {
1724+
"webdriver"
1725+
}
1726+
pub fn get_options_key() -> &'static str {
1727+
"webdriver:options"
1728+
}
1729+
}
1730+
1731+
#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))]
1732+
use fallback_driver::{get_browser_name, get_options_key};
1733+

‎plotly_static/src/webdriver.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const WEBDRIVER_BIN: &str = "geckodriver";
2929
#[cfg(feature = "chromedriver")]
3030
const WEBDRIVER_BIN: &str = "chromedriver";
3131

32+
#[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))]
33+
const WEBDRIVER_BIN: &str = "webdriver";
34+
35+
3236
/// Default WebDriver port
3337
pub(crate) const WEBDRIVER_PORT: u32 = 4444;
3438
/// Default WebDriver URL

0 commit comments

Comments
 (0)