2021-04-05 15:23:46 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, bison
|
2021-09-18 10:52:07 +00:00
|
|
|
# boost derivation to use for the src and version.
|
|
|
|
# This is used by the boost derivation to build
|
|
|
|
# a b2 matching their version (by overriding this
|
|
|
|
# argument). Infinite recursion is not an issue
|
|
|
|
# since we only look at src and version of boost.
|
|
|
|
, useBoost ? {}
|
2021-04-05 15:23:46 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
let
|
|
|
|
defaultVersion = "4.4.1";
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "boost-build";
|
2021-09-18 10:52:07 +00:00
|
|
|
version =
|
|
|
|
if useBoost ? version
|
|
|
|
then "boost-${useBoost.version}"
|
|
|
|
else defaultVersion;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
src = useBoost.src or (fetchFromGitHub {
|
2020-04-24 23:36:52 +00:00
|
|
|
owner = "boostorg";
|
|
|
|
repo = "build";
|
2021-09-18 10:52:07 +00:00
|
|
|
rev = defaultVersion;
|
2021-04-05 15:23:46 +00:00
|
|
|
sha256 = "1r4rwlq87ydmsdqrik4ly5iai796qalvw7603mridg2nwcbbnf54";
|
2021-09-18 10:52:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
# b2 is in a subdirectory of boost source tarballs
|
|
|
|
postUnpack = lib.optionalString (useBoost ? src) ''
|
|
|
|
sourceRoot="$sourceRoot/tools/build"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
patches = [
|
|
|
|
# Upstream defaults to gcc on darwin, but we use clang.
|
|
|
|
./darwin-default-toolset.patch
|
|
|
|
];
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2021-04-05 15:23:46 +00:00
|
|
|
runHook preBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
./bootstrap.sh
|
2021-04-05 15:23:46 +00:00
|
|
|
runHook postBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-04-05 15:23:46 +00:00
|
|
|
runHook preInstall
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
./b2 install --prefix="$out"
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
# older versions of b2 created this symlink,
|
|
|
|
# which we want to support building via useBoost.
|
|
|
|
test -e "$out/bin/bjam" || ln -s b2 "$out/bin/bjam"
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2021-04-05 15:23:46 +00:00
|
|
|
homepage = "https://www.boost.org/build/";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = lib.licenses.boost;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ ivan-tkatchev ];
|
|
|
|
};
|
|
|
|
}
|