gnuradio: fix cross compilation (#434298)

This commit is contained in:
Doron Behar 2025-08-17 01:04:23 +03:00 committed by GitHub
commit 4ffe55e3a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View File

@ -67,7 +67,7 @@ let
# when gr-qtgui is disabled, icu needs to be included, otherwise # when gr-qtgui is disabled, icu needs to be included, otherwise
# building with boost 1.7x fails # building with boost 1.7x fails
++ lib.optionals (!(hasFeature "gr-qtgui")) [ icu ]; ++ lib.optionals (!(hasFeature "gr-qtgui")) [ icu ];
pythonNative = with python.pkgs; [ pythonNative = with python.pythonOnBuildForHost.pkgs; [
mako mako
six six
]; ];
@ -337,6 +337,8 @@ stdenv.mkDerivation (
# This is the only python reference worth removing, if needed. # This is the only python reference worth removing, if needed.
+ lib.optionalString (!hasFeature "python-support") '' + lib.optionalString (!hasFeature "python-support") ''
remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake remove-references-to -t ${python} $out/lib/cmake/gnuradio/GnuradioConfig.cmake
''
+ lib.optionalString (!hasFeature "python-support" && hasFeature "gnuradio-runtime") ''
remove-references-to -t ${python} $(readlink -f $out/lib/libgnuradio-runtime${stdenv.hostPlatform.extensions.sharedLibrary}) remove-references-to -t ${python} $(readlink -f $out/lib/libgnuradio-runtime${stdenv.hostPlatform.extensions.sharedLibrary})
remove-references-to -t ${python.pkgs.pybind11} $out/lib/cmake/gnuradio/gnuradio-runtimeTargets.cmake remove-references-to -t ${python.pkgs.pybind11} $out/lib/cmake/gnuradio/gnuradio-runtimeTargets.cmake
''; '';

View File

@ -24,6 +24,7 @@ let
minor = builtins.elemAt (lib.splitVersion version) 2; minor = builtins.elemAt (lib.splitVersion version) 2;
patch = builtins.elemAt (lib.splitVersion version) 3; patch = builtins.elemAt (lib.splitVersion version) 3;
}; };
cross = stdenv.hostPlatform != stdenv.buildPlatform;
in in
{ {
src = src =
@ -53,26 +54,30 @@ in
feat: info: feat: info:
(lib.optionals (hasFeature feat) ( (lib.optionals (hasFeature feat) (
(lib.optionals (builtins.hasAttr "runtime" info) info.runtime) (lib.optionals (builtins.hasAttr "runtime" info) info.runtime)
++ (lib.optionals (builtins.hasAttr "pythonRuntime" info) info.pythonRuntime) ++ (lib.optionals (
builtins.hasAttr "pythonRuntime" info && hasFeature "python-support"
) info.pythonRuntime)
)) ))
) featuresInfo ) featuresInfo
); );
cmakeFlags = lib.mapAttrsToList ( cmakeFlags = [
# https://pybind11.readthedocs.io/en/stable/changelog.html#version-2-13-0-june-25-2024
(lib.cmakeBool "CMAKE_CROSSCOMPILING" cross)
(lib.cmakeBool "PYBIND11_USE_CROSSCOMPILING" (cross && hasFeature "gnuradio-runtime"))
]
++ lib.mapAttrsToList (
feat: info: feat: info:
( (
if feat == "basic" then if feat == "basic" then
# Abuse this unavoidable "iteration" to set this flag which we want as # Abuse this unavoidable "iteration" to set this flag which we want as
# well - it means: Don't turn on features just because their deps are # well - it means: Don't turn on features just because their deps are
# satisfied, let only our cmakeFlags decide. # satisfied, let only our cmakeFlags decide.
"-DENABLE_DEFAULT=OFF" (lib.cmakeBool "ENABLE_DEFAULT" false)
else if hasFeature feat then
"-DENABLE_${info.cmakeEnableFlag}=ON"
else else
"-DENABLE_${info.cmakeEnableFlag}=OFF" (lib.cmakeBool "ENABLE_${info.cmakeEnableFlag}" (hasFeature feat))
) )
) featuresInfo; ) featuresInfo;
disallowedReferences = [ disallowedReferences = [
# TODO: Should this be conditional?
stdenv.cc stdenv.cc
stdenv.cc.cc stdenv.cc.cc
] ]