Skip to content
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

Work around docs.rs problem with cargo (ref #240) #241

Closed
wants to merge 3 commits into from
Closed
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
features: ["", "--all-features"]
features: ["", "--features bindgen,array"]

steps:
- name: Checkout code
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

strategy:
matrix:
features: ["", "--all-features"]
features: ["", "--features bindgen,array"]

steps:
- name: Checkout code
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:

strategy:
matrix:
features: ["", "--all-features"]
features: ["", "--features bindgen,array"]

steps:
- name: Checkout code
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:

strategy:
matrix:
features: ["", "--all-features"]
features: ["", "--features bindgen,array"]

steps:
- name: Checkout code
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:

strategy:
matrix:
features: ["", "--all-features"]
features: ["", "--features bindgen,array"]

steps:
- name: Checkout code
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edition = "2021"
default = []
bindgen = ["gdal-sys/bindgen"]
array = ["ndarray"]
docsrs = []

[dependencies]
thiserror = "1.0"
Expand All @@ -38,3 +39,4 @@ members = ["gdal-sys"]

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
features = [ "docsrs" ]
11 changes: 9 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use std::str::FromStr;

#[cfg(docsrs)]
#[cfg(feature = "docsrs")]
pub fn gdal_version_info(_key: &str) -> String {
if std::env::var("DOCS_RS").is_err() {
panic!(
r#"The `docsrs` feature should not be enabled.
If you are using the `--all-features` flag, try replacing it with `--features bindgen,array`.
See https://github.com/georust/gdal/pull/241 for more details."#
);
};
"3020000".to_string()
}

#[cfg(not(docsrs))]
#[cfg(not(feature = "docsrs"))]
pub fn gdal_version_info(key: &str) -> String {
let c_key = std::ffi::CString::new(key.as_bytes()).unwrap();

Expand Down