Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
/target
/Cargo.lock
10 changes: 0 additions & 10 deletions android-activity/.gitignore

This file was deleted.

21 changes: 17 additions & 4 deletions android-activity/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(dead_code)]

fn build_glue_for_game_activity() {
let android_games_sdk =
std::env::var("ANDROID_GAMES_SDK").unwrap_or_else(|_err| "android-games-sdk".to_string());
Expand Down Expand Up @@ -94,6 +92,21 @@ fn build_glue_for_game_activity() {
}

fn main() {
#[cfg(feature = "game-activity")]
build_glue_for_game_activity();
// Enable Cargo's change-detection to avoid re-running build script if
// irrelvant parts changed. Using build.rs here is just a dummy used to
// disable the default "rerun on every change" behaviour Cargo has.
println!("cargo:rerun-if-changed=build.rs");

if cfg!(feature = "game-activity") {
build_glue_for_game_activity();
}

// Whether this is used directly in or as a dependency on docs.rs.
//
// `cfg(docsrs)` cannot be used, since it's only set for the crate being
// built, and not for any dependent crates.
println!("cargo:rustc-check-cfg=cfg(used_on_docsrs)");
if std::env::var("DOCS_RS").is_ok() {
println!("cargo:rustc-cfg=used_on_docsrs");
}
}
2 changes: 0 additions & 2 deletions android-activity/src/game_activity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "game-activity")]

use std::collections::HashMap;
use std::marker::PhantomData;
use std::ops::Deref;
Expand Down
16 changes: 13 additions & 3 deletions android-activity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ compile_error!(
);
#[cfg(all(
not(any(feature = "game-activity", feature = "native-activity")),
not(doc)
not(any(doc, used_on_docsrs)),
))]
compile_error!(
r#"Either "game-activity" or "native-activity" must be enabled as features
Expand All @@ -160,8 +160,18 @@ You may need to add a `[patch]` into your Cargo.toml to ensure a specific versio
android-activity is used across all of your application's crates."#
);

#[cfg_attr(any(feature = "native-activity", doc), path = "native_activity/mod.rs")]
#[cfg_attr(any(feature = "game-activity", doc), path = "game_activity/mod.rs")]
#[cfg_attr(feature = "native-activity", path = "native_activity/mod.rs")]
#[cfg_attr(feature = "game-activity", path = "game_activity/mod.rs")]
#[cfg_attr(
all(
// No activities enabled.
not(any(feature = "native-activity", feature = "game-activity")),
// And building docs.
any(doc, used_on_docsrs),
),
// Fall back to documenting native activity.
path = "native_activity/mod.rs"
)]
pub(crate) mod activity_impl;

pub mod error;
Expand Down
2 changes: 0 additions & 2 deletions android-activity/src/native_activity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(any(feature = "native-activity", doc))]

use std::collections::HashMap;
use std::marker::PhantomData;
use std::panic::AssertUnwindSafe;
Expand Down