meson: Support cross-compiling
This commit is contained in:
parent
4728ef130e
commit
284f75a258
@ -1,5 +1,7 @@
|
|||||||
{ lib, python3Packages }:
|
{ lib, python3Packages, stdenv, targetPlatform, writeTextDir, m4 }: let
|
||||||
python3Packages.buildPythonApplication rec {
|
targetPrefix = lib.optionalString stdenv.isCross
|
||||||
|
(targetPlatform.config + "-");
|
||||||
|
in python3Packages.buildPythonApplication rec {
|
||||||
version = "0.44.0";
|
version = "0.44.0";
|
||||||
pname = "meson";
|
pname = "meson";
|
||||||
name = "${pname}-${version}";
|
name = "${pname}-${version}";
|
||||||
@ -33,6 +35,26 @@ python3Packages.buildPythonApplication rec {
|
|||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
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; {
|
meta = with lib; {
|
||||||
homepage = http://mesonbuild.com;
|
homepage = http://mesonbuild.com;
|
||||||
description = "SCons-like build system that use python as a front-end language and Ninja as a building backend";
|
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
|
fi
|
||||||
|
|
||||||
# Build release by default.
|
# 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[@]}"
|
echo "meson flags: $mesonFlags ${mesonFlagsArray[@]}"
|
||||||
|
|
||||||
meson build $mesonFlags "${mesonFlagsArray[@]}"
|
CC=@cc@/bin/cc CXX=@cc@/bin/c++ meson build $mesonFlags "${mesonFlagsArray[@]}"
|
||||||
cd build
|
cd build
|
||||||
|
|
||||||
if ! [[ -v enableParallelBuilding ]]; then
|
if ! [[ -v enableParallelBuilding ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user