meson: Make target-agnostic
The cross file is added in the `mkDerivation`. It isn't nice putting build tool-specific stuff here, but our current architecture gives us little alternative.
This commit is contained in:
parent
128b93e061
commit
8245230753
@ -3,20 +3,8 @@
|
|||||||
, stdenv
|
, stdenv
|
||||||
, writeTextDir
|
, writeTextDir
|
||||||
, substituteAll
|
, substituteAll
|
||||||
, targetPackages
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
|
||||||
# See https://mesonbuild.com/Reference-tables.html#cpu-families
|
|
||||||
cpuFamilies = {
|
|
||||||
aarch64 = "aarch64";
|
|
||||||
armv5tel = "arm";
|
|
||||||
armv6l = "arm";
|
|
||||||
armv7l = "arm";
|
|
||||||
i686 = "x86";
|
|
||||||
x86_64 = "x86_64";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
python3Packages.buildPythonApplication rec {
|
python3Packages.buildPythonApplication rec {
|
||||||
pname = "meson";
|
pname = "meson";
|
||||||
version = "0.54.0";
|
version = "0.54.0";
|
||||||
@ -70,27 +58,11 @@ python3Packages.buildPythonApplication rec {
|
|||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = ./setup-hook.sh;
|
||||||
|
|
||||||
crossFile = writeTextDir "cross-file.conf" ''
|
|
||||||
[binaries]
|
|
||||||
pkgconfig = 'pkg-config'
|
|
||||||
|
|
||||||
[properties]
|
|
||||||
needs_exe_wrapper = true
|
|
||||||
|
|
||||||
[host_machine]
|
|
||||||
system = '${targetPackages.stdenv.targetPlatform.parsed.kernel.name}'
|
|
||||||
cpu_family = '${cpuFamilies.${targetPackages.stdenv.targetPlatform.parsed.cpu.name}}'
|
|
||||||
cpu = '${targetPackages.stdenv.targetPlatform.parsed.cpu.name}'
|
|
||||||
endian = ${if targetPackages.stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
|
|
||||||
'';
|
|
||||||
|
|
||||||
# 0.45 update enabled tests but they are failing
|
# 0.45 update enabled tests but they are failing
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
# checkInputs = [ ninja pkgconfig ];
|
# checkInputs = [ ninja pkgconfig ];
|
||||||
# checkPhase = "python ./run_project_tests.py";
|
# checkPhase = "python ./run_project_tests.py";
|
||||||
|
|
||||||
isCross = stdenv.targetPlatform != stdenv.hostPlatform;
|
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://mesonbuild.com";
|
homepage = "https://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";
|
||||||
|
@ -5,11 +5,6 @@ mesonConfigurePhase() {
|
|||||||
mesonFlags="--prefix=$prefix $mesonFlags"
|
mesonFlags="--prefix=$prefix $mesonFlags"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build release by default.
|
|
||||||
if [ -n "@isCross@" ]; then
|
|
||||||
crossMesonFlags="--cross-file=@crossFile@/cross-file.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# See multiple-outputs.sh and meson’s coredata.py
|
# See multiple-outputs.sh and meson’s coredata.py
|
||||||
mesonFlags="\
|
mesonFlags="\
|
||||||
--libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \
|
--libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \
|
||||||
|
@ -49,6 +49,7 @@ in rec {
|
|||||||
# Configure Phase
|
# Configure Phase
|
||||||
, configureFlags ? []
|
, configureFlags ? []
|
||||||
, cmakeFlags ? []
|
, cmakeFlags ? []
|
||||||
|
, mesonFlags ? []
|
||||||
, # Target is not included by default because most programs don't care.
|
, # Target is not included by default because most programs don't care.
|
||||||
# Including it then would cause needless mass rebuilds.
|
# Including it then would cause needless mass rebuilds.
|
||||||
#
|
#
|
||||||
@ -252,6 +253,34 @@ in rec {
|
|||||||
++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}"
|
++ lib.optional (stdenv.buildPlatform.uname.system != null) "-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}"
|
||||||
++ lib.optional (stdenv.buildPlatform.uname.processor != null) "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}"
|
++ lib.optional (stdenv.buildPlatform.uname.processor != null) "-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}"
|
||||||
++ lib.optional (stdenv.buildPlatform.uname.release != null) "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}";
|
++ lib.optional (stdenv.buildPlatform.uname.release != null) "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}";
|
||||||
|
|
||||||
|
mesonFlags = if mesonFlags == null then null else let
|
||||||
|
# See https://mesonbuild.com/Reference-tables.html#cpu-families
|
||||||
|
cpuFamilies = {
|
||||||
|
aarch64 = "aarch64";
|
||||||
|
armv5tel = "arm";
|
||||||
|
armv6l = "arm";
|
||||||
|
armv7l = "arm";
|
||||||
|
i686 = "x86";
|
||||||
|
x86_64 = "x86_64";
|
||||||
|
};
|
||||||
|
crossFile = builtins.toFile "cross-file.conf" (''
|
||||||
|
[properties]
|
||||||
|
needs_exe_wrapper = true
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
system = '${stdenv.targetPlatform.parsed.kernel.name}'
|
||||||
|
cpu_family = '${cpuFamilies.${stdenv.targetPlatform.parsed.cpu.name}}'
|
||||||
|
cpu = '${stdenv.targetPlatform.parsed.cpu.name}'
|
||||||
|
endian = ${if stdenv.targetPlatform.isLittleEndian then "'little'" else "'big'"}
|
||||||
|
''
|
||||||
|
# TODO should have target prefix too, issue #86077
|
||||||
|
+ ''
|
||||||
|
|
||||||
|
[binaries]
|
||||||
|
pkgconfig = 'pkg-config'
|
||||||
|
'');
|
||||||
|
in [ "--cross-file=${crossFile}" ] ++ mesonFlags;
|
||||||
} // lib.optionalAttrs (attrs.enableParallelBuilding or false) {
|
} // lib.optionalAttrs (attrs.enableParallelBuilding or false) {
|
||||||
enableParallelChecking = attrs.enableParallelChecking or true;
|
enableParallelChecking = attrs.enableParallelChecking or true;
|
||||||
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {
|
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user