Allow running clippy without target (#982)

This commit is contained in:
Justin Starry 2020-03-01 16:43:22 +08:00 committed by GitHub
parent c991c7c7d9
commit 86af481c0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -1,24 +1,29 @@
use std::env; use std::env;
pub fn main() { pub fn main() {
if cfg!(all(feature = "web_sys", feature = "std_web")) { let using_web_sys = cfg!(feature = "web_sys");
let using_std_web = cfg!(feature = "std_web");
if using_web_sys && using_std_web {
panic!("Yew does not allow the `web_sys` and `std_web` cargo features to be used simultaneously"); panic!("Yew does not allow the `web_sys` and `std_web` cargo features to be used simultaneously");
} else if cfg!(not(any(feature = "web_sys", feature = "std_web"))) { } else if !using_web_sys && !using_std_web {
panic!("Yew requires selecting either the `web_sys` or `std_web` cargo feature"); panic!("Yew requires selecting either the `web_sys` or `std_web` cargo feature");
} }
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
let using_wasi = target_os == "wasi"; let using_wasi = target_os == "wasi";
let cargo_web = env::var("COMPILING_UNDER_CARGO_WEB").unwrap_or_default(); let using_cargo_web = env::var("COMPILING_UNDER_CARGO_WEB").is_ok();
let using_cargo_web = cargo_web == "1"; if using_cargo_web && using_web_sys {
if using_cargo_web && cfg!(feature = "web_sys") {
panic!("cargo-web is not compatible with web-sys"); panic!("cargo-web is not compatible with web-sys");
} }
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
let using_wasm_bindgen = target_arch == "wasm32" && !using_cargo_web && !using_wasi; let using_wasm_bindgen = target_arch == "wasm32" && !using_cargo_web && !using_wasi;
if !using_wasm_bindgen && cfg!(all(feature = "web_sys", not(feature = "doc_test"))) {
let using_clippy = env::var("CLIPPY_ARGS").is_ok();
let running_doc_tests = cfg!(feature = "doc_test");
if !using_wasm_bindgen && using_web_sys && !running_doc_tests && !using_clippy {
let target = env::var("TARGET").unwrap_or_default(); let target = env::var("TARGET").unwrap_or_default();
panic!( panic!(
"Selected target `{}` is not compatible with web-sys", "Selected target `{}` is not compatible with web-sys",

View File

@ -9,4 +9,4 @@ fi
set -euxo pipefail set -euxo pipefail
cargo fmt --all -- --check cargo fmt --all -- --check
cargo clippy --features std_web -- --deny=warnings cargo clippy --features std_web -- --deny=warnings
cargo clippy --target wasm32-unknown-unknown --features web_sys -- --deny=warnings cargo clippy --features web_sys -- --deny=warnings