Open HappySeaFox opened 2 years ago
Can you provide more build documentation for cargo?
As per the docs https://github.com/rust-lang/cargo, cargo
has a recursive build dependency on itself :) Yes, one needs cargo
installed to build cargo
from sources. I think installing a pre-compiled binary package is the only way to go to install it from scratch.
The pre-compiled package is available for different platforms and compilers. It also allows unattended install with specifying CLI options. Custom installation path can be set with environment variables, see https://github.com/rust-lang/rustup/issues/618#issuecomment-236252290
@HappySeaFox The last question is: are there other libraries that can be compiled with cargo?
That's a good question. I haven't done any research as resvg is the only Rust lib I need. However, to support cargo
, I can say that making C api for a Rust library is rather easy. I mean it's possible to patch a Rust-only library and add it in vcpkg
rather easily.
This would be neat. I have an odd use case for this which I don't think I'd try to upstream, but it could be a nice hack for our overlay. In Mixxx we use sccache, which is a Rust program, for complier caching on Windows with MSVC. It would be nice if vcpkg could automatically install this as a build tool along with the libraries the application uses.
FWIW there is a Rust crate to do the opposite and integrate vcpkg into Cargo.
Rust libraries are can be easily converted to FFI compatible libraries, for example, crypto-crawler-ffi.
If vcpkg supports building cargo projects out-of-box, many rust libraries can be imported to vcpkg.io.
It looks like rustup doesn't provide a full tarball, but uses the built-in management tools to install and manage its dependencies.
So we can't easily add it as a tool, we can only follow vcpkg_acquire_msys
.
I think the question here might not be getting rustup
ported to or integrated into vcpkg, since it's a installer that helps users to download and manage pre-built binaries of the Rust toolchain - such as rustc
(Rust compiler), rust-std
(Rust standard lib) and cargo
(a package manager and also a build tool). In my opinion these binaries or the Rust toolchain should be installed by the user, just as they need to install MSVC or GCC C/C++ compiler to use vcpkg.
Although it seems that cargo
can be optional, most of the time it's highly tied to Rust projects. So as far as I can see, to support Rust-based libraries, we might need to support cargo in vcpkg. Or maybe these Rust crates which provide C/C++ libraries are somehow different and not relying on cargo so much that we can develop/find something equivalent? It would be nice if someone familiar with Rust can tell me 😃.
And since I'm not quite familiar with vcpkg and how it works now (I saw discussion in #15441 but still not quite clear), I have no idea how Rust support can be added to vcpkg, or how possible/difficult it can be. What I know is that most C/C++ projects uses CMake or Makefile to manage the build, while Rust projects use cargo
with Cargo.toml which defines the build.
Anyway I believe it would be nice if some Rust libraries can be brought onto vcpkg, like besides the resvg
mentioned above, the quiche
project can also be helpful for enabling HTTP/3 support for curl (#32109). 😇
Looking at how Debian packages librsvg (no resvg):
It has meson, cargo and cargo-c preinstalled. But:
The usually small set of Debian changes on top of the orig tarball has all the stuff which is required via Cargo.
https://sources.debian.org/src/librsvg/2.58.0%2Bdfsg-1/debian/README.source/
This adds 29 MB "changes" to a 7.7 MB "orig" tarball.
https://snapshot.debian.org/package/librsvg/2.58.0%2Bdfsg-1/
And it contributes a lengthy section to the copyright
file:
https://tracker.debian.org/media/packages/libr/librsvg/copyright-2.58.0dfsg-1
(TLDNR: Apache-2.0, and BSD-2-clause, and BSD-3-clause, and Expat, and Apache-2.0 or Expat or 0BSD, and Apache-2.0 or Boost-1.0, and Apache-2.0 or Expat, and Expat or Unlicense, and MPL-2.0, and Sun-permissive, and zlib
)
Is your feature request related to a problem? Please describe.
Some Rust libraries can be built with
cargo
tool into aC
library with dll+lib files. For example,resvg
. It would be great to enablevcpkg
to build such libraries.For example: to compile
resvg
C binding:rustup-init.exe
from https://www.rust-lang.org/tools/installresvg
:This creates
resvg.dll
andresvg.dll.lib
.Proposed solution Add
cargo
as build tool.Describe alternatives you've considered -
Additional context -