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

capnpc: add option to build capnp exe from src #268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rileylyman
Copy link

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 of capnp at build time. If it does not exist, we throw an error letting the user know to either install it OR provide feature = "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.

@zenhack
Copy link

zenhack commented May 15, 2022

I like this approach.

Copy link
Contributor

@Bromeon Bromeon left a 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 🙂

Comment on lines +71 to +74
let mut p = PathBuf::from(env!("OUT_DIR"));
p.push("bin");
p.push("capnp");
p
Copy link
Contributor

@Bromeon Bromeon May 24, 2022

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")

Comment on lines +44 to +46
[build-dependencies]
cmake = "0.1"
which = "4.2"
Copy link
Contributor

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.

Comment on lines +8 to +13
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"
);
}
Copy link
Contributor

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);

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.

None yet

3 participants