diff --git a/.travis.yml b/.travis.yml index bce4bcc5778..9868a2e3db6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,15 +22,14 @@ rust: - 1.21.0 - stable - beta - - nightly env: - - FEATURES="native_lib" - FEATURES="" + - FEATURES="client_native" + - FEATURES="server_native" + - FEATURES="client_native server_native" matrix: - allow_failures: - - rust: nightly include: - rust: stable env: BUILD_FMT=1 @@ -98,9 +97,13 @@ script: rustfmt --check tests/scanner_assets/*.rs elif [ -n "$TARPAULIN" ]; then cargo tarpaulin --all --features "" --ignore-tests --out Xml - bash <(curl -s https://codecov.io/bash) -cF rust_impl - cargo tarpaulin --all --features "native_lib" --ignore-tests --out Xml - bash <(curl -s https://codecov.io/bash) -cF native_lib + bash <(curl -s https://codecov.io/bash) -cF full_rust + cargo tarpaulin --all --features "client_native" --ignore-tests --out Xml + bash <(curl -s https://codecov.io/bash) -cF client_native + cargo tarpaulin --all --features "server_native" --ignore-tests --out Xml + bash <(curl -s https://codecov.io/bash) -cF server_native + cargo tarpaulin --all --features "client_native server_native" --ignore-tests --out Xml + bash <(curl -s https://codecov.io/bash) -cF both_native elif [ -n "$CLIPPY" ]; then # - renamed_and_removed and deprecared_cfg_attr are necessary because rust 1.21.0 cannot parse # stuff like #[allow(clippy::all)] or #[rustfmt::skip] @@ -109,16 +112,15 @@ script: -A renamed_and_removed_lints \ -A clippy::deprecated_cfg_attr \ -A clippy::for_loop_over_option - cargo clippy --all --features "native_lib" -- -D warnings \ + cargo clippy --all --features "client_native server_native" -- -D warnings \ -A renamed_and_removed_lints \ -A clippy::deprecated_cfg_attr \ -A clippy::for_loop_over_option - elif [ -n "$BUILD_DOC" ]; then cargo doc --all --no-deps --all-features elif [ -n "$TARGET" ]; then cross build --all --target "$TARGET" - cross build --all --target "$TARGET" --features "native_lib" + cross build --all --target "$TARGET" --features "client_native server_native" else cargo test --all --features "$FEATURES" fi diff --git a/Cargo.toml b/Cargo.toml index acb8303bb83..08ff8100965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ wayland-scanner = { path = "./wayland-scanner" } wayland-client = { path = "./wayland-client", default-features = false, features = ["eventloop"] } wayland-server = { path = "./wayland-server", default-features = false } wayland-protocols = { path = "./wayland-protocols", features = ["client", "server"] } -wayland-sys = { path = "./wayland-sys", optional = true } +wayland-sys = { path = "./wayland-sys" } lazycell = "=1.0.0" [dev-dependencies] @@ -23,7 +23,8 @@ calloop = "0.4.2" members = [ "wayland-sys", "wayland-scanner", "wayland-client", "wayland-server", "wayland-protocols", "wayland-commons" ] [features] -native_lib = [ "wayland-client/dlopen", "wayland-server/dlopen", "wayland-sys" ] +client_native = [ "wayland-client/dlopen" ] +server_native = [ "wayland-server/dlopen" ] # Manual list of the tests, required because some need `harness = false` diff --git a/tests/globals.rs b/tests/globals.rs index 1607e9c9712..b4ac1eae9bd 100644 --- a/tests/globals.rs +++ b/tests/globals.rs @@ -153,7 +153,7 @@ fn wrong_version_create_global() { } #[test] -#[cfg_attr(feature = "native_lib", ignore)] +#[cfg_attr(feature = "server_native", ignore)] fn wrong_global() { use wayc::protocol::wl_output::WlOutput; diff --git a/tests/protocol_errors.rs b/tests/protocol_errors.rs index 681a68b2d2d..e44ef63c090 100644 --- a/tests/protocol_errors.rs +++ b/tests/protocol_errors.rs @@ -128,7 +128,7 @@ fn client_receive_error() { assert_eq!(error.object_id, 3); assert_eq!(error.object_interface, "wl_output"); // native lib can't give us the message - #[cfg(not(feature = "native_lib"))] + #[cfg(not(feature = "client_native"))] { assert_eq!(error.message, "I don't like you!"); } diff --git a/tests/send_sync.rs b/tests/send_sync.rs index d6338fd2401..df76634e686 100644 --- a/tests/send_sync.rs +++ b/tests/send_sync.rs @@ -9,7 +9,7 @@ fn send_sync_client() { ensure_both::>(); } -#[cfg(not(feature = "native_lib"))] +#[cfg(not(feature = "server_native"))] #[test] fn send_sync_server() { ensure_both::>(); diff --git a/tests/server_created_object.rs b/tests/server_created_object.rs index bacb818f1da..c95916d6418 100644 --- a/tests/server_created_object.rs +++ b/tests/server_created_object.rs @@ -389,7 +389,7 @@ fn server_created_race() { // this test currently crashes when using native_lib, this is a bug from the C lib // see https://gitlab.freedesktop.org/wayland/wayland/issues/74 -#[cfg(not(feature = "native_lib"))] +#[cfg(not(feature = "client_native"))] #[test] fn creation_destruction_race() { let mut server = TestServer::new(); @@ -470,7 +470,7 @@ fn creation_destruction_race() { .as_ref() .client() .unwrap() - .create_resource::(server_dd.borrow()[0].as_ref().version()) + .create_resource::(server_dd.borrow()[1].as_ref().version()) .unwrap() .implement_dummy(); server_dd.borrow()[1].data_offer(&offer2); diff --git a/tests/server_resources.rs b/tests/server_resources.rs index a1c4b89150e..50caf10e242 100644 --- a/tests/server_resources.rs +++ b/tests/server_resources.rs @@ -84,7 +84,7 @@ fn resource_user_data() { assert!(cloned.as_ref().user_data::() == Some(&1000)); } -#[cfg(not(feature = "native_lib"))] +#[cfg(not(feature = "server_native"))] #[test] fn resource_user_data_wrong_thread() { let mut server = TestServer::new(); @@ -124,7 +124,7 @@ fn resource_user_data_wrong_thread() { .unwrap(); } -#[cfg(not(feature = "native_lib"))] +#[cfg(not(feature = "server_native"))] #[test] fn resource_implement_wrong_thread() { let server = TestServer::new(); diff --git a/wayland-client/src/proxy.rs b/wayland-client/src/proxy.rs index aa346487c51..ff5e9648b25 100644 --- a/wayland-client/src/proxy.rs +++ b/wayland-client/src/proxy.rs @@ -63,8 +63,17 @@ impl Proxy { /// /// If your request needs to create an object, use `send_constructor`. pub fn send(&self, msg: I::Request) { - if !self.is_alive() { - return; + #[cfg(feature = "native_lib")] + { + if !self.is_external() && !self.is_alive() { + return; + } + } + #[cfg(not(feature = "native_lib"))] + { + if !self.is_alive() { + return; + } } if msg.since() > self.version() { let opcode = msg.opcode() as usize; diff --git a/wayland-server/src/resource.rs b/wayland-server/src/resource.rs index e5ff4c5888d..995e7d8aa0c 100644 --- a/wayland-server/src/resource.rs +++ b/wayland-server/src/resource.rs @@ -47,6 +47,18 @@ impl Resource { /// The event will be send to the client associated to this /// object. pub fn send(&self, msg: I::Event) { + #[cfg(feature = "native_lib")] + { + if !self.is_external() && !self.is_alive() { + return; + } + } + #[cfg(not(feature = "native_lib"))] + { + if !self.is_alive() { + return; + } + } if msg.since() > self.version() { let opcode = msg.opcode() as usize; panic!(