Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 57 lines 1.6 kB view raw
1{ stdenv, lib }: 2 3let 4 inherit (lib) boolToString optionals; 5 6 # See https://mesonbuild.com/Reference-tables.html#cpu-families 7 cpuFamily = 8 platform: 9 with platform; 10 if isAarch32 then 11 "arm" 12 else if isx86_32 then 13 "x86" 14 else if isPower64 then 15 "ppc64" 16 else if isPower then 17 "ppc" 18 else 19 platform.uname.processor; 20 21 crossFile = builtins.toFile "cross-file.conf" '' 22 [properties] 23 bindgen_clang_arguments = ['-target', '${stdenv.targetPlatform.config}'] 24 needs_exe_wrapper = ${boolToString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform)} 25 26 [host_machine] 27 system = '${stdenv.targetPlatform.parsed.kernel.name}' 28 cpu_family = '${cpuFamily stdenv.targetPlatform}' 29 cpu = '${stdenv.targetPlatform.parsed.cpu.name}' 30 endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"} 31 32 [binaries] 33 llvm-config = 'llvm-config-native' 34 rust = ['rustc', '-C', 'target-feature=${ 35 if stdenv.targetPlatform.isStatic then "+" else "-" 36 }crt-static', '--target', '${stdenv.targetPlatform.rust.rustcTargetSpec}'] 37 # Meson refuses to consider any CMake binary during cross compilation if it's 38 # not explicitly specified here, in the cross file. 39 # https://github.com/mesonbuild/meson/blob/0ed78cf6fa6d87c0738f67ae43525e661b50a8a2/mesonbuild/cmake/executor.py#L72 40 cmake = 'cmake' 41 ''; 42 43 crossFlags = optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 44 "--cross-file=${crossFile}" 45 ]; 46 47 makeMesonFlags = 48 { 49 mesonFlags ? [ ], 50 ... 51 }: 52 crossFlags ++ mesonFlags; 53 54in 55{ 56 inherit makeMesonFlags; 57}