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

Add cargo-c and a C-API for rav1e #91050

Merged
merged 2 commits into from Aug 11, 2020
Merged

Add cargo-c and a C-API for rav1e #91050

merged 2 commits into from Aug 11, 2020

Conversation

primeos
Copy link
Member

@primeos primeos commented Jun 18, 2020

Motivation for this change

After #90541 this should make it possible to enable AV1 encoding support via librav1e in FFmpeg.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

This crate is required for building the C-API for rav1e [0] but is also
used by other projects [1].

[0]: https://github.com/xiph/rav1e#building-the-c-api
[1]: https://github.com/lu-zero/cargo-c/#users
Copy link
Member Author

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things that could be improved

Comment on lines +18 to +24
postBuild = ''
cargo cbuild --release --frozen --prefix=${placeholder "out"}
'';

postInstall = ''
cargo cinstall --release --frozen --prefix=${placeholder "out"}
'';
Copy link
Member Author

@primeos primeos Jun 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to have this as a hook from cargo-c but I don't think we have an extensible abstraction for this yet (though I'm not familiar with our Rust abstractions).

Also: I guess this breaks cross-compilation (if it did work before).

Comment on lines +9 to +28
src = stdenv.mkDerivation rec {
name = "${pname}-source-${version}";

src = fetchFromGitHub {
owner = "lu-zero";
repo = pname;
rev = "v${version}";
sha256 = "0n52xh4qg12bvvp2dgx5wfj5f31qijdqahasa3qfa3c3aqq7cvvg";
};
cargoLock = fetchurl {
url = "https://github.com/lu-zero/${pname}/releases/download/v${version}/Cargo.lock";
sha256 = "0296187hsaxxmqhsrrva4qf313jwh3z08j1vxcbislxdq8xg32qb";
};

installPhase = ''
mkdir -p $out
cp -R ./* $out/
cp ${cargoLock} $out/Cargo.lock
'';
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add an abstraction for this? Ideally buildRustPackage should support adding the Cargo.lock file before fetching the crates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@primeos
Copy link
Member Author

primeos commented Aug 11, 2020

Unfortunately this isn't that pretty but let's try it out and hopefully clean it up later. I successfully tested it with ffmpeg-full.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants