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
-
3
1
fn build_glue_for_game_activity ( ) {
4
2
let android_games_sdk =
5
3
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() {
94
92
}
95
93
96
94
fn 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
+ }
99
112
}
Original file line number Diff line number Diff line change 1
- #![ cfg( feature = "game-activity" ) ]
2
-
3
1
use std:: collections:: HashMap ;
4
2
use std:: marker:: PhantomData ;
5
3
use std:: ops:: Deref ;
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ compile_error!(
141
141
) ;
142
142
#[ cfg( all(
143
143
not( any( feature = "game-activity" , feature = "native-activity" ) ) ,
144
- not( doc)
144
+ not( any ( doc, used_on_docsrs ) ) ,
145
145
) ) ]
146
146
compile_error ! (
147
147
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
160
160
android-activity is used across all of your application's crates."#
161
161
) ;
162
162
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
+ ) ]
165
175
pub ( crate ) mod activity_impl;
166
176
167
177
pub mod error;
Original file line number Diff line number Diff line change 1
- #![ cfg( any( feature = "native-activity" , doc) ) ]
2
-
3
1
use std:: collections:: HashMap ;
4
2
use std:: marker:: PhantomData ;
5
3
use std:: panic:: AssertUnwindSafe ;
You can’t perform that action at this time.
0 commit comments