Unverified Commit c898ce22 authored by Will Fancher's avatar Will Fancher Committed by GitHub
Browse files

Merge pull request #285792 from ElvishJerricco/mongodb-cross

mongodb: Cleanups and fix cross compilation.
parents e72d6a1d 9bfa405a
Loading
Loading
Loading
Loading
+22 −39
Original line number Diff line number Diff line
{ lib
, stdenv
, fetchurl
, scons_3_1_2
, buildPackages
, boost
, gperftools
, pcre-cpp
@@ -32,39 +32,20 @@ with lib;
}:

let
  variants =
    if versionAtLeast version "6.0"
    then rec {
  scons = buildPackages.scons;
  python = scons.python.withPackages (ps: with ps; [
    pyyaml
    cheetah3
    psutil
    setuptools
  ] ++ lib.optionals (versionAtLeast version "6.0") [
    packaging
    pymongo
  ]);

      scons = scons_3_1_2;

      mozjsVersion = "60";
      mozjsReplace = "defined(HAVE___SINCOS)";

    }
    else rec {
      python = scons.python.withPackages (ps: with ps; [
        pyyaml
        cheetah3
        psutil
        setuptools
      ]);

      scons = scons_3_1_2;

  mozjsVersion = "60";
  mozjsReplace = "defined(HAVE___SINCOS)";

    };

  system-libraries = [
    "boost"
    "pcre"
@@ -87,8 +68,10 @@ in stdenv.mkDerivation rec {
    inherit sha256;
  };

  nativeBuildInputs = [ variants.scons ]
                      ++ lib.optionals (versionAtLeast version "4.4") [ xz ];
  nativeBuildInputs = [
    scons
    python
  ] ++ lib.optional stdenv.isLinux net-snmp;

  buildInputs = [
    boost
@@ -99,13 +82,12 @@ in stdenv.mkDerivation rec {
    openssl
    openldap
    pcre-cpp
    variants.python
    sasl
    snappy
    zlib
  ] ++ lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ]
  ++ lib.optionals stdenv.isLinux [ net-snmp ];

  ++ lib.optional stdenv.isLinux net-snmp
  ++ lib.optionals (versionAtLeast version "4.4") [ xz ];

  # MongoDB keeps track of its build parameters, which tricks nix into
  # keeping dependencies to build inputs in the final output.
@@ -127,7 +109,7 @@ in stdenv.mkDerivation rec {
    # remove -march overriding, we know better.
    sed -i 's/env.Append.*-march=.*$/pass/' SConstruct
  '' + lib.optionalString (stdenv.isDarwin && versionOlder version "6.0") ''
    substituteInPlace src/third_party/mozjs-${variants.mozjsVersion}/extract/js/src/jsmath.cpp --replace '${variants.mozjsReplace}' 0
    substituteInPlace src/third_party/mozjs-${mozjsVersion}/extract/js/src/jsmath.cpp --replace '${mozjsReplace}' 0
  '' + lib.optionalString (stdenv.isDarwin && versionOlder version "3.6") ''
    substituteInPlace src/third_party/s2/s1angle.cc --replace drem remainder
    substituteInPlace src/third_party/s2/s1interval.cc --replace drem remainder
@@ -162,6 +144,7 @@ in stdenv.mkDerivation rec {
  preBuild = ''
    sconsFlags+=" CC=$CC"
    sconsFlags+=" CXX=$CXX"
    sconsFlags+=" AR=$AR"
  '' + optionalString stdenv.isAarch64 ''
    sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
  '';