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