2021-04-20 09:17:53 +02:00
|
|
|
{ lib
|
2022-11-10 15:11:48 +01:00
|
|
|
, stdenv
|
2021-04-20 09:17:53 +02:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, simdExtensions ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
with rec {
|
|
|
|
# SIMD instruction sets to compile for. If none are specified by the user,
|
|
|
|
# an appropriate one is selected based on the detected host system
|
2022-11-10 15:11:48 +01:00
|
|
|
isas = with stdenv.hostPlatform;
|
2021-04-20 09:17:53 +02:00
|
|
|
if simdExtensions != null then lib.toList simdExtensions
|
|
|
|
else if avx2Support then [ "AVX2" ]
|
|
|
|
else if sse4_1Support then [ "SSE41" ]
|
|
|
|
else if isx86_64 then [ "SSE2" ]
|
|
|
|
else if isAarch64 then [ "NEON" ]
|
|
|
|
else [ "NONE" ];
|
|
|
|
|
|
|
|
# CMake Build flags for the selected ISAs. For a list of flags, see
|
|
|
|
# https://github.com/ARM-software/astc-encoder/blob/main/Docs/Building.md
|
2023-07-04 09:58:48 +02:00
|
|
|
isaFlags = map ( isa: "-DASTCENC_ISA_${isa}=ON" ) isas;
|
2021-04-20 09:17:53 +02:00
|
|
|
|
|
|
|
# The suffix of the binary to link as 'astcenc'
|
|
|
|
mainBinary = builtins.replaceStrings
|
2022-11-10 15:11:48 +01:00
|
|
|
[ "AVX2" "SSE41" "SSE2" "NEON" "NONE" "NATIVE" ]
|
|
|
|
[ "avx2" "sse4.1" "sse2" "neon" "none" "native" ]
|
2021-04-20 09:17:53 +02:00
|
|
|
( builtins.head isas );
|
|
|
|
};
|
|
|
|
|
2022-11-10 15:11:48 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2021-04-20 09:17:53 +02:00
|
|
|
pname = "astc-encoder";
|
2023-12-05 18:37:47 +01:00
|
|
|
version = "4.6.1";
|
2021-04-20 09:17:53 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ARM-software";
|
|
|
|
repo = "astc-encoder";
|
|
|
|
rev = version;
|
2023-12-05 18:37:47 +01:00
|
|
|
sha256 = "sha256-7/GBzqgXh8sU3Pl30eH9Mi24PPIqayQqNuhkMnn5Lq0=";
|
2021-04-20 09:17:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
2023-07-23 23:45:18 +02:00
|
|
|
cmakeBuildType = "RelWithDebInfo";
|
|
|
|
|
2023-07-04 09:58:48 +02:00
|
|
|
cmakeFlags = isaFlags ++ [
|
|
|
|
"-DASTCENC_UNIVERSAL_BUILD=OFF"
|
2021-04-20 09:17:53 +02:00
|
|
|
];
|
|
|
|
|
2022-03-09 12:33:10 +01:00
|
|
|
# Set a fixed build year to display within help output (otherwise, it would be 1980)
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Source/cmake_core.cmake \
|
2023-07-04 09:58:48 +02:00
|
|
|
--replace 'string(TIMESTAMP astcencoder_YEAR "%Y")' 'set(astcencoder_YEAR "2023")'
|
2022-03-09 12:33:10 +01:00
|
|
|
'';
|
|
|
|
|
2022-11-10 15:11:48 +01:00
|
|
|
# Provide 'astcenc' link to main executable
|
2021-04-20 09:17:53 +02:00
|
|
|
postInstall = ''
|
|
|
|
ln -s $out/bin/astcenc-${mainBinary} $out/bin/astcenc
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/ARM-software/astc-encoder";
|
|
|
|
description = "An encoder for the ASTC texture compression format";
|
|
|
|
longDescription = ''
|
|
|
|
The Adaptive Scalable Texture Compression (ASTC) format is
|
|
|
|
widely supported by mobile and desktop graphics hardware and
|
|
|
|
provides better quality at a given bitrate compared to ETC2.
|
|
|
|
|
|
|
|
This program supports both compression and decompression in LDR
|
|
|
|
and HDR mode and can read various image formats. Run `astcenc
|
|
|
|
-help` to see all the options.
|
|
|
|
'';
|
|
|
|
platforms = platforms.unix;
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ dasisdormax ];
|
2022-11-10 15:11:48 +01:00
|
|
|
broken = !stdenv.is64bit;
|
2021-04-20 09:17:53 +02:00
|
|
|
};
|
|
|
|
}
|