File tree Expand file tree Collapse file tree 4 files changed +25
-11
lines changed Expand file tree Collapse file tree 4 files changed +25
-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
for f in [
5
3
"GameActivity.h" ,
@@ -46,6 +44,16 @@ fn build_glue_for_game_activity() {
46
44
}
47
45
48
46
fn main ( ) {
49
- #[ cfg( feature = "game-activity" ) ]
50
- build_glue_for_game_activity ( ) ;
47
+ // Avoid re-running build script if nothing changed.
48
+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
49
+
50
+ if cfg ! ( feature = "game-activity" ) {
51
+ build_glue_for_game_activity ( ) ;
52
+ }
53
+
54
+ // Whether this is used directly in or as a dependency on docs.rs.
55
+ println ! ( "cargo:rustc-check-cfg=cfg(used_on_docsrs)" ) ;
56
+ if std:: env:: var ( "DOCS_RS" ) . is_ok ( ) {
57
+ println ! ( "cargo:rustc-cfg=used_on_docsrs" ) ;
58
+ }
51
59
}
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 @@ -140,7 +140,7 @@ compile_error!(
140
140
) ;
141
141
#[ cfg( all(
142
142
not( any( feature = "game-activity" , feature = "native-activity" ) ) ,
143
- not( doc)
143
+ not( any ( doc, used_on_docsrs ) ) ,
144
144
) ) ]
145
145
compile_error ! (
146
146
r#"Either "game-activity" or "native-activity" must be enabled as features
@@ -159,8 +159,18 @@ You may need to add a `[patch]` into your Cargo.toml to ensure a specific versio
159
159
android-activity is used across all of your application's crates."#
160
160
) ;
161
161
162
- #[ cfg_attr( any( feature = "native-activity" , doc) , path = "native_activity/mod.rs" ) ]
163
- #[ cfg_attr( any( feature = "game-activity" , doc) , path = "game_activity/mod.rs" ) ]
162
+ #[ cfg_attr( feature = "native-activity" , path = "native_activity/mod.rs" ) ]
163
+ #[ cfg_attr( feature = "game-activity" , path = "game_activity/mod.rs" ) ]
164
+ #[ cfg_attr(
165
+ all(
166
+ // No activities enabled.
167
+ not( any( feature = "native-activity" , feature = "game-activity" ) ) ,
168
+ // And building docs.
169
+ any( doc, used_on_docsrs) ,
170
+ ) ,
171
+ // Fall back to documenting native activity.
172
+ path = "native_activity/mod.rs"
173
+ ) ]
164
174
pub ( crate ) mod activity_impl;
165
175
166
176
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