2021-10-28 06:52:43 +00:00
|
|
|
{ stdenv, lib
|
|
|
|
, build2
|
|
|
|
, fetchurl
|
|
|
|
, fixDarwinDylibNames
|
|
|
|
, libbutl
|
|
|
|
, libpkgconf
|
2023-07-15 17:15:38 +00:00
|
|
|
, buildPackages
|
2021-10-28 06:52:43 +00:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
|
|
, enableStatic ? !enableShared
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
configSharedStatic = enableShared: enableStatic:
|
|
|
|
if enableShared && enableStatic then "both"
|
|
|
|
else if enableShared then "shared"
|
|
|
|
else if enableStatic then "static"
|
|
|
|
else throw "neither shared nor static libraries requested";
|
|
|
|
in
|
2021-09-18 10:52:07 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "build2";
|
2022-10-30 15:09:59 +00:00
|
|
|
version = "0.15.0";
|
2021-10-28 06:52:43 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" "doc" "man" ];
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-10-28 06:52:43 +00:00
|
|
|
url = "https://pkg.cppget.org/1/alpha/build2/build2-${version}.tar.gz";
|
2022-10-30 15:09:59 +00:00
|
|
|
sha256 = "07369gw6zlad6nk29564kj17yp145l3dzbgrx04pyiyl1s84aa1r";
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
patches = [
|
|
|
|
# Remove any build/host config entries which refer to nix store paths
|
|
|
|
./remove-config-store-paths.patch
|
|
|
|
# Pick up sysdirs from NIX_LDFLAGS
|
|
|
|
./nix-ldflags-sysdirs.patch
|
2022-10-06 18:32:54 +00:00
|
|
|
|
|
|
|
./remove-const-void-param.patch
|
2021-10-28 06:52:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
nativeBuildInputs = [
|
|
|
|
build2
|
|
|
|
];
|
|
|
|
disallowedReferences = [
|
|
|
|
build2
|
|
|
|
libbutl.dev
|
|
|
|
libpkgconf.dev
|
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
libbutl
|
|
|
|
libpkgconf
|
|
|
|
];
|
|
|
|
|
|
|
|
# Build2 uses @rpath on darwin
|
|
|
|
# https://github.com/build2/build2/issues/166
|
|
|
|
# N.B. this only adjusts the install_name after all libraries are installed;
|
|
|
|
# packages containing multiple interdependent libraries may have
|
|
|
|
# LC_LOAD_DYLIB entries containing @rpath, requiring manual fixup
|
|
|
|
propagatedBuildInputs = lib.optionals stdenv.targetPlatform.isDarwin [
|
|
|
|
fixDarwinDylibNames
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
# Build2 needs to use lld on Darwin because it creates thin archives when it detects `llvm-ar`,
|
|
|
|
# which ld64 does not support.
|
|
|
|
(lib.getBin buildPackages.llvmPackages_16.lld)
|
2021-10-28 06:52:43 +00:00
|
|
|
];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs --build tests/bash/testscript
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
build2ConfigureFlags = [
|
|
|
|
"config.bin.lib=${configSharedStatic enableShared enableStatic}"
|
|
|
|
"config.cc.poptions+=-I${lib.getDev libpkgconf}/include/pkgconf"
|
2022-10-30 15:09:59 +00:00
|
|
|
"config.build2.libpkgconf=true"
|
2021-10-28 06:52:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
|
|
|
install_name_tool -add_rpath "''${!outputLib}/lib" "''${!outputBin}/bin/b"
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
postFixup = ''
|
|
|
|
substituteInPlace $dev/nix-support/setup-hook \
|
|
|
|
--subst-var-by isTargetDarwin '${toString stdenv.targetPlatform.isDarwin}'
|
|
|
|
'';
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
passthru = {
|
|
|
|
bootstrap = build2;
|
|
|
|
inherit configSharedStatic;
|
|
|
|
};
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://www.build2.org/";
|
|
|
|
description = "build2 build system";
|
|
|
|
license = licenses.mit;
|
|
|
|
longDescription = ''
|
|
|
|
build2 is an open source (MIT), cross-platform build toolchain
|
|
|
|
that aims to approximate Rust Cargo's convenience for developing
|
|
|
|
and packaging C/C++ projects while providing more depth and
|
|
|
|
flexibility, especially in the build system.
|
|
|
|
|
|
|
|
build2 is a hierarchy of tools consisting of a general-purpose
|
|
|
|
build system, package manager (for package consumption), and
|
|
|
|
project manager (for project development). It is primarily aimed
|
|
|
|
at C/C++ projects as well as mixed-language projects involving
|
|
|
|
one of these languages (see bash and rust modules, for example).
|
|
|
|
'';
|
2021-10-28 06:52:43 +00:00
|
|
|
changelog = "https://git.build2.org/cgit/build2/tree/NEWS";
|
2021-09-18 10:52:07 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ hiro98 r-burns ];
|
2022-04-27 09:35:20 +00:00
|
|
|
mainProgram = "b";
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
|
|
|
}
|