meson: Support cross-compiling

This commit is contained in:
Shea Levy 2018-02-26 06:33:00 -05:00
parent 4728ef130e
commit 284f75a258
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27
2 changed files with 30 additions and 4 deletions

@ -1,5 +1,7 @@
{ lib, python3Packages }:
python3Packages.buildPythonApplication rec {
{ lib, python3Packages, stdenv, targetPlatform, writeTextDir, m4 }: let
targetPrefix = lib.optionalString stdenv.isCross
(targetPlatform.config + "-");
in python3Packages.buildPythonApplication rec {
version = "0.44.0";
pname = "meson";
name = "${pname}-${version}";
@ -33,6 +35,26 @@ python3Packages.buildPythonApplication rec {
setupHook = ./setup-hook.sh;
crossFile = writeTextDir "cross-file.conf" ''
[binaries]
c = '${targetPrefix}cc'
cpp = '${targetPrefix}c++'
ar = '${targetPrefix}ar'
strip = '${targetPrefix}strip'
pkgconfig = 'pkg-config'
[properties]
needs_exe_wrapper = true
[host_machine]
system = '${targetPlatform.parsed.kernel.name}'
cpu_family = '${targetPlatform.parsed.cpu.family}'
cpu = '${targetPlatform.parsed.cpu.name}'
endian = ${if targetPlatform.isLittleEndian then "'little'" else "'big'"}
'';
inherit (stdenv) cc isCross;
meta = with lib; {
homepage = http://mesonbuild.com;
description = "SCons-like build system that use python as a front-end language and Ninja as a building backend";

@ -6,11 +6,15 @@ mesonConfigurePhase() {
fi
# Build release by default.
mesonFlags="--buildtype=${mesonBuildType:-release} $mesonFlags"
if [ -n "@isCross@" ]; then
crossMesonFlags="--cross-file=@crossFile@/cross-file.conf"
fi
mesonFlags="${crossMesonFlags+$crossMesonFlags }--buildtype=${mesonBuildType:-release} $mesonFlags"
echo "meson flags: $mesonFlags ${mesonFlagsArray[@]}"
meson build $mesonFlags "${mesonFlagsArray[@]}"
CC=@cc@/bin/cc CXX=@cc@/bin/c++ meson build $mesonFlags "${mesonFlagsArray[@]}"
cd build
if ! [[ -v enableParallelBuilding ]]; then