Skip to content

Add a way to not use bindgen #499

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

Merged
merged 4 commits into from
Dec 28, 2020
Merged

Add a way to not use bindgen #499

merged 4 commits into from
Dec 28, 2020

Conversation

hug-dev
Copy link
Contributor

@hug-dev hug-dev commented Nov 19, 2020

Fix #489

Add the use-bindgen feature which is activated by default.

If disabled, then the previously generated bindings will be used instead of generating new ones. It will fail compilation if this feature is disabled for the non supported targets.

If enabled, the behaviour is the same as before.

Fix tikv#489

Add the `use-bindgen` feature which is activated by default.

If
disabled, then the previously generated bindings will be used instead of
generating new ones. It will fail compilation if this feature is
disabled for the non supported targets.

If enabled, the behaviour is the same as before.

Signed-off-by: Hugues de Valon <[email protected]>
@hug-dev
Copy link
Contributor Author

hug-dev commented Nov 19, 2020

hmm --no-default-features is used with targets that do not have pregenerated bindings... I can instead make a not-use-bindgen feature and reverse the logic everywhere?

@BusyJay
Copy link
Member

BusyJay commented Nov 20, 2020

How about using rust-lang/cargo#7914 to enable use-bindgen for unsupported targets?

Also fix the CI script for Mac

Signed-off-by: Hugues de Valon <[email protected]>
@hug-dev
Copy link
Contributor Author

hug-dev commented Nov 20, 2020

How about using rust-lang/cargo#7914 to enable use-bindgen for unsupported targets?

That is a good idea but I think the cfg parameters can not filter on the target triple individually... So I don't think I can use that to enable bindgen on every target but Aarch64 and x86 on Linux.

I fixed the Mac CI workflow here by enabling the use-bindgen feature there.

I am aware though that this will break compilation for everyone using this crate with --no-default-features on unsupported platforms.

@BusyJay
Copy link
Member

BusyJay commented Nov 20, 2020

...the cfg parameters can not filter on the target triple individually...

How about:

[target.'cfg(not(all(any(target_arch="x86_64", target_arch="aarch64"), target_os="linux", target_env="gnu")))'.dependencies.grpcio-sys]
path = "grpc-sys"
version = "0.7"
features = ["use-bindgen"]

?

@hug-dev
Copy link
Contributor Author

hug-dev commented Nov 20, 2020

ooh yes I guess that would do it, nice 👌

With the following:

diff --git a/Cargo.toml b/Cargo.toml
index 70b1b39..a02033d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ autoexamples = false
 all-features = true

 [dependencies]
-grpcio-sys = { path = "grpc-sys", version = "0.7", default-features = false }
+grpcio-sys = { path = "grpc-sys", version = "0.7" }
 libc = "0.2"
 futures = "0.3"
 protobuf = { version = "2.0", optional = true }
@@ -30,7 +30,7 @@ parking_lot = "0.11"
 members = ["proto", "benchmark", "compiler", "interop", "tests-and-examples"]

 [features]
-default = ["protobuf-codec", "secure", "use-bindgen"]
+default = ["protobuf-codec", "secure"]
 protobuf-codec = ["protobuf"]
 prost-codec = ["prost", "bytes"]
 secure = ["grpcio-sys/secure"]
@@ -47,3 +47,6 @@ travis-ci = { repository = "tikv/grpc-rs" }

 [patch.crates-io]
 grpcio-compiler = { path = "compiler", version = "0.7.0", default-features = false }
+
+[target.'cfg(not(all(any(target_arch="x86_64", target_arch="aarch64"), target_os="linux", target_env="gnu")))'.dependencies]
+grpcio-sys = { path = "grpc-sys", version = "0.7", features = ["use-bindgen"] }
diff --git a/grpc-sys/Cargo.toml b/grpc-sys/Cargo.toml
index 60e1d2f..c02f7eb 100644
--- a/grpc-sys/Cargo.toml
+++ b/grpc-sys/Cargo.toml
@@ -53,7 +53,6 @@ openssl-sys = { version = "0.9", optional = true, features = ["vendored"] }
 libz-sys = { version = "1.0.25", features = ["static"] }

 [features]
-default = ["use-bindgen"]
 secure = []
 openssl = ["secure"]
 openssl-vendored = ["openssl", "openssl-sys"]

compiling with cargo build -Z features=itarget with nightly rust, the use-bindgen feature is not enabled on my machine (x86 linux gnu). I can enable it adding --features use-bindgen.

I guess that would do it but the main problem I see is that this requires a nightly toolchain to work... For my use-case ideally stable would be used.

BusyJay
BusyJay previously approved these changes Nov 20, 2020
@BusyJay
Copy link
Member

BusyJay commented Nov 20, 2020

Got it. I guess this can only be brought to 0.8.0.

hunterlxt
hunterlxt previously approved these changes Dec 17, 2020
@BusyJay BusyJay dismissed stale reviews from hunterlxt and themself via 8ef2e12 December 28, 2020 11:45
@BusyJay BusyJay merged commit b9ddf27 into tikv:master Dec 28, 2020
@hug-dev
Copy link
Contributor Author

hug-dev commented Jan 18, 2021

Hello @BusyJay !

Do you know when 0.8.0 is planned to be released? We would be happy to use the change of this PR 😃

@hug-dev
Copy link
Contributor Author

hug-dev commented Feb 1, 2021

Hello @BusyJay

Kindly pinging you again to know about plans for a next release 👌

@BusyJay
Copy link
Member

BusyJay commented Feb 2, 2021

Hi, @hug-dev, we are working on #506, when it's merged we may release next version.

@hug-dev
Copy link
Contributor Author

hug-dev commented Feb 2, 2021

Excellent! Sorry for the spam 😋

@hug-dev hug-dev deleted the no-bindgen branch February 2, 2021 11:21
@hug-dev
Copy link
Contributor Author

hug-dev commented Feb 25, 2021

Thanks for the release 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature to conditionally include bindgen dependency
3 participants