Unverified Commit 4ffe55e3 authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

gnuradio: fix cross compilation (#434298)

parents 9e1616ff 6874ffdf
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ let
      # when gr-qtgui is disabled, icu needs to be included, otherwise
      # building with boost 1.7x fails
      ++ lib.optionals (!(hasFeature "gr-qtgui")) [ icu ];
      pythonNative = with python.pkgs; [
      pythonNative = with python.pythonOnBuildForHost.pkgs; [
        mako
        six
      ];
@@ -337,6 +337,8 @@ stdenv.mkDerivation (
        # This is the only python reference worth removing, if needed.
        + lib.optionalString (!hasFeature "python-support") ''
          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.pkgs.pybind11} $out/lib/cmake/gnuradio/gnuradio-runtimeTargets.cmake
        '';
+12 −7
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ let
    minor = builtins.elemAt (lib.splitVersion version) 2;
    patch = builtins.elemAt (lib.splitVersion version) 3;
  };
  cross = stdenv.hostPlatform != stdenv.buildPlatform;
in
{
  src =
@@ -53,26 +54,30 @@ in
      feat: info:
      (lib.optionals (hasFeature feat) (
        (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
  );
  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:
    (
      if feat == "basic" then
        # 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
        # satisfied, let only our cmakeFlags decide.
        "-DENABLE_DEFAULT=OFF"
      else if hasFeature feat then
        "-DENABLE_${info.cmakeEnableFlag}=ON"
        (lib.cmakeBool "ENABLE_DEFAULT" false)
      else
        "-DENABLE_${info.cmakeEnableFlag}=OFF"
        (lib.cmakeBool "ENABLE_${info.cmakeEnableFlag}" (hasFeature feat))
    )
  ) featuresInfo;
  disallowedReferences = [
    # TODO: Should this be conditional?
    stdenv.cc
    stdenv.cc.cc
  ]