File tree Expand file tree Collapse file tree 4 files changed +30
-11
lines changed Expand file tree Collapse file tree 4 files changed +30
-11
lines changed Original file line number Diff line number Diff line change 1- #![ allow( dead_code) ]
2-
31fn build_glue_for_game_activity ( ) {
42 let android_games_sdk =
53 std:: env:: var ( "ANDROID_GAMES_SDK" ) . unwrap_or_else ( |_err| "android-games-sdk" . to_string ( ) ) ;
@@ -94,6 +92,21 @@ fn build_glue_for_game_activity() {
9492}
9593
9694fn main ( ) {
97- #[ cfg( feature = "game-activity" ) ]
98- build_glue_for_game_activity ( ) ;
95+ // Enable Cargo's change-detection to avoid re-running build script if
96+ // irrelvant parts changed. Using build.rs here is just a dummy used to
97+ // disable the default "rerun on every change" behaviour Cargo has.
98+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
99+
100+ if cfg ! ( feature = "game-activity" ) {
101+ build_glue_for_game_activity ( ) ;
102+ }
103+
104+ // Whether this is used directly in or as a dependency on docs.rs.
105+ //
106+ // `cfg(docsrs)` cannot be used, since it's only set for the crate being
107+ // built, and not for any dependent crates.
108+ println ! ( "cargo:rustc-check-cfg=cfg(used_on_docsrs)" ) ;
109+ if std:: env:: var ( "DOCS_RS" ) . is_ok ( ) {
110+ println ! ( "cargo:rustc-cfg=used_on_docsrs" ) ;
111+ }
99112}
Original file line number Diff line number Diff line change 1- #![ cfg( feature = "game-activity" ) ]
2-
31use std:: collections:: HashMap ;
42use std:: marker:: PhantomData ;
53use std:: ops:: Deref ;
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ compile_error!(
141141) ;
142142#[ cfg( all(
143143 not( any( feature = "game-activity" , feature = "native-activity" ) ) ,
144- not( doc)
144+ not( any ( doc, used_on_docsrs ) ) ,
145145) ) ]
146146compile_error ! (
147147 r#"Either "game-activity" or "native-activity" must be enabled as features
@@ -160,8 +160,18 @@ You may need to add a `[patch]` into your Cargo.toml to ensure a specific versio
160160android-activity is used across all of your application's crates."#
161161) ;
162162
163- #[ cfg_attr( any( feature = "native-activity" , doc) , path = "native_activity/mod.rs" ) ]
164- #[ cfg_attr( any( feature = "game-activity" , doc) , path = "game_activity/mod.rs" ) ]
163+ #[ cfg_attr( feature = "native-activity" , path = "native_activity/mod.rs" ) ]
164+ #[ cfg_attr( feature = "game-activity" , path = "game_activity/mod.rs" ) ]
165+ #[ cfg_attr(
166+ all(
167+ // No activities enabled.
168+ not( any( feature = "native-activity" , feature = "game-activity" ) ) ,
169+ // And building docs.
170+ any( doc, used_on_docsrs) ,
171+ ) ,
172+ // Fall back to documenting native activity.
173+ path = "native_activity/mod.rs"
174+ ) ]
165175pub ( crate ) mod activity_impl;
166176
167177pub mod error;
Original file line number Diff line number Diff line change 1- #![ cfg( any( feature = "native-activity" , doc) ) ]
2-
31use std:: collections:: HashMap ;
42use std:: marker:: PhantomData ;
53use std:: panic:: AssertUnwindSafe ;
You can’t perform that action at this time.
0 commit comments