From 1a53eeda71a17d917f89e6539094795435b1458e Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 12 Dec 2021 18:05:47 -0300 Subject: [PATCH 1/6] meson: put 0.57 in a subdirectory Meson is a delicate package. It needs some patches to properly work in Nixpkgs and many packages have it as a dependency, from many small applications to systemd (yay, mass rebuilds in sight!). Updating it is not a trivial and harmless task. Therefore, I took the paranoid way and encapsulate the current version in a subdir, instead of the regular write-over procedure. This way, at the best we can just remove the whole dir in the future, and at the worse we just maintain duplicated code. --- .../meson/{ => 0.57}/allow-dirs-outside-of-prefix.patch | 0 .../{ => 0.57}/boost-Do-not-add-system-paths-on-nix.patch | 0 .../build-managers/meson/{ => 0.57}/clear-old-rpath.patch | 0 .../tools/build-managers/meson/{ => 0.57}/default.nix | 1 - .../tools/build-managers/meson/{ => 0.57}/fix-rpath.patch | 0 .../build-managers/meson/{ => 0.57}/gir-fallback-path.patch | 0 .../tools/build-managers/meson/{ => 0.57}/more-env-vars.patch | 0 .../tools/build-managers/meson/{ => 0.57}/setup-hook.sh | 0 pkgs/top-level/all-packages.nix | 3 ++- 9 files changed, 2 insertions(+), 2 deletions(-) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/allow-dirs-outside-of-prefix.patch (100%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/boost-Do-not-add-system-paths-on-nix.patch (100%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/clear-old-rpath.patch (100%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/default.nix (99%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/fix-rpath.patch (100%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/gir-fallback-path.patch (100%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/more-env-vars.patch (100%) rename pkgs/development/tools/build-managers/meson/{ => 0.57}/setup-hook.sh (100%) diff --git a/pkgs/development/tools/build-managers/meson/allow-dirs-outside-of-prefix.patch b/pkgs/development/tools/build-managers/meson/0.57/allow-dirs-outside-of-prefix.patch similarity index 100% rename from pkgs/development/tools/build-managers/meson/allow-dirs-outside-of-prefix.patch rename to pkgs/development/tools/build-managers/meson/0.57/allow-dirs-outside-of-prefix.patch diff --git a/pkgs/development/tools/build-managers/meson/boost-Do-not-add-system-paths-on-nix.patch b/pkgs/development/tools/build-managers/meson/0.57/boost-Do-not-add-system-paths-on-nix.patch similarity index 100% rename from pkgs/development/tools/build-managers/meson/boost-Do-not-add-system-paths-on-nix.patch rename to pkgs/development/tools/build-managers/meson/0.57/boost-Do-not-add-system-paths-on-nix.patch diff --git a/pkgs/development/tools/build-managers/meson/clear-old-rpath.patch b/pkgs/development/tools/build-managers/meson/0.57/clear-old-rpath.patch similarity index 100% rename from pkgs/development/tools/build-managers/meson/clear-old-rpath.patch rename to pkgs/development/tools/build-managers/meson/0.57/clear-old-rpath.patch diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/0.57/default.nix similarity index 99% rename from pkgs/development/tools/build-managers/meson/default.nix rename to pkgs/development/tools/build-managers/meson/0.57/default.nix index de82609a5486f..6fd93e8f86b15 100644 --- a/pkgs/development/tools/build-managers/meson/default.nix +++ b/pkgs/development/tools/build-managers/meson/0.57/default.nix @@ -1,6 +1,5 @@ { lib , python3 - , writeTextDir , substituteAll , fetchpatch diff --git a/pkgs/development/tools/build-managers/meson/fix-rpath.patch b/pkgs/development/tools/build-managers/meson/0.57/fix-rpath.patch similarity index 100% rename from pkgs/development/tools/build-managers/meson/fix-rpath.patch rename to pkgs/development/tools/build-managers/meson/0.57/fix-rpath.patch diff --git a/pkgs/development/tools/build-managers/meson/gir-fallback-path.patch b/pkgs/development/tools/build-managers/meson/0.57/gir-fallback-path.patch similarity index 100% rename from pkgs/development/tools/build-managers/meson/gir-fallback-path.patch rename to pkgs/development/tools/build-managers/meson/0.57/gir-fallback-path.patch diff --git a/pkgs/development/tools/build-managers/meson/more-env-vars.patch b/pkgs/development/tools/build-managers/meson/0.57/more-env-vars.patch similarity index 100% rename from pkgs/development/tools/build-managers/meson/more-env-vars.patch rename to pkgs/development/tools/build-managers/meson/0.57/more-env-vars.patch diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/0.57/setup-hook.sh similarity index 100% rename from pkgs/development/tools/build-managers/meson/setup-hook.sh rename to pkgs/development/tools/build-managers/meson/0.57/setup-hook.sh diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c057511d2cb96..7d0fa820211fa 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3366,7 +3366,8 @@ with pkgs; merriweather-sans = callPackage ../data/fonts/merriweather-sans { }; - meson = callPackage ../development/tools/build-managers/meson { }; + meson = meson_0_57; + meson_0_57 = callPackage ../development/tools/build-managers/meson/0.57 { }; meson-tools = callPackage ../misc/meson-tools { }; From e9c8925d1bc83625489dea6ef446f8218f9b25f8 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 12 Dec 2021 18:35:10 -0300 Subject: [PATCH 2/6] meson: copy 0.57 to 0.60 A very ugly decision: in order to register the diff between 0.57 and 0.60 releases of Meson in Nixpkgs, I copied the whole directory before actually write it by hand. --- .../0.60/allow-dirs-outside-of-prefix.patch | 19 ++++ ...boost-Do-not-add-system-paths-on-nix.patch | 40 ++++++++ .../meson/0.60/clear-old-rpath.patch | 20 ++++ .../build-managers/meson/0.60/default.nix | 94 +++++++++++++++++++ .../build-managers/meson/0.60/fix-rpath.patch | 24 +++++ .../meson/0.60/gir-fallback-path.patch | 16 ++++ .../meson/0.60/more-env-vars.patch | 13 +++ .../build-managers/meson/0.60/setup-hook.sh | 37 ++++++++ 8 files changed, 263 insertions(+) create mode 100644 pkgs/development/tools/build-managers/meson/0.60/allow-dirs-outside-of-prefix.patch create mode 100644 pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch create mode 100644 pkgs/development/tools/build-managers/meson/0.60/clear-old-rpath.patch create mode 100644 pkgs/development/tools/build-managers/meson/0.60/default.nix create mode 100644 pkgs/development/tools/build-managers/meson/0.60/fix-rpath.patch create mode 100644 pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch create mode 100644 pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch create mode 100644 pkgs/development/tools/build-managers/meson/0.60/setup-hook.sh diff --git a/pkgs/development/tools/build-managers/meson/0.60/allow-dirs-outside-of-prefix.patch b/pkgs/development/tools/build-managers/meson/0.60/allow-dirs-outside-of-prefix.patch new file mode 100644 index 0000000000000..4eb292a2e529e --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/allow-dirs-outside-of-prefix.patch @@ -0,0 +1,19 @@ +--- a/mesonbuild/coredata.py ++++ b/mesonbuild/coredata.py +@@ -506,7 +506,6 @@ class CoreData: + return value + if option.name.endswith('dir') and value.is_absolute() and \ + option not in BULITIN_DIR_NOPREFIX_OPTIONS: +- # Value must be a subdir of the prefix + # commonpath will always return a path in the native format, so we + # must use pathlib.PurePath to do the same conversion before + # comparing. +@@ -518,7 +517,7 @@ class CoreData: + try: + value = value.relative_to(prefix) + except ValueError: +- raise MesonException(msg.format(option, value, prefix)) ++ pass + if '..' in str(value): + raise MesonException(msg.format(option, value, prefix)) + return value.as_posix() diff --git a/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch b/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch new file mode 100644 index 0000000000000..5b9020b3d5402 --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch @@ -0,0 +1,40 @@ +From 536108b10271f2f42d41c7d9ddb4ce2ea1851f4f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= +Date: Sat, 17 Oct 2020 19:27:08 +0200 +Subject: [PATCH] boost: Do not add system paths on nix + +--- + mesonbuild/dependencies/boost.py | 17 +---------------- + 1 file changed, 1 insertion(+), 16 deletions(-) + +diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py +index 907c0c275..ecaf11b18 100644 +--- a/mesonbuild/dependencies/boost.py ++++ b/mesonbuild/dependencies/boost.py +@@ -643,22 +643,7 @@ class BoostDependency(ExternalDependency): + roots += [x for x in candidates if x.name.lower().startswith('boost') and x.is_dir()] + else: + tmp = [] # type: T.List[Path] +- +- # Homebrew +- brew_boost = Path('/usr/local/Cellar/boost') +- if brew_boost.is_dir(): +- tmp += [x for x in brew_boost.iterdir()] +- +- # Add some default system paths +- tmp += [Path('/opt/local')] +- tmp += [Path('/usr/local/opt/boost')] +- tmp += [Path('/usr/local')] +- tmp += [Path('/usr')] +- +- # Cleanup paths +- tmp = [x for x in tmp if x.is_dir()] +- tmp = [x.resolve() for x in tmp] +- roots += tmp ++ # Do not add any non-explicit paths on nix + + return roots + +-- +2.25.4 + diff --git a/pkgs/development/tools/build-managers/meson/0.60/clear-old-rpath.patch b/pkgs/development/tools/build-managers/meson/0.60/clear-old-rpath.patch new file mode 100644 index 0000000000000..f1e3c76e8b53b --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/clear-old-rpath.patch @@ -0,0 +1,20 @@ +diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py +index 4176b9a03..faaabf616 100644 +--- a/mesonbuild/scripts/depfixer.py ++++ b/mesonbuild/scripts/depfixer.py +@@ -336,6 +336,15 @@ class Elf(DataSizes): + if not new_rpath: + self.remove_rpath_entry(entrynum) + else: ++ # Clear old rpath to avoid stale references, ++ # not heeding the warning above about de-duplication ++ # since it does not seem to cause issues for us ++ # and not doing so trips up Nix’s reference checker. ++ # See https://github.com/NixOS/nixpkgs/pull/46020 ++ # and https://github.com/NixOS/nixpkgs/issues/95163 ++ self.bf.seek(rp_off) ++ self.bf.write(b'\0'*len(old_rpath)) ++ + self.bf.seek(rp_off) + self.bf.write(new_rpath) + self.bf.write(b'\0') diff --git a/pkgs/development/tools/build-managers/meson/0.60/default.nix b/pkgs/development/tools/build-managers/meson/0.60/default.nix new file mode 100644 index 0000000000000..6fd93e8f86b15 --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/default.nix @@ -0,0 +1,94 @@ +{ lib +, python3 +, writeTextDir +, substituteAll +, fetchpatch +, installShellFiles +}: + +python3.pkgs.buildPythonApplication rec { + pname = "meson"; + version = "0.57.1"; + + src = python3.pkgs.fetchPypi { + inherit pname version; + sha256 = "19n8alcpzv6npgp27iqljkmvdmr7s2c7zm8y997j1nlvpa1cgqbj"; + }; + + patches = [ + # Upstream insists on not allowing bindir and other dir options + # outside of prefix for some reason: + # https://github.com/mesonbuild/meson/issues/2561 + # 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. + # We patch Meson to add a --fallback-library-path argument with + # library install_dir to g-ir-scanner. + ./gir-fallback-path.patch + + # In common distributions, RPATH is only needed for internal libraries so + # meson removes everything else. With Nix, the locations of libraries + # are not as predictable, therefore we need to keep them in the RPATH. + # At the moment we are keeping the paths starting with /nix/store. + # https://github.com/NixOS/nixpkgs/issues/31222#issuecomment-365811634 + (substituteAll { + src = ./fix-rpath.patch; + inherit (builtins) storeDir; + }) + + # When Meson removes build_rpath from DT_RUNPATH entry, it just writes + # the shorter NUL-terminated new rpath over the old one to reduce + # the risk of potentially breaking the ELF files. + # But this can cause much bigger problem for Nix as it can produce + # cut-in-half-by-\0 store path references. + # Let’s just clear the whole rpath and hope for the best. + ./clear-old-rpath.patch + + # Patch out default boost search paths to avoid impure builds on + # unsandboxed non-NixOS builds, see: + # https://github.com/NixOS/nixpkgs/issues/86131#issuecomment-711051774 + ./boost-Do-not-add-system-paths-on-nix.patch + ]; + + setupHook = ./setup-hook.sh; + + # 0.45 update enabled tests but they are failing + doCheck = false; + # checkInputs = [ ninja pkg-config ]; + # checkPhase = "python ./run_project_tests.py"; + + postFixup = '' + pushd $out/bin + # undo shell wrapper as meson tools are called with python + for i in *; do + mv ".$i-wrapped" "$i" + done + popd + + # Do not propagate Python + rm $out/nix-support/propagated-build-inputs + ''; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = '' + installShellCompletion --zsh data/shell-completions/zsh/_meson + installShellCompletion --bash data/shell-completions/bash/meson + ''; + + 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"; + license = licenses.asl20; + maintainers = with maintainers; [ jtojnar mbe ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/tools/build-managers/meson/0.60/fix-rpath.patch b/pkgs/development/tools/build-managers/meson/0.60/fix-rpath.patch new file mode 100644 index 0000000000000..d34b6c4c43457 --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/fix-rpath.patch @@ -0,0 +1,24 @@ +--- a/mesonbuild/backend/backends.py ++++ b/mesonbuild/backend/backends.py +@@ -456,6 +456,21 @@ class Backend: + args.extend(self.environment.coredata.get_external_link_args(target.for_machine, lang)) + except Exception: + pass ++ ++ nix_ldflags = os.environ.get('NIX_LDFLAGS', '').split() ++ next_is_path = False ++ # Try to add rpaths set by user or ld-wrapper so that they are not removed. ++ # Based on https://github.com/NixOS/nixpkgs/blob/69711a2f5ffe8cda208163be5258266172ff527f/pkgs/build-support/bintools-wrapper/ld-wrapper.sh#L148-L177 ++ for flag in nix_ldflags: ++ if flag == '-rpath' or flag == '-L': ++ next_is_path = True ++ elif next_is_path or flag.startswith('-L/'): ++ if flag.startswith('-L/'): ++ flag = flag[2:] ++ if flag.startswith('@storeDir@'): ++ dirs.add(flag) ++ next_is_path = False ++ + # Match rpath formats: + # -Wl,-rpath= + # -Wl,-rpath, diff --git a/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch b/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch new file mode 100644 index 0000000000000..0c924bacf73f5 --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch @@ -0,0 +1,16 @@ +--- a/mesonbuild/modules/gnome.py ++++ b/mesonbuild/modules/gnome.py +@@ -807,6 +807,13 @@ class GnomeModule(ExtensionModule): + if fatal_warnings: + scan_command.append('--warn-error') + ++ if len(set([girtarget.get_custom_install_dir()[0] for girtarget in girtargets])) > 1: ++ raise MesonException('generate_gir tries to build multiple libraries with different install_dir at once: {}'.format(','.join([str(girtarget) for girtarget in girtargets]))) ++ ++ fallback_libpath = girtargets[0].get_custom_install_dir()[0] ++ if fallback_libpath is not None and isinstance(fallback_libpath, str) and len(fallback_libpath) > 0 and fallback_libpath[0] == "/": ++ scan_command += ['--fallback-library-path=' + fallback_libpath] ++ + scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs) + + typelib_output = '%s-%s.typelib' % (ns, nsversion) diff --git a/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch b/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch new file mode 100644 index 0000000000000..4b2606e2d694a --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch @@ -0,0 +1,13 @@ +diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py +index 756dd8193..a5cc6ef8b 100644 +--- a/mesonbuild/environment.py ++++ b/mesonbuild/environment.py +@@ -151,7 +151,7 @@ def _get_env_var(for_machine: MachineChoice, is_cross: bool, var_name: str) -> T + # 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 + [var_name] + )[for_machine] diff --git a/pkgs/development/tools/build-managers/meson/0.60/setup-hook.sh b/pkgs/development/tools/build-managers/meson/0.60/setup-hook.sh new file mode 100644 index 0000000000000..3d946fcffd522 --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/0.60/setup-hook.sh @@ -0,0 +1,37 @@ +mesonConfigurePhase() { + runHook preConfigure + + if [ -z "${dontAddPrefix-}" ]; then + mesonFlags="--prefix=$prefix $mesonFlags" + fi + + # See multiple-outputs.sh and meson’s coredata.py + mesonFlags="\ + --libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec \ + --bindir=${!outputBin}/bin --sbindir=${!outputBin}/sbin \ + --includedir=${!outputInclude}/include \ + --mandir=${!outputMan}/share/man --infodir=${!outputInfo}/share/info \ + --localedir=${!outputLib}/share/locale \ + -Dauto_features=${mesonAutoFeatures:-enabled} \ + -Dwrap_mode=${mesonWrapMode:-nodownload} \ + $mesonFlags" + + mesonFlags="${crossMesonFlags+$crossMesonFlags }--buildtype=${mesonBuildType:-plain} $mesonFlags" + + echo "meson flags: $mesonFlags ${mesonFlagsArray[@]}" + + meson build $mesonFlags "${mesonFlagsArray[@]}" + cd build + + if ! [[ -v enableParallelBuilding ]]; then + enableParallelBuilding=1 + echo "meson: enabled parallel building" + fi + + runHook postConfigure +} + +if [ -z "${dontUseMesonConfigure-}" -a -z "${configurePhase-}" ]; then + setOutputFlags= + configurePhase=mesonConfigurePhase +fi From fac4c247ca3f19400ddefce6a88d4c50b0a539e3 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 12 Dec 2021 22:47:19 -0300 Subject: [PATCH 3/6] meson: 0.57.1 -> 0.60.2 --- ...boost-Do-not-add-system-paths-on-nix.patch | 33 ++++--------------- .../build-managers/meson/0.60/default.nix | 5 ++- .../meson/0.60/gir-fallback-path.patch | 17 ++++++---- .../meson/0.60/more-env-vars.patch | 13 ++++---- pkgs/top-level/all-packages.nix | 5 +-- 5 files changed, 29 insertions(+), 44 deletions(-) diff --git a/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch b/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch index 5b9020b3d5402..0a2eda9de9ac6 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch +++ b/pkgs/development/tools/build-managers/meson/0.60/boost-Do-not-add-system-paths-on-nix.patch @@ -1,26 +1,10 @@ -From 536108b10271f2f42d41c7d9ddb4ce2ea1851f4f Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= -Date: Sat, 17 Oct 2020 19:27:08 +0200 -Subject: [PATCH] boost: Do not add system paths on nix - ---- - mesonbuild/dependencies/boost.py | 17 +---------------- - 1 file changed, 1 insertion(+), 16 deletions(-) - -diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py -index 907c0c275..ecaf11b18 100644 ---- a/mesonbuild/dependencies/boost.py -+++ b/mesonbuild/dependencies/boost.py -@@ -643,22 +643,7 @@ class BoostDependency(ExternalDependency): - roots += [x for x in candidates if x.name.lower().startswith('boost') and x.is_dir()] +diff -Naur meson-0.60.2-old/mesonbuild/dependencies/boost.py meson-0.60.2-new/mesonbuild/dependencies/boost.py +--- meson-0.60.2-old/mesonbuild/dependencies/boost.py 2021-11-02 16:58:07.000000000 -0300 ++++ meson-0.60.2-new/mesonbuild/dependencies/boost.py 2021-12-12 19:21:27.895705897 -0300 +@@ -682,16 +682,7 @@ else: tmp = [] # type: T.List[Path] -- -- # Homebrew -- brew_boost = Path('/usr/local/Cellar/boost') -- if brew_boost.is_dir(): -- tmp += [x for x in brew_boost.iterdir()] -- + - # Add some default system paths - tmp += [Path('/opt/local')] - tmp += [Path('/usr/local/opt/boost')] @@ -31,10 +15,7 @@ index 907c0c275..ecaf11b18 100644 - tmp = [x for x in tmp if x.is_dir()] - tmp = [x.resolve() for x in tmp] - roots += tmp -+ # Do not add any non-explicit paths on nix ++ # Remove such spurious, non-explicit "system" paths for Nix&Nixpkgs - return roots + self.check_and_set_roots(roots, use_system=True) --- -2.25.4 - diff --git a/pkgs/development/tools/build-managers/meson/0.60/default.nix b/pkgs/development/tools/build-managers/meson/0.60/default.nix index 6fd93e8f86b15..13ca80340d8b4 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/default.nix +++ b/pkgs/development/tools/build-managers/meson/0.60/default.nix @@ -1,6 +1,5 @@ { lib , python3 -, writeTextDir , substituteAll , fetchpatch , installShellFiles @@ -8,11 +7,11 @@ python3.pkgs.buildPythonApplication rec { pname = "meson"; - version = "0.57.1"; + version = "0.60.2"; src = python3.pkgs.fetchPypi { inherit pname version; - sha256 = "19n8alcpzv6npgp27iqljkmvdmr7s2c7zm8y997j1nlvpa1cgqbj"; + hash = "sha256-ZOaWhWW/G4FS9PnWyoFU77nhTKqaq/eyLnHmxdBT6SE="; }; patches = [ diff --git a/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch b/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch index 0c924bacf73f5..e6d7402652778 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch +++ b/pkgs/development/tools/build-managers/meson/0.60/gir-fallback-path.patch @@ -1,16 +1,21 @@ +diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py +index 1c6952df7..9466a0b7d 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py -@@ -807,6 +807,13 @@ class GnomeModule(ExtensionModule): +@@ -923,6 +923,16 @@ class GnomeModule(ExtensionModule): if fatal_warnings: scan_command.append('--warn-error') - -+ if len(set([girtarget.get_custom_install_dir()[0] for girtarget in girtargets])) > 1: + ++ if len(set(girtarget.get_custom_install_dir()[0] for girtarget in girtargets if girtarget.get_custom_install_dir())) > 1: + raise MesonException('generate_gir tries to build multiple libraries with different install_dir at once: {}'.format(','.join([str(girtarget) for girtarget in girtargets]))) + -+ fallback_libpath = girtargets[0].get_custom_install_dir()[0] ++ if girtargets[0].get_custom_install_dir(): ++ fallback_libpath = girtargets[0].get_custom_install_dir()[0] ++ else: ++ fallback_libpath = None + if fallback_libpath is not None and isinstance(fallback_libpath, str) and len(fallback_libpath) > 0 and fallback_libpath[0] == "/": + scan_command += ['--fallback-library-path=' + fallback_libpath] + - scan_target = self._make_gir_target(state, girfile, scan_command, depends, kwargs) + generated_files = [f for f in libsources if isinstance(f, (GeneratedList, CustomTarget, CustomTargetIndex))] - typelib_output = '%s-%s.typelib' % (ns, nsversion) + scan_target = self._make_gir_target(state, girfile, scan_command, generated_files, depends, kwargs) diff --git a/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch b/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch index 4b2606e2d694a..5628f1b27e4a5 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch +++ b/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch @@ -1,13 +1,12 @@ -diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py -index 756dd8193..a5cc6ef8b 100644 ---- a/mesonbuild/environment.py -+++ b/mesonbuild/environment.py -@@ -151,7 +151,7 @@ def _get_env_var(for_machine: MachineChoice, is_cross: bool, var_name: str) -> T +diff -Naur meson-0.60.2-old/mesonbuild/environment.py meson-0.60.2-new/mesonbuild/environment.py +--- meson-0.60.2-old/mesonbuild/environment.py 2021-11-02 16:58:13.000000000 -0300 ++++ meson-0.60.2-new/mesonbuild/environment.py 2021-12-12 17:44:00.350499307 -0300 +@@ -68,7 +68,7 @@ # 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 ++ [var_name + '_FOR_BUILD'] ++ ([] if is_cross else [var_name]), + # Always just the unprefixed host versions [var_name] )[for_machine] diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7d0fa820211fa..6d16e1b8458dc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3366,8 +3366,9 @@ with pkgs; merriweather-sans = callPackage ../data/fonts/merriweather-sans { }; - meson = meson_0_57; - meson_0_57 = callPackage ../development/tools/build-managers/meson/0.57 { }; + # TODO: call a sprintable to deprecate Meson 0.57 as soon as possible + meson = callPackage ../development/tools/build-managers/meson/0.57 { }; + meson_0_60 = callPackage ../development/tools/build-managers/meson/0.60 { }; meson-tools = callPackage ../misc/meson-tools { }; From c401c98393d3ca0ce29ad09b7b9ba11b3856e825 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Tue, 14 Dec 2021 12:15:43 -0300 Subject: [PATCH 4/6] meson 0.60: Fix more-env-vars.patch Concatenation of lists in Python is done by the `+` operator. --- .../tools/build-managers/meson/0.60/more-env-vars.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch b/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch index 5628f1b27e4a5..e4ad43550423d 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch +++ b/pkgs/development/tools/build-managers/meson/0.60/more-env-vars.patch @@ -6,7 +6,7 @@ diff -Naur meson-0.60.2-old/mesonbuild/environment.py meson-0.60.2-new/mesonbuil # 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]), ++ [var_name + '_FOR_BUILD'] + ([] if is_cross else [var_name]), # Always just the unprefixed host versions [var_name] )[for_machine] From 5dc14c358c96fb2eb54fbea4f10e8ba7d1032fd4 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 12 Dec 2021 19:29:19 -0300 Subject: [PATCH 5/6] meson: add myself as maintainer --- .../tools/build-managers/meson/0.60/default.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkgs/development/tools/build-managers/meson/0.60/default.nix b/pkgs/development/tools/build-managers/meson/0.60/default.nix index 13ca80340d8b4..7babbba340011 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/default.nix +++ b/pkgs/development/tools/build-managers/meson/0.60/default.nix @@ -85,9 +85,18 @@ python3.pkgs.buildPythonApplication rec { 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"; + description = "An open source, fast and friendly build system made in Python"; + longDescription = '' + Meson is an open source build system meant to be both extremely fast, and, + even more importantly, as user friendly as possible. + + The main design point of Meson is that every moment a developer spends + writing or debugging build definitions is a second wasted. So is every + second spent waiting for the build system to actually start compiling + code. + ''; license = licenses.asl20; - maintainers = with maintainers; [ jtojnar mbe ]; - platforms = platforms.all; + maintainers = with maintainers; [ jtojnar mbe AndersonTorres ]; + inherit (python3.meta) platforms; }; } From 650c249d8f641c79623b80b0789feca42d2a30d5 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 12 Dec 2021 22:50:23 -0300 Subject: [PATCH 6/6] meson: document the failed tests issue The comment should be self-explaining now. --- .../tools/build-managers/meson/0.60/default.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/development/tools/build-managers/meson/0.60/default.nix b/pkgs/development/tools/build-managers/meson/0.60/default.nix index 7babbba340011..79870cd4d128a 100644 --- a/pkgs/development/tools/build-managers/meson/0.60/default.nix +++ b/pkgs/development/tools/build-managers/meson/0.60/default.nix @@ -1,8 +1,10 @@ { lib -, python3 -, substituteAll , fetchpatch , installShellFiles +, ninja +, pkg-config +, python3 +, substituteAll }: python3.pkgs.buildPythonApplication rec { @@ -59,10 +61,14 @@ python3.pkgs.buildPythonApplication rec { setupHook = ./setup-hook.sh; - # 0.45 update enabled tests but they are failing + # Meson included tests since 0.45, however they fail in Nixpkgs because they + # require a typical building environment (including C compiler and stuff). + # Just for the sake of documentation, the next lines are maintained here. doCheck = false; - # checkInputs = [ ninja pkg-config ]; - # checkPhase = "python ./run_project_tests.py"; + checkInputs = [ ninja pkg-config ]; + checkPhase = '' + python ./run_project_tests.py + ''; postFixup = '' pushd $out/bin @@ -100,3 +106,4 @@ python3.pkgs.buildPythonApplication rec { inherit (python3.meta) platforms; }; } +# TODO: a more Nixpkgs-tailoired test suite