mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
gnuradio: Make hasFeature function simpler
It always needs the `features` attribute of it's derivation as a last argument, so let's make it do it by it's own.
This commit is contained in:
parent
18eb4531cd
commit
d6fa3fef68
@ -238,34 +238,34 @@ stdenv.mkDerivation rec {
|
||||
passthru = shared.passthru // {
|
||||
# Deps that are potentially overriden and are used inside GR plugins - the same version must
|
||||
inherit boost volk;
|
||||
} // lib.optionalAttrs (hasFeature "gr-uhd" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gr-uhd") {
|
||||
inherit uhd;
|
||||
};
|
||||
cmakeFlags = shared.cmakeFlags
|
||||
# From some reason, if these are not set, libcodec2 and gsm are
|
||||
# not detected properly (slightly different then what's in
|
||||
# ./default.nix).
|
||||
++ lib.optionals (hasFeature "gr-vocoder" features) [
|
||||
++ lib.optionals (hasFeature "gr-vocoder") [
|
||||
"-DLIBCODEC2_LIBRARIES=${codec2}/lib/libcodec2.so"
|
||||
"-DLIBCODEC2_INCLUDE_DIR=${codec2}/include"
|
||||
"-DLIBGSM_LIBRARIES=${gsm}/lib/libgsm.so"
|
||||
"-DLIBGSM_INCLUDE_DIR=${gsm}/include/gsm"
|
||||
]
|
||||
++ lib.optionals (hasFeature "volk" features && volk != null) [
|
||||
++ lib.optionals (hasFeature "volk" && volk != null) [
|
||||
"-DENABLE_INTERNAL_VOLK=OFF"
|
||||
]
|
||||
;
|
||||
stripDebugList = shared.stripDebugList
|
||||
# gr-fcd feature was dropped in 3.8
|
||||
++ lib.optionals (hasFeature "gr-fcd" features) [ "share/gnuradio/examples/fcd" ]
|
||||
++ lib.optionals (hasFeature "gr-fcd") [ "share/gnuradio/examples/fcd" ]
|
||||
;
|
||||
preConfigure = ""
|
||||
# wxgui and pygtk are not looked up properly, so we force them to be
|
||||
# detected as found, if they are requested by the `features` attrset.
|
||||
+ lib.optionalString (hasFeature "gr-wxgui" features) ''
|
||||
+ lib.optionalString (hasFeature "gr-wxgui") ''
|
||||
sed -i 's/.*wx\.version.*/set(WX_FOUND TRUE)/g' gr-wxgui/CMakeLists.txt
|
||||
''
|
||||
+ lib.optionalString (hasFeature "gnuradio-companion" features) ''
|
||||
+ lib.optionalString (hasFeature "gnuradio-companion") ''
|
||||
sed -i 's/.*pygtk_version.*/set(PYGTK_FOUND TRUE)/g' grc/CMakeLists.txt
|
||||
''
|
||||
;
|
||||
|
@ -65,7 +65,7 @@ let
|
||||
]
|
||||
# when gr-qtgui is disabled, icu needs to be included, otherwise
|
||||
# building with boost 1.7x fails
|
||||
++ lib.optionals (!(hasFeature "gr-qtgui" features)) [ icu ];
|
||||
++ lib.optionals (!(hasFeature "gr-qtgui")) [ icu ];
|
||||
pythonNative = with python.pkgs; [
|
||||
Mako
|
||||
six
|
||||
@ -233,9 +233,9 @@ stdenv.mkDerivation rec {
|
||||
passthru = shared.passthru // {
|
||||
# Deps that are potentially overriden and are used inside GR plugins - the same version must
|
||||
inherit boost volk;
|
||||
} // lib.optionalAttrs (hasFeature "gr-uhd" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gr-uhd") {
|
||||
inherit uhd;
|
||||
} // lib.optionalAttrs (hasFeature "gr-qtgui" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gr-qtgui") {
|
||||
inherit (libsForQt5) qwt;
|
||||
};
|
||||
cmakeFlags = shared.cmakeFlags
|
||||
@ -246,7 +246,7 @@ stdenv.mkDerivation rec {
|
||||
#
|
||||
# NOTE: qradiolink needs libcodec2 to be detected in
|
||||
# order to build, see https://github.com/qradiolink/qradiolink/issues/67
|
||||
++ lib.optionals (hasFeature "gr-vocoder" features) [
|
||||
++ lib.optionals (hasFeature "gr-vocoder") [
|
||||
"-DLIBCODEC2_FOUND=TRUE"
|
||||
"-DLIBCODEC2_LIBRARIES=${codec2}/lib/libcodec2.so"
|
||||
"-DLIBCODEC2_INCLUDE_DIRS=${codec2}/include"
|
||||
@ -255,7 +255,7 @@ stdenv.mkDerivation rec {
|
||||
"-DLIBGSM_LIBRARIES=${gsm}/lib/libgsm.so"
|
||||
"-DLIBGSM_INCLUDE_DIRS=${gsm}/include/gsm"
|
||||
]
|
||||
++ lib.optionals (hasFeature "volk" features && volk != null) [
|
||||
++ lib.optionals (hasFeature "volk" && volk != null) [
|
||||
"-DENABLE_INTERNAL_VOLK=OFF"
|
||||
]
|
||||
;
|
||||
@ -263,7 +263,7 @@ stdenv.mkDerivation rec {
|
||||
postInstall = shared.postInstall
|
||||
# This is the only python reference worth removing, if needed (3.7 doesn't
|
||||
# set that reference).
|
||||
+ lib.optionalString (!hasFeature "python-support" features) ''
|
||||
+ lib.optionalString (!hasFeature "python-support") ''
|
||||
${removeReferencesTo}/bin/remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake
|
||||
''
|
||||
;
|
||||
|
@ -69,7 +69,7 @@ let
|
||||
]
|
||||
# when gr-qtgui is disabled, icu needs to be included, otherwise
|
||||
# building with boost 1.7x fails
|
||||
++ lib.optionals (!(hasFeature "gr-qtgui" features)) [ icu ];
|
||||
++ lib.optionals (!(hasFeature "gr-qtgui")) [ icu ];
|
||||
pythonNative = with python.pkgs; [
|
||||
Mako
|
||||
six
|
||||
@ -257,15 +257,15 @@ stdenv.mkDerivation rec {
|
||||
passthru = shared.passthru // {
|
||||
# Deps that are potentially overriden and are used inside GR plugins - the same version must
|
||||
inherit boost volk;
|
||||
} // lib.optionalAttrs (hasFeature "gr-uhd" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gr-uhd") {
|
||||
inherit uhd;
|
||||
} // lib.optionalAttrs (hasFeature "gr-qtgui" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gr-qtgui") {
|
||||
inherit (libsForQt5) qwt;
|
||||
};
|
||||
|
||||
postInstall = shared.postInstall
|
||||
# This is the only python reference worth removing, if needed.
|
||||
+ lib.optionalString (!hasFeature "python-support" features) ''
|
||||
+ lib.optionalString (!hasFeature "python-support") ''
|
||||
${removeReferencesTo}/bin/remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake
|
||||
${removeReferencesTo}/bin/remove-references-to -t ${python} $(readlink -f $out/lib/libgnuradio-runtime.so)
|
||||
${removeReferencesTo}/bin/remove-references-to -t ${python.pkgs.pybind11} $out/lib/cmake/gnuradio/gnuradio-runtimeTargets.cmake
|
||||
|
@ -31,7 +31,7 @@ rec {
|
||||
;
|
||||
# Check if a feature is enabled, while defaulting to true if feat is not
|
||||
# specified.
|
||||
hasFeature = feat: features: (
|
||||
hasFeature = feat: (
|
||||
if builtins.hasAttr feat features then
|
||||
features.${feat}
|
||||
else
|
||||
@ -39,7 +39,7 @@ rec {
|
||||
);
|
||||
nativeBuildInputs = lib.flatten (lib.mapAttrsToList (
|
||||
feat: info: (
|
||||
if hasFeature feat features then
|
||||
if hasFeature feat then
|
||||
(if builtins.hasAttr "native" info then info.native else []) ++
|
||||
(if builtins.hasAttr "pythonNative" info then info.pythonNative else [])
|
||||
else
|
||||
@ -48,7 +48,7 @@ rec {
|
||||
) featuresInfo);
|
||||
buildInputs = lib.flatten (lib.mapAttrsToList (
|
||||
feat: info: (
|
||||
if hasFeature feat features then
|
||||
if hasFeature feat then
|
||||
(if builtins.hasAttr "runtime" info then info.runtime else []) ++
|
||||
(if builtins.hasAttr "pythonRuntime" info then info.pythonRuntime else [])
|
||||
else
|
||||
@ -63,7 +63,7 @@ rec {
|
||||
# satisfied, let only our cmakeFlags decide.
|
||||
"-DENABLE_DEFAULT=OFF"
|
||||
else
|
||||
if hasFeature feat features then
|
||||
if hasFeature feat then
|
||||
"-DENABLE_${info.cmakeEnableFlag}=ON"
|
||||
else
|
||||
"-DENABLE_${info.cmakeEnableFlag}=OFF"
|
||||
@ -75,17 +75,17 @@ rec {
|
||||
stdenv.cc.cc
|
||||
]
|
||||
# If python-support is disabled, we probably don't want it referenced
|
||||
++ lib.optionals (!hasFeature "python-support" features) [ python ]
|
||||
++ lib.optionals (!hasFeature "python-support") [ python ]
|
||||
;
|
||||
# Gcc references from examples
|
||||
stripDebugList = [ "lib" "bin" ]
|
||||
++ lib.optionals (hasFeature "gr-audio" features) [ "share/gnuradio/examples/audio" ]
|
||||
++ lib.optionals (hasFeature "gr-uhd" features) [ "share/gnuradio/examples/uhd" ]
|
||||
++ lib.optionals (hasFeature "gr-qtgui" features) [ "share/gnuradio/examples/qt-gui" ]
|
||||
++ lib.optionals (hasFeature "gr-audio") [ "share/gnuradio/examples/audio" ]
|
||||
++ lib.optionals (hasFeature "gr-uhd") [ "share/gnuradio/examples/uhd" ]
|
||||
++ lib.optionals (hasFeature "gr-qtgui") [ "share/gnuradio/examples/qt-gui" ]
|
||||
;
|
||||
postInstall = ""
|
||||
# Gcc references
|
||||
+ lib.optionalString (hasFeature "gnuradio-runtime" features) ''
|
||||
+ lib.optionalString (hasFeature "gnuradio-runtime") ''
|
||||
${removeReferencesTo}/bin/remove-references-to -t ${stdenv.cc} $(readlink -f $out/lib/libgnuradio-runtime.so)
|
||||
''
|
||||
;
|
||||
@ -101,9 +101,9 @@ rec {
|
||||
featuresInfo
|
||||
python
|
||||
;
|
||||
} // lib.optionalAttrs (hasFeature "gr-qtgui" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gr-qtgui") {
|
||||
inherit qt;
|
||||
} // lib.optionalAttrs (hasFeature "gnuradio-companion" features) {
|
||||
} // lib.optionalAttrs (hasFeature "gnuradio-companion") {
|
||||
inherit gtk;
|
||||
};
|
||||
# Wrapping is done with an external wrapper
|
||||
|
@ -41,7 +41,7 @@ let
|
||||
++ (builtins.map unwrapped.python.pkgs.toPythonModule extraPackages)
|
||||
++ lib.flatten (lib.mapAttrsToList (
|
||||
feat: info: (
|
||||
if unwrapped.hasFeature feat unwrapped.features then
|
||||
if unwrapped.hasFeature feat then
|
||||
(if builtins.hasAttr "pythonRuntime" info then info.pythonRuntime else [])
|
||||
else
|
||||
[]
|
||||
@ -55,8 +55,8 @@ let
|
||||
]
|
||||
# Emulating wrapGAppsHook & wrapQtAppsHook working together
|
||||
++ lib.optionals (
|
||||
(unwrapped.hasFeature "gnuradio-companion" unwrapped.features)
|
||||
|| (unwrapped.hasFeature "gr-qtgui" unwrapped.features)
|
||||
(unwrapped.hasFeature "gnuradio-companion")
|
||||
|| (unwrapped.hasFeature "gr-qtgui")
|
||||
) [
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "$out/share"
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "$out/share/gsettings-schemas/${name}"
|
||||
@ -66,7 +66,7 @@ let
|
||||
# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1764890.html
|
||||
"--prefix" "PATH" ":" "${lib.getBin glib}/bin"
|
||||
]
|
||||
++ lib.optionals (unwrapped.hasFeature "gnuradio-companion" unwrapped.features) [
|
||||
++ lib.optionals (unwrapped.hasFeature "gnuradio-companion") [
|
||||
"--set" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.moduleDir}.cache"
|
||||
"--prefix" "GIO_EXTRA_MODULES" ":" "${lib.getLib dconf}/lib/gio/modules"
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk}/share"
|
||||
@ -89,7 +89,7 @@ let
|
||||
++ lib.optionals (extraPackages != []) [
|
||||
"--prefix" "GRC_BLOCKS_PATH" ":" "${lib.makeSearchPath "share/gnuradio/grc/blocks" extraPackages}"
|
||||
]
|
||||
++ lib.optionals (unwrapped.hasFeature "gr-qtgui" unwrapped.features)
|
||||
++ lib.optionals (unwrapped.hasFeature "gr-qtgui")
|
||||
# 3.7 builds with qt4
|
||||
(if lib.versionAtLeast unwrapped.versionAttr.major "3.8" then
|
||||
[
|
||||
|
@ -52,11 +52,11 @@ in mkDerivation {
|
||||
libbladeRF
|
||||
rtl-sdr
|
||||
soapysdr-with-plugins
|
||||
] ++ lib.optional (gnuradio.hasFeature "gr-uhd" gnuradio.features) [
|
||||
] ++ lib.optionals (gnuradio.hasFeature "gr-uhd") [
|
||||
uhd
|
||||
];
|
||||
cmakeFlags = [
|
||||
(if (gnuradio.hasFeature "python-support" gnuradio.features) then
|
||||
(if (gnuradio.hasFeature "python-support") then
|
||||
"-DENABLE_PYTHON=ON"
|
||||
else
|
||||
"-DENABLE_PYTHON=OFF"
|
||||
@ -66,7 +66,7 @@ in mkDerivation {
|
||||
cmake
|
||||
pkg-config
|
||||
swig
|
||||
] ++ lib.optionals (gnuradio.hasFeature "python-support" gnuradio.features) [
|
||||
] ++ lib.optionals (gnuradio.hasFeature "python-support") [
|
||||
(if (gnuradio.versionAttr.major == "3.7") then
|
||||
python.pkgs.cheetah
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user