-
Notifications
You must be signed in to change notification settings - Fork 224
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
capnpc: add option to build capnp
exe from src
#268
base: master
Are you sure you want to change the base?
Conversation
I like this approach. |
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.
Randomly stumbled upon this PR and realized it has already been two years since the issue!
Very nice to see concrete ideas 🙂
let mut p = PathBuf::from(env!("OUT_DIR")); | ||
p.push("bin"); | ||
p.push("capnp"); | ||
p |
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.
Probably a matter of style, but you could just use:
PathBuf::from(env!("OUT_DIR"))
.join("bin")
.join("capnp")
[build-dependencies] | ||
cmake = "0.1" | ||
which = "4.2" |
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.
cmake
should probably be marked optional, while activated by build-capnp
feature?
[features]
build-capnp = ["dep:cmake"]
[build-dependencies]
cmake = { version = "0.1", optional = true }
which = "4.2"
See also Cargo reference. The dep:
syntax requires Rust 1.60.
if !which::which("capnp").is_ok() { | ||
panic!( | ||
"capnp executable not found. install it with your package manager or enable the \ | ||
\"build-capnp\" feature to build it from source" | ||
); | ||
} |
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.
if !which::which("capnp").is_ok() {
panic!(msg);
}
could be written as:
which::which("capnp").expect(msg);
Related to #182.
This is one potential way we could implement option
2.)
while keeping in mind @zenhack's concern about pushing users away from their package manager. The idea is that we check for the existence ofcapnp
at build time. If it does not exist, we throw an error letting the user know to either install it OR providefeature = "build-capnp"
to the crate so that we can build it for them.I think that it is good to at least provide this option to the user since many may find it desirable to have a plug-and-play solution without the need for prerequisites when building their crate.
You may find adding the
capnproto
submodule undesirable, in which case we could potentially clone the repo at build time.