2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv
|
2021-01-09 10:05:03 +00:00
|
|
|
, fetchFromGitHub
|
2020-04-24 23:36:52 +00:00
|
|
|
, bison
|
|
|
|
, cmake
|
|
|
|
, jq
|
|
|
|
, python3
|
|
|
|
, spirv-headers
|
|
|
|
, spirv-tools
|
2020-10-16 20:44:37 +00:00
|
|
|
, argSpirv-tools ? null
|
|
|
|
, argSpirv-headers ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
2020-10-16 20:44:37 +00:00
|
|
|
# glslang requires custom versions of spirv-tools and spirb-headers.
|
|
|
|
# The exact versions are taken from:
|
2021-01-09 10:05:03 +00:00
|
|
|
# https://github.com/KhronosGroup/glslang/blob/${version}/known_good.json
|
2020-10-16 20:44:37 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
localSpirv-tools = if argSpirv-tools == null
|
|
|
|
then spirv-tools.overrideAttrs (_: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "SPIRV-Tools";
|
2021-01-09 10:05:03 +00:00
|
|
|
rev = "b27b1afd12d05bf238ac7368bb49de73cd620a8e";
|
|
|
|
sha256 = "0v26ws6qx23jn4dcpsq6rqmdxgyxpl5pcvfm90wb3nz6iqbqx294";
|
2020-10-16 20:44:37 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
else argSpirv-tools;
|
|
|
|
|
|
|
|
localSpirv-headers = if argSpirv-headers == null
|
|
|
|
then spirv-headers.overrideAttrs (_: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "SPIRV-Headers";
|
2021-01-09 10:05:03 +00:00
|
|
|
rev = "f027d53ded7e230e008d37c8b47ede7cd308e19d";
|
|
|
|
sha256 = "12gp2mqcar6jj57jw9isfr62yn72kmvdcl0zga4gvrlyfhnf582q";
|
2020-10-16 20:44:37 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
else argSpirv-headers;
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "glslang";
|
2021-01-09 10:05:03 +00:00
|
|
|
version = "11.1.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "glslang";
|
|
|
|
rev = version;
|
2021-01-09 10:05:03 +00:00
|
|
|
sha256 = "1j81pghy7whyr8ygk7lx6g6qph61rky7fkkc8xp87c7n695a48rw";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# These get set at all-packages, keep onto them for child drvs
|
|
|
|
passthru = {
|
2020-10-16 20:44:37 +00:00
|
|
|
spirv-tools = localSpirv-tools;
|
|
|
|
spirv-headers = localSpirv-headers;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake python3 bison jq ];
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-10-16 20:44:37 +00:00
|
|
|
cp --no-preserve=mode -r "${localSpirv-tools.src}" External/spirv-tools
|
|
|
|
ln -s "${localSpirv-headers.src}" External/spirv-tools/external/spirv-headers
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Ensure spirv-headers and spirv-tools match exactly to what is expected
|
|
|
|
preConfigure = ''
|
|
|
|
HEADERS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools/external/spirv-headers"))[0].commit')
|
|
|
|
TOOLS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools"))[0].commit')
|
2020-10-16 20:44:37 +00:00
|
|
|
if [ "$HEADERS_COMMIT" != "${localSpirv-headers.src.rev}" ] || [ "$TOOLS_COMMIT" != "${localSpirv-tools.src.rev}" ]; then
|
2020-04-24 23:36:52 +00:00
|
|
|
echo "ERROR: spirv-tools commits do not match expected versions: expected tools at $TOOLS_COMMIT, headers at $HEADERS_COMMIT";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit (src.meta) homepage;
|
|
|
|
description = "Khronos reference front-end for GLSL and ESSL";
|
|
|
|
license = licenses.asl20;
|
2021-01-09 10:05:03 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = [ maintainers.ralith ];
|
|
|
|
};
|
|
|
|
}
|