Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 839c0c783f90
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 941d2765fd34
Choose a head ref
  • 4 commits
  • 4 files changed
  • 2 contributors

Commits on Apr 26, 2020

  1. meson: Don't set CC and CXX

    I've since convinced upstream to not use such vars for the build
    platform during cross. Finally!
    Ericson2314 committed Apr 26, 2020
    Copy the full SHA
    3c00ca0 View commit details

Commits on Apr 28, 2020

  1. meson: Patch to ingest env vars like autoconf

    See comment in code and the PR it references,
    mesonbuild/meson#6827, for details.
    
    We can remove entries from the cross file because they will be gotten
    from env vars now.
    Ericson2314 committed Apr 28, 2020
    Copy the full SHA
    128b93e View commit details
  2. 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.
    Ericson2314 committed Apr 28, 2020
    Copy the full SHA
    8245230 View commit details
  3. Merge pull request #86080 from Ericson2314/fix-meson-cross

    meson: Clean up build and infra
    Ericson2314 authored Apr 28, 2020
    Copy the full SHA
    941d276 View commit details
41 changes: 5 additions & 36 deletions pkgs/development/tools/build-managers/meson/default.nix
Original file line number Diff line number Diff line change
@@ -3,20 +3,8 @@
, stdenv
, writeTextDir
, 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 {
pname = "meson";
version = "0.54.0";
@@ -45,6 +33,11 @@ python3Packages.buildPythonApplication rec {
# We remove the check so multiple outputs can work sanely.
./allow-dirs-outside-of-prefix.patch

# Meson is currently inspecting fewer variables than autoconf does, which
# makes it harder for us to use setup hooks, etc. Taken from
# https://github.com/mesonbuild/meson/pull/6827
./more-env-vars.patch

# Unlike libtool, vanilla Meson does not pass any information
# about the path library will be installed to to g-ir-scanner,
# breaking the GIR when path other than ${!outputLib}/lib is used.
@@ -65,35 +58,11 @@ python3Packages.buildPythonApplication rec {

setupHook = ./setup-hook.sh;

crossFile = writeTextDir "cross-file.conf" ''
[binaries]
c = '${targetPackages.stdenv.cc.targetPrefix}cc'
cpp = '${targetPackages.stdenv.cc.targetPrefix}c++'
ar = '${targetPackages.stdenv.cc.bintools.targetPrefix}ar'
strip = '${targetPackages.stdenv.cc.bintools.targetPrefix}strip'
pkgconfig = 'pkg-config'
ld = '${targetPackages.stdenv.cc.targetPrefix}ld'
objcopy = '${targetPackages.stdenv.cc.targetPrefix}objcopy'
[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
doCheck = false;
# checkInputs = [ ninja pkgconfig ];
# checkPhase = "python ./run_project_tests.py";

inherit (stdenv) cc;

isCross = stdenv.targetPlatform != stdenv.hostPlatform;

meta = with lib; {
homepage = "https://mesonbuild.com";
description = "SCons-like build system that use python as a front-end language and Ninja as a building backend";
16 changes: 16 additions & 0 deletions pkgs/development/tools/build-managers/meson/more-env-vars.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
index ac13a710..e0d07c51 100644
--- a/mesonbuild/envconfig.py
+++ b/mesonbuild/envconfig.py
@@ -119,9 +119,9 @@ def get_env_var_pair(for_machine: MachineChoice,
# compiling we fall back on the unprefixed host version. This
# allows native builds to never need to worry about the 'BUILD_*'
# ones.
- ([var_name + '_FOR_BUILD'] if is_cross else [var_name]),
+ [var_name + '_FOR_BUILD'] + ([] if is_cross else [var_name]),
# Always just the unprefixed host verions
- ([] if is_cross else [var_name]),
+ [var_name],
)[for_machine]
for var in candidates:
value = os.environ.get(var)
7 changes: 1 addition & 6 deletions pkgs/development/tools/build-managers/meson/setup-hook.sh
Original file line number Diff line number Diff line change
@@ -5,11 +5,6 @@ mesonConfigurePhase() {
mesonFlags="--prefix=$prefix $mesonFlags"
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
mesonFlags="\
--libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \
@@ -25,7 +20,7 @@ mesonConfigurePhase() {

echo "meson flags: $mesonFlags ${mesonFlagsArray[@]}"

CC=@cc@/bin/cc CXX=@cc@/bin/c++ meson build $mesonFlags "${mesonFlagsArray[@]}"
meson build $mesonFlags "${mesonFlagsArray[@]}"
cd build

if ! [[ -v enableParallelBuilding ]]; then
29 changes: 29 additions & 0 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ in rec {
# Configure Phase
, configureFlags ? []
, cmakeFlags ? []
, mesonFlags ? []
, # Target is not included by default because most programs don't care.
# 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.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}";

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) {
enableParallelChecking = attrs.enableParallelChecking or true;
} // lib.optionalAttrs (hardeningDisable != [] || hardeningEnable != []) {