at 24.05-pre 77 lines 2.4 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, cmake 5, simdExtensions ? null 6}: 7 8with rec { 9 # SIMD instruction sets to compile for. If none are specified by the user, 10 # an appropriate one is selected based on the detected host system 11 isas = with stdenv.hostPlatform; 12 if simdExtensions != null then lib.toList simdExtensions 13 else if avx2Support then [ "AVX2" ] 14 else if sse4_1Support then [ "SSE41" ] 15 else if isx86_64 then [ "SSE2" ] 16 else if isAarch64 then [ "NEON" ] 17 else [ "NONE" ]; 18 19 # CMake Build flags for the selected ISAs. For a list of flags, see 20 # https://github.com/ARM-software/astc-encoder/blob/main/Docs/Building.md 21 isaFlags = map ( isa: "-DASTCENC_ISA_${isa}=ON" ) isas; 22 23 # The suffix of the binary to link as 'astcenc' 24 mainBinary = builtins.replaceStrings 25 [ "AVX2" "SSE41" "SSE2" "NEON" "NONE" "NATIVE" ] 26 [ "avx2" "sse4.1" "sse2" "neon" "none" "native" ] 27 ( builtins.head isas ); 28}; 29 30stdenv.mkDerivation rec { 31 pname = "astc-encoder"; 32 version = "4.6.0"; 33 34 src = fetchFromGitHub { 35 owner = "ARM-software"; 36 repo = "astc-encoder"; 37 rev = version; 38 sha256 = "sha256-COZO4LTrM/kZp85uNGwB9eaF27Xf7NVg4hcshaCJBwI="; 39 }; 40 41 nativeBuildInputs = [ cmake ]; 42 43 cmakeBuildType = "RelWithDebInfo"; 44 45 cmakeFlags = isaFlags ++ [ 46 "-DASTCENC_UNIVERSAL_BUILD=OFF" 47 ]; 48 49 # Set a fixed build year to display within help output (otherwise, it would be 1980) 50 postPatch = '' 51 substituteInPlace Source/cmake_core.cmake \ 52 --replace 'string(TIMESTAMP astcencoder_YEAR "%Y")' 'set(astcencoder_YEAR "2023")' 53 ''; 54 55 # Provide 'astcenc' link to main executable 56 postInstall = '' 57 ln -s $out/bin/astcenc-${mainBinary} $out/bin/astcenc 58 ''; 59 60 meta = with lib; { 61 homepage = "https://github.com/ARM-software/astc-encoder"; 62 description = "An encoder for the ASTC texture compression format"; 63 longDescription = '' 64 The Adaptive Scalable Texture Compression (ASTC) format is 65 widely supported by mobile and desktop graphics hardware and 66 provides better quality at a given bitrate compared to ETC2. 67 68 This program supports both compression and decompression in LDR 69 and HDR mode and can read various image formats. Run `astcenc 70 -help` to see all the options. 71 ''; 72 platforms = platforms.unix; 73 license = licenses.asl20; 74 maintainers = with maintainers; [ dasisdormax ]; 75 broken = !stdenv.is64bit; 76 }; 77}