1{
2 lib,
3 rustPlatform,
4 fetchCrate,
5 pkg-config,
6 curl,
7 openssl,
8 stdenv,
9 libiconv,
10 rav1e,
11}:
12
13rustPlatform.buildRustPackage rec {
14 pname = "cargo-c";
15 version = "0.10.2";
16
17 src = fetchCrate {
18 inherit pname;
19 # this version may need to be updated along with package version
20 version = "${version}+cargo-0.80.0";
21 hash = "sha256-ltxd4n3oo8ZF/G/zmR4FSVtNOkxwCjDv6PdxkmWxZ+8=";
22 };
23
24 cargoHash = "sha256-tCJ7Giyj7Wqowhk0N7CkvAiWvF6DBNw7G7aAnn2+mp8=";
25
26 nativeBuildInputs = [
27 pkg-config
28 (lib.getDev curl)
29 ];
30 buildInputs = [
31 openssl
32 curl
33 ]
34 ++ lib.optionals stdenv.hostPlatform.isDarwin [
35 libiconv
36 ];
37
38 # Ensure that we are avoiding build of the curl vendored in curl-sys
39 doInstallCheck = stdenv.hostPlatform.libc == "glibc";
40 installCheckPhase = ''
41 runHook preInstallCheck
42
43 ldd "$out/bin/cargo-cbuild" | grep libcurl.so
44
45 runHook postInstallCheck
46 '';
47
48 passthru.tests = {
49 inherit rav1e;
50 };
51
52 meta = {
53 description = "Cargo subcommand to build and install C-ABI compatible dynamic and static libraries";
54 longDescription = ''
55 Cargo C-ABI helpers. A cargo applet that produces and installs a correct
56 pkg-config file, a static library and a dynamic library, and a C header
57 to be used by any C (and C-compatible) software.
58 '';
59 homepage = "https://github.com/lu-zero/cargo-c";
60 changelog = "https://github.com/lu-zero/cargo-c/releases/tag/v${version}";
61 license = lib.licenses.mit;
62 maintainers = with lib.maintainers; [
63 cpu
64 matthiasbeyer
65 ];
66 };
67}