2022-10-21 18:38:19 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, python3, autoSignDarwinBinariesHook, cctools }:
|
2020-04-24 23:36:52 +00:00
|
|
|
# Like many google projects, shaderc doesn't gracefully support separately compiled dependencies, so we can't easily use
|
|
|
|
# the versions of glslang and spirv-tools used by vulkan-loader. Exact revisions are taken from
|
|
|
|
# https://github.com/google/shaderc/blob/known-good/known_good.json
|
|
|
|
|
|
|
|
# Future work: extract and fetch all revisions automatically based on a revision of shaderc's known-good branch.
|
|
|
|
let
|
|
|
|
glslang = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "glslang";
|
2024-01-25 14:12:00 +00:00
|
|
|
rev = "a91631b260cba3f22858d6c6827511e636c2458a";
|
|
|
|
hash = "sha256-7kIIU45pe+IF7lGltpIKSvQBmcXR+TWFvmx7ztMNrpc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
spirv-tools = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "SPIRV-Tools";
|
2024-01-25 14:12:00 +00:00
|
|
|
rev = "f0cc85efdbbe3a46eae90e0f915dc1509836d0fc";
|
|
|
|
hash = "sha256-RzGvoDt1Qc+f6mZsfs99MxX4YB3yFc5FP92Yx/WGrsI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
spirv-headers = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "SPIRV-Headers";
|
2024-01-25 14:12:00 +00:00
|
|
|
rev = "1c6bb2743599e6eb6f37b2969acc0aef812e32e3";
|
|
|
|
hash = "sha256-/I9dJlBE0kvFvqooKuqMETtOE72Jmva3zIGnq0o4+aE=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "shaderc";
|
2024-01-25 14:12:00 +00:00
|
|
|
version = "2023.8";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "lib" "bin" "dev" "static" ];
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "google";
|
|
|
|
repo = "shaderc";
|
|
|
|
rev = "v${version}";
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-c8mJ361DY2VlSFZ4/RCrV+nqB9HblbOdfMkI4cM1QzM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
cp -r --no-preserve=mode ${glslang} third_party/glslang
|
|
|
|
cp -r --no-preserve=mode ${spirv-tools} third_party/spirv-tools
|
|
|
|
ln -s ${spirv-headers} third_party/spirv-tools/external/spirv-headers
|
2024-01-25 14:12:00 +00:00
|
|
|
patchShebangs --build utils/
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
nativeBuildInputs = [ cmake python3 ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ cctools ]
|
|
|
|
++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
moveToOutput "lib/*.a" $static
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = [ "-DSHADERC_SKIP_TESTS=ON" ];
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
# Fix the paths in .pc, even though it's unclear if all these .pc are really useful.
|
|
|
|
postFixup = ''
|
|
|
|
substituteInPlace "$dev"/lib/pkgconfig/*.pc \
|
|
|
|
--replace '=''${prefix}//' '=/' \
|
|
|
|
--replace "$dev/$dev/" "$dev/"
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit (src.meta) homepage;
|
2020-10-19 00:13:06 +00:00
|
|
|
description = "A collection of tools, libraries and tests for shader compilation";
|
2021-12-06 16:07:01 +00:00
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = [ licenses.asl20 ];
|
|
|
|
};
|
|
|
|
}
|