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