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

uhd: fix Darwin build (fixes also Gnuradio build) (#481933)

parents d362a816 3cd94035
Loading
Loading
Loading
Loading
+14 −21
Original line number Diff line number Diff line
@@ -310,25 +310,18 @@ stdenv.mkDerivation (
        # Not accepted upstream, see https://github.com/gnuradio/gnuradio/pull/5227
        ./modtool-newmod-permissions.patch
      ];
      passthru =
        shared.passthru
        // {
      passthru = shared.passthru // {
        # Deps that are potentially overridden and are used inside GR plugins - the same version must
        inherit
          uhd
          boost
          volk
          libiio
          libad9361
          ;
        # Used by many gnuradio modules, the same attribute is present in
        # previous gnuradio versions where there it's log4cpp.
        logLib = spdlog;
        }
        // lib.optionalAttrs (hasFeature "gr-uhd") {
          inherit uhd;
        }
        // lib.optionalAttrs (hasFeature "gr-pdu") {
          inherit libiio libad9361;
        }
        // lib.optionalAttrs (hasFeature "gr-qtgui") {
        inherit (libsForQt5) qwt;
      };

+61 −70
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@
    soapyplutosdr
    soapyremote
    soapyrtlsdr
  ]
  ++ lib.optionals (unwrapped.hasFeature "gr-uhd") [
    soapyuhd
  ],
  # Allow to add whatever you want to the wrapper
@@ -62,10 +64,14 @@ let
  pythonPkgs =
    extraPythonPackages
    ++ [ (unwrapped.python.pkgs.toPythonModule unwrapped) ]
    ++ unwrapped.passthru.uhd.pythonPath
    ++ lib.optionals (unwrapped.hasFeature "gr-uhd") (
      unwrapped.passthru.uhd.pythonPath
      # Check if uhd was built with python support, which means it should
      # be added as a python module too.
      ++ lib.optionals (unwrapped.passthru.uhd.pythonPath != [ ]) [
        (unwrapped.python.pkgs.toPythonModule unwrapped.passthru.uhd)
      ]
    )
    # Add the extraPackages as python modules as well
    ++ (map unwrapped.python.pkgs.toPythonModule extraPackages)
    ++ lib.flatten (
@@ -81,12 +87,8 @@ let
  pname = unwrapped.pname + "-wrapped";
  inherit (unwrapped) outputs version;
  makeWrapperArgs = builtins.concatStringsSep " " (
    [
    ]
    # Emulating wrapGAppsHook3 & wrapQtAppsHook working together
    ++
      lib.optionals ((unwrapped.hasFeature "gnuradio-companion") || (unwrapped.hasFeature "gr-qtgui"))
        [
    lib.optionals ((unwrapped.hasFeature "gnuradio-companion") || (unwrapped.hasFeature "gr-qtgui")) [
      "--prefix"
      "XDG_DATA_DIRS"
      ":"
@@ -157,12 +159,7 @@ let
      ":"
      "${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
            [
    ++ lib.optionals (unwrapped.hasFeature "gr-qtgui") [
      "--prefix"
      "QT_PLUGIN_PATH"
      ":"
@@ -190,12 +187,6 @@ let
        )
      )}"
    ]
          else
            # Add here qt4 related environment for 3.7?
            [

            ]
        )
    ++ extraMakeWrapperArgs
  );

+2 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ stdenv.mkDerivation (finalAttrs: {
    # Tests that hang up in the Darwin sandbox
    "SecurityTest"
    "SecurityFromBufferTest"
    "python_test"
    "PythonThriftTNonblockingServer"

    # fails on hydra, passes locally
    "concurrency_test"
@@ -95,6 +95,7 @@ stdenv.mkDerivation (finalAttrs: {
    "TInterruptTest"
    "TServerIntegrationTest"
    "processor"
    "processor_test"
    "TNonblockingServerTest"
    "TNonblockingSSLServerTest"
    "StressTest"
+45 −37
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  substitute,
  fetchpatch,
  llvmPackages_20,
  fetchurl,
  fetchFromGitHub,
  cmake,
@@ -36,15 +35,23 @@

let
  inherit (lib) optionals cmakeBool;
  stdenv' = (
    # Fix a compilation issue on Darwin, that upstream is aware of:
    # https://github.com/EttusResearch/uhd/issues/881
    if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then
      llvmPackages_20.stdenv
    else
      stdenv
  );
in

stdenv.mkDerivation (finalAttrs: {
stdenv'.mkDerivation (finalAttrs: {
  pname = "uhd";
  # NOTE: Use the following command to update the package, and the uhdImageSrc attribute:
  #
  #     nix-shell maintainers/scripts/update.nix --argstr package uhd --argstr commit true
  #
  version = "4.9.0.0";
  version = "4.9.0.1";

  outputs = [
    "out"
@@ -57,15 +64,18 @@ stdenv.mkDerivation (finalAttrs: {
    rev = "v${finalAttrs.version}";
    # The updateScript relies on the `src` using `hash`, and not `sha256. To
    # update the correct hash for the `src` vs the `uhdImagesSrc`
    hash = "sha256-XA/ADJ0HjD6DxqFTVMwFa7tRgM56mHAEL+a0paWxKyM=";
    hash = "sha256-AOZYCmkgsM09YORW7dVsPAwecXNZQOxOscJnVOlMoP0=";
  };
  # Firmware images are downloaded (pre-built) from the respective release on Github
  uhdImagesSrc = fetchurl {
    url = "https://github.com/EttusResearch/uhd/releases/download/v${finalAttrs.version}/uhd-images_${finalAttrs.version}.tar.xz";
    # Please don't convert this to a hash, in base64, see comment near src's
    # hash.
    sha256 = "194gsmvn7gmwj7b1lw9sq0d0y0babbd0q1229qbb3qjc6f6m0p0y";
    sha256 = "15ahcxb7hsylvdzzv0q0shd3wqm7p2y4kzbqk85cvsxbdklxhsvn";
  };
  inherit (finalAttrs.finalPackage.passthru) pythonPath;
  passthru = {
    runtimePython = python3.withPackages (ps: finalAttrs.finalPackage.passthru.pythonPath);
    # This are the minimum required Python dependencies, this attribute might
    # be useful if you want to build a development environment with a python
    # interpreter able to import the uhd module.
@@ -90,8 +100,6 @@ stdenv.mkDerivation (finalAttrs: {
          python3.pkgs.pyroute2
        */
      ];
  passthru = {
    runtimePython = python3.withPackages (ps: finalAttrs.pythonPath);
    updateScript = [
      ./update.sh
      # Pass it this file name as argument
@@ -100,11 +108,11 @@ stdenv.mkDerivation (finalAttrs: {
  };

  cmakeFlags = [
    "-DENABLE_LIBUHD=ON"
    "-DENABLE_USB=ON"
    (cmakeBool "ENABLE_LIBUHD" true)
    (cmakeBool "ENABLE_USB" true)
    # Regardless of doCheck, we want to build the tests to help us gain
    # confident that the package is OK.
    "-DENABLE_TESTS=ON"
    (cmakeBool "ENABLE_TESTS" true)
    (cmakeBool "ENABLE_EXAMPLES" enableExamples)
    (cmakeBool "ENABLE_UTILS" enableUtils)
    (cmakeBool "ENABLE_C_API" enableCApi)
@@ -148,7 +156,7 @@ stdenv.mkDerivation (finalAttrs: {
    # ABI differences GCC 7.1
    # /nix/store/wd6r25miqbk9ia53pp669gn4wrg9n9cj-gcc-7.3.0/include/c++/7.3.0/bits/vector.tcc:394:7: note: parameter passing for argument of type 'std::vector<uhd::range_t>::iterator {aka __gnu_cxx::__normal_iterator<uhd::range_t*, std::vector<uhd::range_t> >}' changed in GCC 7.1
  ]
  ++ optionals stdenv.hostPlatform.isAarch32 [
  ++ optionals stdenv'.hostPlatform.isAarch32 [
    "-DCMAKE_CXX_FLAGS=-Wno-psabi"
  ];

@@ -181,7 +189,7 @@ stdenv.mkDerivation (finalAttrs: {
  ];

  # many tests fails on darwin, according to ofborg
  doCheck = !stdenv.hostPlatform.isDarwin;
  doCheck = !stdenv'.hostPlatform.isDarwin;

  doInstallCheck = true;

@@ -192,7 +200,7 @@ stdenv.mkDerivation (finalAttrs: {
    "installFirmware"
    "removeInstalledTests"
  ]
  ++ optionals (enableUtils && stdenv.hostPlatform.isLinux) [
  ++ optionals (enableUtils && stdenv'.hostPlatform.isLinux) [
    "moveUdevRules"
  ];