about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/misc/netcoredbg/default.nix
blob: cb0c1cdc8ec7c82751efacd19f6c65885f9ed3b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ lib, clangStdenv, stdenvNoCC, cmake, fetchFromGitHub, dotnetCorePackages, buildDotnetModule }:
let
  pname = "netcoredbg";
  version = "1.2.0-825";

  # according to CMakeLists.txt, this should be 3.1 even when building for .NET 5
  coreclr-version = "3.1.19";
  coreclr-src = fetchFromGitHub {
    owner = "dotnet";
    repo = "coreclr";
    rev = "v${coreclr-version}";
    sha256 = "o1KafmXqNjX9axr6sSxPKrfUX0e+b/4ANiVQt4T2ybw=";
  };

  dotnet-sdk = dotnetCorePackages.sdk_5_0;

  src = fetchFromGitHub {
    owner = "Samsung";
    repo = pname;
    rev = version;
    sha256 = "JQhDI1+bVbOIFNkXixZnFB/5+dzqCbInR0zJvykcFCg=";
  };

  unmanaged = clangStdenv.mkDerivation rec {
    inherit src pname version;

    nativeBuildInputs = [ cmake dotnet-sdk ];

    hardeningDisable = [ "strictoverflow" ];

    preConfigure = ''
      dotnetVersion="$(${dotnet-sdk}/bin/dotnet --list-runtimes | grep -Po '^Microsoft.NETCore.App \K.*?(?= )')"
      cmakeFlagsArray+=(
        "-DDBGSHIM_RUNTIME_DIR=${dotnet-sdk}/shared/Microsoft.NETCore.App/$dotnetVersion"
      )
    '';

    cmakeFlags = [
      "-DCORECLR_DIR=${coreclr-src}"
      "-DDOTNET_DIR=${dotnet-sdk}"
      "-DBUILD_MANAGED=0"
    ];
  };

  managed = buildDotnetModule {
    inherit pname version src dotnet-sdk;

    projectFile = "src/managed/ManagedPart.csproj";
    nugetDeps = ./deps.nix;

    executables = [ ];
  };
in
stdenvNoCC.mkDerivation {
  inherit pname version;

  buildCommand = ''
    mkdir -p $out/share/netcoredbg $out/bin
    cp ${unmanaged}/* $out/share/netcoredbg
    cp ${managed}/lib/netcoredbg/* $out/share/netcoredbg
    ln -s $out/share/netcoredbg/netcoredbg $out/bin/netcoredbg
  '';

  meta = with lib; {
    description = "Managed code debugger with MI interface for CoreCLR";
    homepage = "https://github.com/Samsung/netcoredbg";
    license = licenses.mit;
    platforms = platforms.unix;
    maintainers = [ maintainers.leo60228 ];
  };
}