Unverified Commit beab3b86 authored by Peder Bergebakken Sundt's avatar Peder Bergebakken Sundt Committed by GitHub
Browse files

Merge pull request #324400 from CyberShadow/ldc-include-output

ldc: split includes to separate output
parents bf30c9e3 2ac637b0
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
, callPackage
, makeWrapper
, runCommand
, writeText
, targetPackages

, ldcBootstrap ? callPackage ./bootstrap.nix { }
@@ -73,8 +74,12 @@ stdenv.mkDerivation (finalAttrs: {

  buildInputs = [ curl tzdata ];

  outputs = [ "out" "include" ];
  outputInclude = "include";

  cmakeFlags = [
    "-DD_FLAGS=-d-version=TZDatabaseDir;-d-version=LibcurlPath;-J${pathConfig}"
    "-DINCLUDE_INSTALL_DIR=${placeholder "include"}/include/d"
  ];

  postConfigure = ''
@@ -142,4 +147,35 @@ stdenv.mkDerivation (finalAttrs: {
    maintainers = with maintainers; [ lionello jtbx ];
    platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
  };

  passthru.tests = let
    ldc = finalAttrs.finalPackage;
    helloWorld = stdenv.mkDerivation (finalAttrs: {
      name = "ldc-hello-world";
      src = writeText "hello_world.d" ''
        module hello_world;
        import std.stdio;
        void main() {
          writeln("Hello, world!");
        }
      '';
      dontUnpack = true;
      buildInputs = [ ldc ];
      dFlags = [];
      buildPhase = ''
        ldc2 ${lib.escapeShellArgs finalAttrs.dFlags} -of=test $src
      '';
      installPhase = ''
        mkdir -p $out/bin
        mv test $out/bin
      '';
    });
  in {
    # Without -shared, built binaries should not contain
    # references to the compiler binaries.
    no-references-to-compiler = helloWorld.overrideAttrs {
      disallowedReferences = [ ldc ];
      dFlags = ["-g"];
    };
  };
})