-
Notifications
You must be signed in to change notification settings - Fork 64
Allow building as dependency on docs.rs with no features enabled #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
target | ||
Cargo.lock | ||
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#![allow(dead_code)] | ||
|
||
fn build_glue_for_game_activity() { | ||
for f in [ | ||
"GameActivity.h", | ||
|
@@ -46,6 +44,16 @@ fn build_glue_for_game_activity() { | |
} | ||
|
||
fn main() { | ||
#[cfg(feature = "game-activity")] | ||
build_glue_for_game_activity(); | ||
// Avoid re-running build script if nothing changed. | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
Comment on lines
+47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe "nothing" should be clarified to "avoid re-running the build script if anything but the build script changed". At first I thought this was redundant, but supposedly the build script reruns on any file changes inside the package directory by default unless specified with |
||
|
||
if cfg!(feature = "game-activity") { | ||
build_glue_for_game_activity(); | ||
} | ||
|
||
// Whether this is used directly in or as a dependency on docs.rs. | ||
println!("cargo:rustc-check-cfg=cfg(used_on_docsrs)"); | ||
if std::env::var("DOCS_RS").is_ok() { | ||
println!("cargo:rustc-cfg=used_on_docsrs"); | ||
Comment on lines
+54
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe link the doc here that says that |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,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 | ||
|
@@ -159,8 +159,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")] | ||
Comment on lines
-162
to
-163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little fuzzy on the old implementation here. Setting Additionally, this together with the redundant |
||
#[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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one, it looks like we deliberately didn't check one in but forgot to exclude it globally.
The other gitignore in the crate should be useless as these files are created at the workspace root, i.e. here. In light of that, can you prefix these with
/
to ensure they only ignore this file in the root of the repository to match that?