1{
2 lib,
3 stdenv,
4 build2,
5 DarwinTools,
6 fetchurl,
7 libuuid,
8 enableShared ? !stdenv.hostPlatform.isStatic,
9 enableStatic ? !enableShared,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "libbutl";
14 version = "0.17.0";
15
16 outputs = [
17 "out"
18 "dev"
19 "doc"
20 ];
21
22 src = fetchurl {
23 url = "https://pkg.cppget.org/1/alpha/build2/libbutl-${version}.tar.gz";
24 hash = "sha256-sFqaEf6s2rF1YcZjw5J6oY5ol5PbO9vy6NseKjrvTvs=";
25 };
26
27 nativeBuildInputs =
28 [
29 build2
30 ]
31 ++ lib.optionals stdenv.hostPlatform.isDarwin [
32 DarwinTools
33 ];
34
35 patches = [
36 # Install missing .h files needed by dependers
37 # https://github.com/build2/libbutl/issues/5
38 ./install-h-files.patch
39 ];
40
41 strictDeps = true;
42
43 # Should be true for anything built with build2,
44 # but especially important when bootstrapping
45 disallowedReferences = [ build2 ];
46
47 postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
48 substituteInPlace libbutl/uuid-linux.cxx \
49 --replace '"libuuid.so' '"${lib.getLib libuuid}/lib/libuuid.so'
50 '';
51
52 build2ConfigureFlags = [
53 "config.bin.lib=${build2.configSharedStatic enableShared enableStatic}"
54 ];
55
56 doCheck = true;
57
58 meta = with lib; {
59 description = "build2 utility library";
60 longDescription = ''
61 This library is a collection of utilities that are used throughout the
62 build2 toolchain.
63 '';
64 homepage = "https://build2.org/";
65 changelog = "https://git.build2.org/cgit/libbutl/log";
66 license = licenses.mit;
67 maintainers = with maintainers; [ r-burns ];
68 platforms = platforms.all;
69 };
70}