Skip to content

Building crates that work only on some platforms #141

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

Closed
Boddlnagg opened this issue Jul 20, 2017 · 8 comments
Closed

Building crates that work only on some platforms #141

Boddlnagg opened this issue Jul 20, 2017 · 8 comments

Comments

@Boddlnagg
Copy link

Boddlnagg commented Jul 20, 2017

Crates such as https://docs.rs/crate/core-foundation/0.4.1/builds fail to build on platforms other than macOS. In this case, it fails with error: native frameworks are only available on macOS targets, but the crate would build correctly on macOS targets ... docs.rs doesn't seem to even try to build on macOS, however, after this error.

Could it be changed in such a way that docs.rs tries to build on all platforms and later only show the subset of platforms where it succeeded to build?

@onur
Copy link
Member

onur commented Jul 20, 2017

This is a known limitation of docs.rs.

Docs.rs is only using a Linux host machine right now. I can implement building on OSX if someone donates an OSX server.

@Boddlnagg
Copy link
Author

Boddlnagg commented Jul 20, 2017

Huh? But I changed coremidi-sys in such a way that it would be cfg'ed out if the target is not macOS, so it would not result in the linking error, but instead just build an empty crate. This worked, I can see the documentation for macOS: https://docs.rs/coremidi-sys/2.0.2/x86_64-apple-darwin/coremidi_sys/. (Note that it did not work before the change: https://docs.rs/crate/coremidi-sys/2.0.0/builds)

So this means that somehow building for macOS target does work, and docs.rs should do that even if the build for other targets fails.

@onur
Copy link
Member

onur commented Jul 20, 2017

Ahh I see, I thought OSX targeted crates requires an OSX host machine, but looks like they are like winapi crates and rust-std for OSX is enough to build this type of crates.

Yes, I agree docs.rs should try to build crates for all targets and decide default-target itself. This is a neat idea and thanks for suggestion. I'll see what I can do.

@Boddlnagg
Copy link
Author

Thanks, that sounds great! 👍

@jrmuizel
Copy link

I've run into this as well. What would be the best way to implement this?

@quadrupleslap
Copy link

quadrupleslap commented Feb 8, 2018

Can I do anything to help get this implemented? I haven't looked too closely, but it looks like src/docbuilder/chroot_builder.rs is the only file that needs to be changed.

Edit

I skimmed over the source, and it looks like there's a 'main' build in the way Docs.rs is implemented, and right now that build is the one for the current platform. It looks like the two ways to address this issue would be to:

  1. Modify build_package_in_chroot to use the default-target from the metadata if it is provided, so that the user gets to choose which platform this 'main' build happens on. This looks easy to implement, and should be enough.
  2. Get rid of the idea of a 'main' build, and just build it on all supported platforms, saying that there was a build error only if it failed on all platforms. Also, try to guess the default-target by looking at which platforms succeeded. This looks harder to implement, but I guess this is the more 'elegant' solution.

I think makes sense to implement (1) and then later implement (2).

Sorry if I said anything obviously stupid.

@jyn514
Copy link
Member

jyn514 commented Dec 21, 2019

I'm actually hoping to go the other way and only build one target unless requested otherwise, see #532.

Would setting default-target to x86_64-apple-darwin fix your problem? We no longer ignore this field, winapi for example uses it since their builds only work on Windows.

@jrmuizel
Copy link

Yes. I think that should work.

@jyn514 jyn514 closed this as completed Dec 22, 2019
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

No branches or pull requests

5 participants