nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 86 lines 2.6 kB view raw
1# Static arguments 2{ 3 lib, 4 runCommandCC, 5 cmake, 6}: 7 8# Tester arguments 9{ 10 package, 11 moduleNames, 12 # Extra nativeBuildInputs needed to pass the cmake find_package test, e.g. pkg-config. 13 nativeBuildInputs ? [ ], 14 # buildInputs is used to help pass the cmake find_package test. 15 # The purpose of buildInputs here is to allow us to iteratively add 16 # any missing dependencies required by the *Config.cmake module 17 # during testing. This allows us to test and fix the CMake setup 18 # without rebuilding the finalPackage each time. Once all required 19 # packages are properly added to the finalPackage's propagateBuildInputs, 20 # this buildInputs should be set to an empty list []. 21 buildInputs ? [ ], 22 # Extra cmakeFlags needed to pass the cmake find_package test. 23 # Can be used to set verbose/debug flags. 24 cmakeFlags ? [ ], 25 testName ? "check-cmake-config-${package.pname or package.name}", 26 version ? package.version or null, 27 versionCheck ? false, 28}: 29 30runCommandCC testName 31 { 32 inherit moduleNames versionCheck cmakeFlags; 33 version = if versionCheck then version else null; 34 nativeBuildInputs = [ 35 cmake 36 ] 37 ++ nativeBuildInputs; 38 buildInputs = [ package ] ++ buildInputs; 39 meta = { 40 description = "Test whether ${package.name} exposes cmake-config modules ${lib.concatStringsSep ", " moduleNames}"; 41 } 42 # Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org, 43 # as hydra can't check this meta info in dependencies. 44 # The test itself is just Nixpkgs, with MIT license. 45 // builtins.intersectAttrs { 46 available = throw "unused"; 47 broken = throw "unused"; 48 insecure = throw "unused"; 49 license = throw "unused"; 50 maintainers = throw "unused"; 51 teams = throw "unused"; 52 platforms = throw "unused"; 53 unfree = throw "unused"; 54 unsupported = throw "unused"; 55 } package.meta; 56 } 57 '' 58 touch "$out" 59 notFound=0 60 for moduleName in $moduleNames; do 61 echo "checking cmake-config module $moduleName" 62 63 cat <<EOF > CMakeLists.txt 64 cmake_minimum_required(VERSION 3.14) 65 project(CheckCmakeModule) 66 67 find_package($moduleName $version EXACT NO_MODULE REQUIRED) 68 EOF 69 70 echoCmd 'cmake flags' $cmakeFlags 71 set +e 72 cmake . $cmakeFlags 73 r=$? 74 set -e 75 if [[ $r = 0 ]]; then 76 echo " cmake-config module $moduleName exists" 77 else 78 echo " cmake-config module $moduleName was not found" 79 ((notFound+=1)) 80 fi 81 done 82 83 if [[ $notFound -ne 0 ]]; then 84 exit 1 85 fi 86 ''