uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -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()

View file

@ -0,0 +1,21 @@
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]
- # 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
+ # Remove such spurious, non-explicit "system" paths for Nix&Nixpkgs
self.check_and_set_roots(roots, use_system=True)

View file

@ -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 Nixs 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')

View file

@ -0,0 +1,121 @@
{ lib
, fetchpatch
, installShellFiles
, ninja
, pkg-config
, python3
, substituteAll
, withDarwinFrameworksGtkDocPatch ? false
}:
python3.pkgs.buildPythonApplication rec {
pname = "meson";
version = "0.61.2";
src = python3.pkgs.fetchPypi {
inherit pname version;
hash = "sha256-AjOn+NlZB5MY9gUrCTnCf2il3oa6YB8lye5oaftfWIk=";
};
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.
# Lets 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
# https://github.com/mesonbuild/meson/pull/9841
# cross-compilation fix
(fetchpatch {
url = "https://github.com/mesonbuild/meson/commit/266e8acb5807b38a550cb5145cea0e19545a21d7.patch";
sha256 = "sha256-1GdKsm2xvq2GxTNeTyBH5O73hxboL0YI+w2BCoUeWXM=";
})
] ++ lib.optionals withDarwinFrameworksGtkDocPatch [
# Fix building gtkdoc for GLib
# https://github.com/mesonbuild/meson/pull/10186
./fix-gtkdoc-when-using-multiple-apple-frameworks.patch
];
setupHook = ./setup-hook.sh;
# 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
'';
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 = "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 AndersonTorres ];
inherit (python3.meta) platforms;
};
}
# TODO: a more Nixpkgs-tailoired test suite

View file

@ -0,0 +1,162 @@
From b8ba462ae72e0818898357464263ec84722f6d4c Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 26 Mar 2022 02:26:27 +0100
Subject: [PATCH] gnome: Fix gtkdoc when using multiple Apple frameworks
The `-framework Foundation -framework CoreFoundation` ended up
de-duplicated by OrderedSet into `-framework Foundation CoreFoundation`.
Picked from https://github.com/mesonbuild/meson/pull/10186
Also pick https://github.com/mesonbuild/meson/commit/68e684d51f1e469e0d9f4b499ffda15146cad98a when resolving conflict.
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 214f97ac3..0521b2605 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -593,15 +593,16 @@ class GnomeModule(ExtensionModule):
lib: T.Union[build.SharedLibrary, build.StaticLibrary],
depends: T.List[build.BuildTarget],
include_rpath: bool = False,
- use_gir_args: bool = False) -> T.List[str]:
+ use_gir_args: bool = False) -> T.Tuple[T.List[str], T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]:
link_command: T.List[str] = []
+ new_depends = list(depends)
# Construct link args
if isinstance(lib, build.SharedLibrary):
libdir = os.path.join(state.environment.get_build_dir(), state.backend.get_target_dir(lib))
link_command.append('-L' + libdir)
if include_rpath:
link_command.append('-Wl,-rpath,' + libdir)
- depends.append(lib)
+ new_depends.append(lib)
# Needed for the following binutils bug:
# https://github.com/mesonbuild/meson/issues/1911
# However, g-ir-scanner does not understand -Wl,-rpath
@@ -615,19 +616,19 @@ class GnomeModule(ExtensionModule):
link_command.append('--extra-library=' + lib.name)
else:
link_command.append('-l' + lib.name)
- return link_command
+ return link_command, new_depends
- def _get_dependencies_flags(
+ def _get_dependencies_flags_raw(
self, deps: T.Sequence[T.Union['Dependency', build.SharedLibrary, build.StaticLibrary]],
- state: 'ModuleState', depends: T.List[build.BuildTarget], include_rpath: bool = False,
- use_gir_args: bool = False, separate_nodedup: bool = False
- ) -> T.Tuple[OrderedSet[str], OrderedSet[str], OrderedSet[str], T.Optional[T.List[str]], OrderedSet[str]]:
+ state: 'ModuleState', depends: T.List[build.BuildTarget], include_rpath: bool,
+ use_gir_args: bool
+ ) -> T.Tuple[OrderedSet[str], OrderedSet[T.Union[str, T.Tuple[str, str]]], OrderedSet[T.Union[str, T.Tuple[str, str]]], T.Optional[T.List[str]], OrderedSet[str],
+ T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]:
cflags: OrderedSet[str] = OrderedSet()
- internal_ldflags: OrderedSet[str] = OrderedSet()
- external_ldflags: OrderedSet[str] = OrderedSet()
# External linker flags that can't be de-duped reliably because they
- # require two args in order, such as -framework AVFoundation
- external_ldflags_nodedup: T.List[str] = []
+ # require two args in order, such as -framework AVFoundation will be stored as a tuple.
+ internal_ldflags: OrderedSet[T.Union[str, T.Tuple[str, str]]] = OrderedSet()
+ external_ldflags: OrderedSet[T.Union[str, T.Tuple[str, str]]] = OrderedSet()
gi_includes: OrderedSet[str] = OrderedSet()
deps = mesonlib.listify(deps)
@@ -642,21 +643,20 @@ class GnomeModule(ExtensionModule):
cflags.update(state.get_include_args(dep.include_directories))
for lib in dep.libraries:
if isinstance(lib, build.SharedLibrary):
- internal_ldflags.update(self._get_link_args(state, lib, depends, include_rpath))
- libdepflags = self._get_dependencies_flags(lib.get_external_deps(), state, depends, include_rpath,
- use_gir_args, True)
+ _ld, depends = self._get_link_args(state, lib, depends, include_rpath)
+ internal_ldflags.update(_ld)
+ libdepflags = self._get_dependencies_flags_raw(lib.get_external_deps(), state, depends, include_rpath,
+ use_gir_args)
cflags.update(libdepflags[0])
internal_ldflags.update(libdepflags[1])
external_ldflags.update(libdepflags[2])
- external_ldflags_nodedup += libdepflags[3]
- gi_includes.update(libdepflags[4])
- extdepflags = self._get_dependencies_flags(dep.ext_deps, state, depends, include_rpath,
- use_gir_args, True)
+ gi_includes.update(libdepflags[3])
+ extdepflags = self._get_dependencies_flags_raw(dep.ext_deps, state, depends, include_rpath,
+ use_gir_args)
cflags.update(extdepflags[0])
internal_ldflags.update(extdepflags[1])
external_ldflags.update(extdepflags[2])
- external_ldflags_nodedup += extdepflags[3]
- gi_includes.update(extdepflags[4])
+ gi_includes.update(extdepflags[3])
for source in dep.sources:
if isinstance(source, GirTarget):
gi_includes.update([os.path.join(state.environment.get_build_dir(),
@@ -684,7 +684,7 @@ class GnomeModule(ExtensionModule):
# If it's a framework arg, slurp the framework name too
# to preserve the order of arguments
if flag == '-framework':
- external_ldflags_nodedup += [flag, next(ldflags)]
+ external_ldflags.update([(flag, next(ldflags))])
else:
external_ldflags.update([flag])
elif isinstance(dep, (build.StaticLibrary, build.SharedLibrary)):
@@ -695,21 +695,41 @@ class GnomeModule(ExtensionModule):
continue
if use_gir_args and self._gir_has_option('--extra-library'):
- def fix_ldflags(ldflags: T.Iterable[str]) -> OrderedSet[str]:
- fixed_ldflags: OrderedSet[str] = OrderedSet()
+ def fix_ldflags(ldflags: T.Iterable[T.Union[str, T.Tuple[str, str]]]) -> OrderedSet[T.Union[str, T.Tuple[str, str]]]:
+ fixed_ldflags: OrderedSet[T.Union[str, T.Tuple[str, str]]] = OrderedSet()
for ldflag in ldflags:
- if ldflag.startswith("-l"):
+ if isinstance(ldflag, str) and ldflag.startswith("-l"):
ldflag = ldflag.replace('-l', '--extra-library=', 1)
fixed_ldflags.add(ldflag)
return fixed_ldflags
internal_ldflags = fix_ldflags(internal_ldflags)
external_ldflags = fix_ldflags(external_ldflags)
- if not separate_nodedup:
- external_ldflags.update(external_ldflags_nodedup)
- return cflags, internal_ldflags, external_ldflags, None, gi_includes
- else:
- return cflags, internal_ldflags, external_ldflags, external_ldflags_nodedup, gi_includes
+ return cflags, internal_ldflags, external_ldflags, gi_includes, depends
+
+ def _get_dependencies_flags(
+ self, deps: T.Sequence[T.Union['Dependency', build.SharedLibrary, build.StaticLibrary]],
+ state: 'ModuleState', depends: T.List[build.BuildTarget], include_rpath: bool = False,
+ use_gir_args: bool = False
+ ) -> T.Tuple[OrderedSet[str], T.List[str], T.List[str], OrderedSet[str],
+ T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]:
+
+ cflags, internal_ldflags_raw, external_ldflags_raw, gi_includes, depends = self._get_dependencies_flags_raw(deps, state, depends, include_rpath, use_gir_args)
+ internal_ldflags: T.List[str] = []
+ external_ldflags: T.List[str] = []
+
+ # Extract non-deduplicable argument groups out of the tuples.
+ for ldflag in internal_ldflags_raw:
+ if isinstance(ldflag, str):
+ internal_ldflags.append(ldflag)
+ else:
+ internal_ldflags.extend(ldflag)
+ for ldflag in external_ldflags_raw:
+ if isinstance(ldflag, str):
+ external_ldflags.append(ldflag)
+ else:
+ external_ldflags.extend(ldflag)
+ return cflags, internal_ldflags, external_ldflags, gi_includes, depends
def _unwrap_gir_target(self, girtarget: T.Union[build.Executable, build.StaticLibrary, build.SharedLibrary], state: 'ModuleState'
) -> T.Union[build.Executable, build.StaticLibrary, build.SharedLibrary]:
if not isinstance(girtarget, (build.Executable, build.SharedLibrary,
@@ -1056,7 +1076,7 @@ class GnomeModule(ExtensionModule):
# ldflags will be misinterpreted by gir scanner (showing
# spurious dependencies) but building GStreamer fails if they
# are not used here.
- dep_cflags, dep_internal_ldflags, dep_external_ldflags, _, gi_includes = \
+ dep_cflags, dep_internal_ldflags, dep_external_ldflags, gi_includes, depends = \
self._get_dependencies_flags(deps, state, depends, use_gir_args=True)
scan_cflags = []
scan_cflags += list(self._get_scanner_cflags(cflags))

View file

@ -0,0 +1,24 @@
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -723,6 +723,21 @@
@staticmethod
def get_rpath_dirs_from_link_args(args: T.List[str]) -> T.Set[str]:
dirs: T.Set[str] = set()
+
+ 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,

View file

@ -0,0 +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
@@ -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 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])))
+
+ 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]
+
generated_files = [f for f in libsources if isinstance(f, (GeneratedList, CustomTarget, CustomTargetIndex))]
scan_target = self._make_gir_target(state, girfile, scan_command, generated_files, depends, kwargs)

View file

@ -0,0 +1,12 @@
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 versions
[var_name]
)[for_machine]

View file

@ -0,0 +1,37 @@
mesonConfigurePhase() {
runHook preConfigure
if [ -z "${dontAddPrefix-}" ]; then
mesonFlags="--prefix=$prefix $mesonFlags"
fi
# See multiple-outputs.sh and mesons 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