Merge pull request #253847 from doronbehar/pkg/soapysdr

soapysdr: cleanup expression; gnuradio: add support for soapysdr plugins in the wrapper
This commit is contained in:
Franz Pletz 2023-09-13 12:34:58 +02:00 committed by GitHub
commit a2f7126deb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 54 deletions

View file

@ -28,6 +28,27 @@
, extraPackages ? []
# For Adding additional python packaages
, extraPythonPackages ? []
, soapysdr # For it's passthru.searchPath
# soapysdr plugins we add by default. Ideally, we should have a
# soapysdrPackages = soapysdr.pkgs attribute set, but until now this wasn't
# crucial.
, soapyairspy
, soapyaudio
, soapybladerf
, soapyhackrf
, soapyremote
, soapyrtlsdr
, soapyuhd
# For adding / changing soapysdr packages, like soapsdr-with-plugins does
, extraSoapySdrPackages ? [
soapyairspy
soapyaudio
soapybladerf
soapyhackrf
soapyremote
soapyrtlsdr
soapyuhd
]
# Allow to add whatever you want to the wrapper
, extraMakeWrapperArgs ? []
}:
@ -87,6 +108,10 @@ let
++ lib.optionals (extraPackages != []) [
"--prefix" "GRC_BLOCKS_PATH" ":" "${lib.makeSearchPath "share/gnuradio/grc/blocks" extraPackages}"
]
++ lib.optionals (extraSoapySdrPackages != []) [
"--prefix" "SOAPY_SDR_PLUGIN_PATH" ":" "${lib.makeSearchPath
soapysdr.passthru.searchPath extraSoapySdrPackages}"
]
++ lib.optionals (unwrapped.hasFeature "gr-qtgui")
# 3.7 builds with qt4
(if lib.versionAtLeast unwrapped.versionAttr.major "3.8" then

View file

@ -1,66 +1,83 @@
{ stdenv, lib, lndir, makeWrapper
, fetchFromGitHub, cmake
, libusb-compat-0_1, pkg-config
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, cmake
, pkg-config
, makeWrapper
, libusb-compat-0_1
, ncurses
, usePython ? false
, python ? null
, ncurses, swig2
, extraPackages ? []
, testers
, swig2
, extraPackages ? [ ]
, buildPackages
, testers
}:
let
version = "0.8.1";
modulesVersion = with lib; versions.major version + "." + versions.minor version;
modulesPath = "lib/SoapySDR/modules" + modulesVersion;
extraPackagesSearchPath = lib.makeSearchPath modulesPath extraPackages;
in stdenv.mkDerivation (finalAttrs: {
stdenv.mkDerivation (finalAttrs: {
pname = "soapysdr";
inherit version;
version = "0.8.1";
src = fetchFromGitHub {
owner = "pothosware";
repo = "SoapySDR";
rev = "soapy-sdr-${version}";
rev = "soapy-sdr-${finalAttrs.version}";
sha256 = "19f2x0pkxvf9figa0pl6xqlcz8fblvqb19mcnj632p0l8vk6qdv2";
};
patches = [
# see https://github.com/pothosware/SoapySDR/issues/352 for upstream issue
./fix-pkgconfig.patch
# Fix for https://github.com/pothosware/SoapySDR/issues/352
(fetchpatch {
url = "https://github.com/pothosware/SoapySDR/commit/10c05b3e52caaa421147d6b4623eccd3fc3be3f4.patch";
hash = "sha256-D7so6NSZiU6SXbzns04Q4RjSZW0FJ+MYobvvVpVMjws=";
})
];
nativeBuildInputs = [ cmake makeWrapper pkg-config ];
buildInputs = [ libusb-compat-0_1 ncurses ]
++ lib.optionals usePython [ python swig2 ];
nativeBuildInputs = [
cmake
pkg-config
makeWrapper
];
buildInputs = [
libusb-compat-0_1
ncurses
] ++ lib.optionals usePython [
python
swig2
];
propagatedBuildInputs = lib.optional usePython python.pkgs.numpy;
propagatedBuildInputs = lib.optionals usePython [
python.pkgs.numpy
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
] ++ lib.optional usePython "-DUSE_PYTHON_CONFIG=ON";
] ++ lib.optionals usePython [
"-DUSE_PYTHON_CONFIG=ON"
];
# https://github.com/pothosware/SoapySDR/issues/352
postPatch = ''
substituteInPlace lib/SoapySDR.in.pc \
--replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
--replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
'';
postFixup = lib.optionalString (lib.length extraPackages != 0) ''
postFixup = lib.optionalString (extraPackages != [ ]) (
# Join all plugins via symlinking
for i in ${toString extraPackages}; do
${buildPackages.xorg.lndir}/bin/lndir -silent $i $out
done
# Needed for at least the remote plugin server
for file in $out/bin/*; do
wrapProgram "$file" --prefix SOAPY_SDR_PLUGIN_PATH : ${lib.escapeShellArg extraPackagesSearchPath}
done
'';
lib.pipe extraPackages [
(map (pkg: ''
${buildPackages.xorg.lndir}/bin/lndir -silent ${pkg} $out
''))
lib.concatStrings
] + ''
# Needed for at least the remote plugin server
for file in $out/bin/*; do
wrapProgram "$file" --prefix SOAPY_SDR_PLUGIN_PATH : ${lib.escapeShellArg (
lib.makeSearchPath finalAttrs.passthru.searchPath extraPackages
)}
done
''
);
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
passthru = {
tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
searchPath = "lib/SoapySDR/modules${lib.versions.majorMinor finalAttrs.version}";
};
meta = with lib; {
homepage = "https://github.com/pothosware/SoapySDR";

View file

@ -1,14 +0,0 @@
diff --git a/lib/SoapySDR.in.pc b/lib/SoapySDR.in.pc
index a1ca698..fd2f4c0 100644
--- a/lib/SoapySDR.in.pc
+++ b/lib/SoapySDR.in.pc
@@ -1,7 +1,5 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: Soapy SDR
Description: Vendor and platform neutral SDR interface library.