lol

Merge pull request #33188 from obsidiansystems/clean-boost

boost: Clean, reducing duplication

authored by

John Ericson and committed by
GitHub
da486038 5920579a

+83 -125
+29 -29
pkgs/development/libraries/boost/1.59.nix
··· 8 8 sha256 = "1jj1aai5rdmd72g90a3pd8sw9vi32zad46xv5av8fhnr48ir6ykj"; 9 9 }; 10 10 11 - patches = if stdenv.isCygwin then [ 12 - ./cygwin-fedora-boost-1.50.0-fix-non-utf8-files.patch 13 - ./cygwin-fedora-boost-1.50.0-pool.patch 14 - ./cygwin-fedora-boost-1.57.0-mpl-print.patch 15 - ./cygwin-fedora-boost-1.57.0-spirit-unused_typedef.patch 16 - ./cygwin-fedora-boost-1.54.0-locale-unused_typedef.patch 17 - ./cygwin-fedora-boost-1.54.0-python-unused_typedef.patch 18 - ./cygwin-fedora-boost-1.57.0-pool-test_linking.patch 19 - ./cygwin-fedora-boost-1.54.0-pool-max_chunks_shadow.patch 20 - ./cygwin-fedora-boost-1.57.0-signals2-weak_ptr.patch 21 - ./cygwin-fedora-boost-1.57.0-uuid-comparison.patch 22 - ./cygwin-fedora-boost-1.57.0-move-is_class.patch 23 - ./cygwin-1.40.0-cstdint-cygwin.patch 24 - ./cygwin-1.57.0-asio-cygwin.patch 25 - ./cygwin-1.55.0-asio-MSG_EOR.patch 26 - ./cygwin-1.57.0-config-cygwin.patch 27 - ./cygwin-1.57.0-context-cygwin.patch 28 - ./cygwin-1.57.0-filesystem-cygwin.patch 29 - ./cygwin-1.55.0-interlocked-cygwin.patch 30 - ./cygwin-1.40.0-iostreams-cygwin.patch 31 - ./cygwin-1.57.0-locale-cygwin.patch 32 - ./cygwin-1.57.0-log-cygwin.patch 33 - ./cygwin-1.40.0-python-cygwin.patch 34 - ./cygwin-1.40.0-regex-cygwin.patch 35 - ./cygwin-1.57.0-smart_ptr-cygwin.patch 36 - ./cygwin-1.57.0-system-cygwin.patch 37 - ./cygwin-1.45.0-jam-cygwin.patch 38 - ./cygwin-1.50.0-jam-pep3149.patch 39 - ] else null; 11 + patches = stdenv.lib.optionals stdenv.isCygwin [ 12 + ./cygwin-fedora-boost-1.50.0-fix-non-utf8-files.patch 13 + ./cygwin-fedora-boost-1.50.0-pool.patch 14 + ./cygwin-fedora-boost-1.57.0-mpl-print.patch 15 + ./cygwin-fedora-boost-1.57.0-spirit-unused_typedef.patch 16 + ./cygwin-fedora-boost-1.54.0-locale-unused_typedef.patch 17 + ./cygwin-fedora-boost-1.54.0-python-unused_typedef.patch 18 + ./cygwin-fedora-boost-1.57.0-pool-test_linking.patch 19 + ./cygwin-fedora-boost-1.54.0-pool-max_chunks_shadow.patch 20 + ./cygwin-fedora-boost-1.57.0-signals2-weak_ptr.patch 21 + ./cygwin-fedora-boost-1.57.0-uuid-comparison.patch 22 + ./cygwin-fedora-boost-1.57.0-move-is_class.patch 23 + ./cygwin-1.40.0-cstdint-cygwin.patch 24 + ./cygwin-1.57.0-asio-cygwin.patch 25 + ./cygwin-1.55.0-asio-MSG_EOR.patch 26 + ./cygwin-1.57.0-config-cygwin.patch 27 + ./cygwin-1.57.0-context-cygwin.patch 28 + ./cygwin-1.57.0-filesystem-cygwin.patch 29 + ./cygwin-1.55.0-interlocked-cygwin.patch 30 + ./cygwin-1.40.0-iostreams-cygwin.patch 31 + ./cygwin-1.57.0-locale-cygwin.patch 32 + ./cygwin-1.57.0-log-cygwin.patch 33 + ./cygwin-1.40.0-python-cygwin.patch 34 + ./cygwin-1.40.0-regex-cygwin.patch 35 + ./cygwin-1.57.0-smart_ptr-cygwin.patch 36 + ./cygwin-1.57.0-system-cygwin.patch 37 + ./cygwin-1.45.0-jam-cygwin.patch 38 + ./cygwin-1.50.0-jam-pep3149.patch 39 + ]; 40 40 })
+54 -96
pkgs/development/libraries/boost/generic.nix
··· 1 1 { stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames, libiconv 2 - , buildPlatform, hostPlatform 3 - , toolset ? if stdenv.cc.isClang then "clang" else null 2 + , which 3 + , buildPackages, buildPlatform, hostPlatform 4 + , toolset ? /**/ if stdenv.cc.isClang then "clang" 5 + else if stdenv.cc.isGNU && hostPlatform != buildPlatform then "gcc-cross" 6 + else null 4 7 , enableRelease ? true 5 8 , enableDebug ? false 6 9 , enableSingleThreaded ? false 7 10 , enableMultiThreaded ? true 8 11 , enableShared ? !(hostPlatform.libc == "msvcrt") # problems for now 9 12 , enableStatic ? !enableShared 10 - , enablePIC ? false 11 - , enableExceptions ? false 12 13 , enablePython ? hostPlatform == buildPlatform 13 14 , enableNumpy ? false 14 15 , taggedLayout ? ((enableRelease && enableDebug) || (enableSingleThreaded && enableMultiThreaded) || (enableShared && enableStatic)) 15 - , patches ? null 16 + , patches ? [] 16 17 , mpi ? null 17 18 18 19 # Attributes inherit from specific versions ··· 21 22 }: 22 23 23 24 # We must build at least one type of libraries 24 - assert !enableShared -> enableStatic; 25 + assert enableShared || enableStatic; 25 26 27 + # Python isn't supported when cross-compiling 26 28 assert enablePython -> hostPlatform == buildPlatform; 27 29 assert enableNumpy -> enablePython; 28 30 ··· 46 48 # To avoid library name collisions 47 49 layout = if taggedLayout then "tagged" else "system"; 48 50 49 - cflags = if enablePIC && enableExceptions then 50 - "cflags=\"-fPIC -fexceptions\" cxxflags=-fPIC linkflags=-fPIC" 51 - else if enablePIC then 52 - "cflags=-fPIC cxxflags=-fPIC linkflags=-fPIC" 53 - else if enableExceptions then 54 - "cflags=-fexceptions" 55 - else 56 - ""; 57 - 58 - withToolset = stdenv.lib.optionalString (toolset != null) "--with-toolset=${toolset}"; 59 - 60 - genericB2Flags = [ 51 + b2Args = concatStringsSep " " ([ 61 52 "--includedir=$dev/include" 62 53 "--libdir=$out/lib" 63 54 "-j$NIX_BUILD_CORES" 64 55 "--layout=${layout}" 65 56 "variant=${variant}" 66 57 "threading=${threading}" 67 - ] ++ optional (link != "static") "runtime-link=${runtime-link}" ++ [ 58 + "runtime-link=${runtime-link}" 68 59 "link=${link}" 69 - "${cflags}" 70 - ] ++ optional (variant == "release") "debug-symbols=off" 71 - ++ optional (!enablePython) "--without-python"; 72 - 73 - nativeB2Flags = [ 74 60 "-sEXPAT_INCLUDE=${expat.dev}/include" 75 61 "-sEXPAT_LIBPATH=${expat.out}/lib" 76 - ] ++ optional (toolset != null) "toolset=${toolset}" 77 - ++ optional (mpi != null) "--user-config=user-config.jam"; 78 - nativeB2Args = concatStringsSep " " (genericB2Flags ++ nativeB2Flags); 79 - 80 - crossB2Flags = [ 81 - "-sEXPAT_INCLUDE=${expat.crossDrv}/include" 82 - "-sEXPAT_LIBPATH=${expat.crossDrv}/lib" 83 - "--user-config=user-config.jam" 84 - "toolset=gcc-cross" 85 - ] ++ optionals (hostPlatform.libc == "msvcrt") [ 62 + ] ++ optional (variant == "release") "debug-symbols=off" 63 + ++ optional (toolset != null) "toolset=${toolset}" 64 + ++ optional (mpi != null || hostPlatform != buildPlatform) "--user-config=user-config.jam" 65 + ++ optionals (hostPlatform.libc == "msvcrt") [ 86 66 "target-os=windows" 87 67 "threadapi=win32" 88 68 "binary-format=pe" 89 69 "address-model=${toString hostPlatform.parsed.cpu.bits}" 90 70 "architecture=x86" 91 - ]; 92 - crossB2Args = concatStringsSep " " (genericB2Flags ++ crossB2Flags); 93 - 94 - builder = b2Args: '' 95 - ./b2 ${b2Args} 96 - ''; 97 - 98 - installer = b2Args: '' 99 - # boostbook is needed by some applications 100 - mkdir -p $dev/share/boostbook 101 - cp -a tools/boostbook/{xsl,dtd} $dev/share/boostbook/ 102 - 103 - # Let boost install everything else 104 - ./b2 ${b2Args} install 105 - ''; 106 - 107 - commonConfigureFlags = [ 108 - "--includedir=$(dev)/include" 109 - "--libdir=$(out)/lib" 110 - ]; 111 - 112 - fixup = '' 113 - # Make boost header paths relative so that they are not runtime dependencies 114 - ( 115 - cd "$dev" 116 - find include \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \ 117 - -exec sed '1i#line 1 "{}"' -i '{}' \; 118 - ) 119 - '' + optionalString (hostPlatform.libc == "msvcrt") '' 120 - ${stdenv.cc.targetPrefix}ranlib "$out/lib/"*.a 121 - ''; 71 + ]); 122 72 123 73 in 124 74 125 75 stdenv.mkDerivation { 126 76 name = "boost-${version}"; 127 77 128 - inherit src patches version; 78 + inherit src; 79 + 80 + patchFlags = optionalString (hostPlatform.libc == "msvcrt") "-p0"; 81 + patches = patches ++ optional (hostPlatform.libc == "msvcrt") (fetchurl { 82 + url = "https://svn.boost.org/trac/boost/raw-attachment/tickaet/7262/" 83 + + "boost-mingw.patch"; 84 + sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj"; 85 + }); 129 86 130 87 meta = { 131 88 homepage = http://boost.org/; ··· 142 99 --replace '@rpath/$(<[1]:D=)' "$out/lib/\$(<[1]:D=)"; 143 100 fi; 144 101 '' + optionalString (mpi != null) '' 145 - cat << EOF > user-config.jam 102 + cat << EOF >> user-config.jam 146 103 using mpi : ${mpi}/bin/mpiCC ; 147 104 EOF 105 + '' + optionalString (hostPlatform != buildPlatform) '' 106 + cat << EOF >> user-config.jam 107 + using gcc : cross : ${stdenv.cc.targetPrefix}c++ ; 108 + EOF 148 109 ''; 149 110 150 111 NIX_CFLAGS_LINK = stdenv.lib.optionalString stdenv.isDarwin ··· 152 113 153 114 enableParallelBuilding = true; 154 115 116 + nativeBuildInputs = [ which buildPackages.stdenv.cc ]; 155 117 buildInputs = [ expat zlib bzip2 libiconv ] 156 118 ++ optional (hostPlatform == buildPlatform) icu 157 119 ++ optional stdenv.isDarwin fixDarwinDylibNames ··· 159 121 ++ optional enableNumpy python.pkgs.numpy; 160 122 161 123 configureScript = "./bootstrap.sh"; 162 - configureFlags = commonConfigureFlags 163 - ++ [ "--with-python=${python.interpreter}" ] 164 - ++ optional (hostPlatform == buildPlatform) "--with-icu=${icu.dev}" 165 - ++ optional (toolset != null) "--with-toolset=${toolset}"; 124 + configurePlatforms = []; 125 + configureFlags = [ 126 + "--includedir=$(dev)/include" 127 + "--libdir=$(out)/lib" 128 + (if enablePython then "--with-python=${python.interpreter}" else "--without-python") 129 + (if hostPlatform == buildPlatform then "--with-icu=${icu.dev}" else "--without-icu") 130 + ] ++ optional (toolset != null) "--with-toolset=${toolset}"; 131 + 132 + buildPhase = '' 133 + ./b2 ${b2Args} 134 + ''; 166 135 167 - buildPhase = builder nativeB2Args; 136 + installPhase = '' 137 + # boostbook is needed by some applications 138 + mkdir -p $dev/share/boostbook 139 + cp -a tools/boostbook/{xsl,dtd} $dev/share/boostbook/ 168 140 169 - installPhase = installer nativeB2Args; 141 + # Let boost install everything else 142 + ./b2 ${b2Args} install 143 + ''; 170 144 171 - postFixup = fixup; 145 + postFixup = '' 146 + # Make boost header paths relative so that they are not runtime dependencies 147 + find "$dev/include" \( -name '*.hpp' -or -name '*.h' -or -name '*.ipp' \) \ 148 + -exec sed '1i#line 1 "{}"' -i '{}' \; 149 + '' + optionalString (hostPlatform.libc == "msvcrt") '' 150 + $RANLIB "$out/lib/"*.a 151 + ''; 172 152 173 153 outputs = [ "out" "dev" ]; 174 154 setOutputFlags = false; 175 - 176 - crossAttrs = rec { 177 - # We want to substitute the contents of configureFlags, removing thus the 178 - # usual --build and --host added on cross building. 179 - preConfigure = '' 180 - export configureFlags="--without-icu ${concatStringsSep " " commonConfigureFlags}" 181 - cat << EOF > user-config.jam 182 - using gcc : cross : $crossConfig-g++ ; 183 - EOF 184 - ''; 185 - buildPhase = builder crossB2Args; 186 - installPhase = installer crossB2Args; 187 - postFixup = fixup; 188 - } // optionalAttrs (hostPlatform.libc == "msvcrt") { 189 - patches = fetchurl { 190 - url = "https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/" 191 - + "boost-mingw.patch"; 192 - sha256 = "0s32kwll66k50w6r5np1y5g907b7lcpsjhfgr7rsw7q5syhzddyj"; 193 - }; 194 - 195 - patchFlags = "-p0"; 196 - }; 197 155 }